Symfony 7 is a high-performance PHP framework built for flexibility and scalability. This guide installs the Symfony CLI and creates a new Symfony 7 web application on Ubuntu 24.04 LTS.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- PHP 8.3 installed
- Composer installed
- A user with sudo privileges
Step 1 – Install the Symfony CLI
Download and install the Symfony binary:
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash -
sudo apt install symfony-cli -y
Step 2 – Create a New Symfony 7 Web Application
Create a full web app skeleton:
symfony new myapp --version="7.1.*" --webapp
cd myapp
Step 3 – Check PHP Requirements
Verify your environment meets Symfony requirements:
symfony check:requirements
Step 4 – Start the Development Server
Use the Symfony local server:
symfony server:start
Visit https://127.0.0.1:8000 in your browser.
Step 5 – Configure the Database
Edit the .env file and set the DATABASE_URL:
nano .env
Example for MySQL:
DATABASE_URL="mysql://myuser:[email protected]:3306/mydb?serverVersion=8.0"
Create the database and run migrations:
php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate
Step 6 – Configure Nginx for Production
Create an Nginx server block pointing to the public/ directory:
sudo nano /etc/nginx/sites-available/symfony
Add:
server {
listen 80;
server_name symfony.example.com;
root /var/www/myapp/public;
index index.php;
location / { try_files $uri /index.php$is_args$args; }
location ~ ^/index.php(/|$) {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_split_path_info ^(.+.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
internal;
}
}
Step 7 – Set Production Environment
Update APP_ENV in .env and clear cache:
nano .env # set APP_ENV=prod
php bin/console cache:clear --env=prod
Conclusion
Symfony 7 is now installed on Ubuntu 24.04 LTS. The Symfony CLI provides a powerful development environment, while Nginx handles production traffic with PHP 8.3-FPM.