Symfony 7 is a robust PHP framework following an LTS release cycle. Known for its reusable components and strict standards, Symfony powers enterprise applications worldwide. This guide installs a Symfony 7 application on Ubuntu 26.04 LTS with Nginx and PHP-FPM.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS with Nginx and PHP 8.4 installed
- Composer installed globally
- Symfony CLI (optional but recommended)
Step 1 – Install Required PHP Extensions
sudo apt install php8.4-fpm php8.4-xml php8.4-mbstring php8.4-intl
php8.4-curl php8.4-mysql php8.4-zip -y
Step 2 – Install the Symfony CLI
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo bash
sudo apt install symfony-cli -y
symfony --version
Step 3 – Create a New Symfony 7 Project
cd /var/www
sudo symfony new myapp --version=7.x --webapp
sudo chown -R www-data:www-data /var/www/myapp
Step 4 – Configure Environment
cd /var/www/myapp
cp .env .env.local
nano .env.local
Set:
APP_ENV=prod
DATABASE_URL=mysql://sfuser:[email protected]:3306/sfdb?serverVersion=9.0
Step 5 – Create the Nginx Config
sudo nano /etc/nginx/sites-available/symfony
Add:
server {
listen 80;
server_name example.com;
root /var/www/myapp/public;
location / { try_files $uri /index.php$is_args$args; }
location ~ ^/index.php(/|$) {
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_split_path_info ^(.+.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ .php$ { return 404; }
}
sudo ln -s /etc/nginx/sites-available/symfony /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Step 6 – Install Composer Dependencies
cd /var/www/myapp
composer install --no-dev --optimize-autoloader
Step 7 – Clear and Warm Cache
APP_ENV=prod php bin/console cache:clear
APP_ENV=prod php bin/console cache:warmup
Conclusion
Symfony 7 is now deployed on Ubuntu 26.04 LTS. Configure your database connection, run migrations with php bin/console doctrine:migrations:migrate, and add HTTPS with Certbot.