|
php
nginx
ubuntu
tutorial
Setting Up a PHP 8.4 Development Environment
Setting Up a PHP 8.4 Development Environment
This guide walks through setting up a modern PHP development environment with PHP 8.4, MySQL 8, and nginx.
Prerequisites
- Ubuntu 22.04 or newer
- sudo access
- Basic terminal knowledge
Installing PHP 8.4
First, add the Ondrej PHP repository:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Then install PHP 8.4 with common extensions:
sudo apt install php8.4-fpm php8.4-mysql php8.4-mbstring php8.4-xml php8.4-curl
Configuring nginx
Create a new site configuration:
server {
listen 80;
server_name mysite.local;
root /var/www/mysite/public;
index index.php;
location ~ .php$ {
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Testing Your Setup
Create a simple PHP file to verify everything works:
<?php
declare(strict_types=1);
phpinfo();
Conclusion
You now have a working PHP 8.4 development environment. Happy coding!