RHEL BasedRocky Linux

How To Install Symfony Framework on Rocky Linux 9

Install Symfony Framework on Rocky Linux 9

In this tutorial, we will show you how to install Symfony Framework on Rocky Linux 9. Symfony is a PHP framework for web applications and a set of reusable PHP components. It is one of the most popular application frameworks among open-source developers due to its robustness, flexibility, and the extensive community support it receives. Symfony is suitable for building a wide range of applications, from small microservices to large-scale enterprise systems.

The framework is known for its adherence to the MVC (Model-View-Controller) pattern, although it is flexible enough to accommodate other architectural patterns as well. Symfony’s use of reusable components means that developers can create modular and maintainable codebases. Additionally, Symfony is recognized for its performance and has been designed to optimize the speed of web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Symfony Framework open-source PHP web framework on Rocky Linux 9 or RHEL-based.


  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for MailSpring.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
  • The Extra Packages for Enterprise Linux (EPEL) repository is enabled. This repository provides additional packages that are not included in the default Rocky Linux repositories.

Install Symfony Framework on Rocky Linux 9

Step 1. First, we‘ll update all system packages to their latest versions to avoid any potential conflicts:

sudo dnf update
sudo dnf install dnf-plugins-core

Step 2. Installing PHP 8.

Use Remi’s repository to install PHP 8.1 and the required extensions:

sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-8.1
sudo dnf install php php-fpm php-mbstring php-xml php-gd php-json php-mysqlnd php-zip php-intl

You can confirm the installed PHP version by running:

php -v

Step 3. Installing Composer.

Download and install Composer, the PHP package manager:

cd ~
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Step 4. Installing MySQL and Creating a Database.

For this guide, we’ll use MySQL as the database for our Symfony application. Install MySQL server using dnf:

sudo dnf install mysql-server

Start the MySQL service and enable it to start after system reboots:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Run mysql_secure_installation to improve MySQL security:


Next, log in with the root MySQL user:

mysql -u root -p

Create a database for Symfony:


Step 5. Installing Nginx and Configure Symfony Stack.

We’ll use Nginx as our web server. Install Nginx from the repository:

sudo dnf install nginx

Start Nginx and set it to start automatically on reboot:

sudo systemctl start nginx
sudo systemctl enable nginx

Now we need to configure Nginx to work with PHP-FPM which will process PHP files for us.

Open the default Nginx configuration file:

sudo nano /etc/nginx/nginx.conf

Uncomment the following lines by removing the # symbol:

include /etc/nginx/default.d/*.conf;

server {
    listen       80;

    # note that these lines are originally from the "location /" block
    index index.php index.html index.htm;
    try_files $uri $uri/ =404; 

Save and exit from the file after making the changes, then test the Nginx configuration and restart it:

sudo nginx -t
sudo systemctl restart nginx

Step 6. Installing Symfony Framework on Rocky Linux 9.

Now download the Symfony installer to get the symfony CLI command:

wget https://get.symfony.com/cli/installer -O - | bash

Ensure the Symfony CLI is correctly installed by checking its version:

symfony -v

Step 7. Creating a New Symfony Project.

Use the Symfony CLI to create a new project. This command sets up a new Symfony project in the specified directory:

symfony new my_project --webapp

Set permissions for the web server:

chown -R nginx:nginx my_project 
chmod -R 755 my_project

This will create a new Symfony project called my_project with a default directory structure.

Step 8. Configuration Nginx Web Server.

Now we’ll configure Nginx to serve our Symfony application using the my_project/public directory.

Create an Nginx virtual host configuration file:

sudo nano /etc/nginx/conf.d/myproject.conf

Add the following configuration:

server {
    listen 80;
    listen [::]:80;

    root /home/youruser/symfony-project/my_project/public;
    index index.php index.html index.htm;

    server_name symfony-project.test;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

This configures Nginx to serve our Symfony app from the public/ directory and forwards PHP requests to the PHP-FPM socket.

Check the Nginx configuration and reload it:

sudo nginx -t
sudo systemctl reload nginx

Step 9. Configure Environment Variables.

Our Symfony application expects some environment variables to be set including database credentials.

Open the .env file:

nano .env

Update the following lines with your database credentials:


Be sure to replace db_user, db_password with your actual MySQL credentials and symfony_db with your database name.

Step 10. Installing Symfony Dependencies.

Navigate to your project directory and use Composer to install PHP dependencies for Symfony:

cd my_project
composer install

This will install all libraries that Symfony requires including Twig, Doctrine, etc. under the vendor/ folder.

Step 11. Initialize the Database Schema.

The final step is to build our database schema which can be done with the following commands:

php bin/console doctrine:database:create
php bin/console make:migration
php bin/console doctrine:migrations:migrate

This creates the configured database, makes an initial migration, and runs it to build all defined database tables and relationships.

Our Symfony setup is complete! The application can be accessed via the configured Nginx virtual host:


You should see Symfony’s default welcome page.

Install Symfony Framework on Rocky Linux 9

Congratulations! You have successfully installed Symfony. Thanks for using this tutorial for installing the Symfony Framework on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Symfony website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button