How to Install Symfony 5 Framework with Nginx on Debian 10

page1 19

How to Install Symfony 5 Framework with Nginx on Debian 10

Symfony is a free, open-source and high-performance PHP framework that can be used to build web applications, APIs, microservices and web services. Symfony allows you to create web applications without monotonous and extensive coding. Symfony comes with a set of tools that helps you to test, debug and document projects. Symfony uses the Model-View-Controller design pattern and aims to speed up the creation and maintenance of web applications.

In this tutorial, we will show you how to install Symfony 5 with Nginx on Debian 10.


  • A server running Debian 10.
  • A root password is configured on your server.

Getting Started

Before starting, it is recommended to update your server with the latest version using the following command:
apt-get update -y
apt-get upgrade -y

Once your server is updated, restart it to implement the changes.

Install Nginx, MariaDB, and PHP

First, you will need to install Nginx, MariaDB, PHP and other required libraries on your server. You can install all of them with the following command:
apt-get install nginx mariadb-server php php-fpm php-common php-mysql php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-bcmath php-soap php-ldap php-imap php-xml php-cli php-zip git unzip wget -y

Once all the packages are installed, start Nginx and MariaDB service and enable them to start on system reboot with the following command:
systemctl start nginx
systemctl start mariadb
systemctl enable nginx
systemctl enable mariadb

Once you are done, you can proceed to the next step.

Install Symfony 5

First, you will need to install the Composer on your server. You can download the Composer installation script with the following command:
wget https://getcomposer.org/installer

Next, run the installer as shown below:
php installer

Once the Composer has been downloaded, you should see the following output:
All settings correct for using Composer

Composer (version 1.9.1) successfully installed to: /root/composer.phar
Use it: php composer.phar

Next, move the Composer to /usr/local/bin directory and make it executable:
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

Now, change the directory to the /var/www/html and install Symfony 5 with the following command:
cd /var/www/html
composer create-project symfony/skeleton symfony5

Next, give proper permissions to the symfony5 directory as shown below:
chown -R www-data:www-data /var/www/html/symfony5
chmod -R 755 /var/www/html/symfony5

Configure Nginx for Symfony 5

Next, you will need to create an Nginx virtual host configuration file for Symfony 5. You can create it with the following command:
nano /etc/nginx/sites-available/symfony.conf

Add the following lines:
server {
server_name your-server-ip;
root /var/www/html/symfony5/public;
location / {
try_files $uri /index.php$is_args$args;
location ~ ^/index.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.3-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;
location ~ .php$ {
return 404;
error_log /var/log/nginx/symfony_error.log;
access_log /var/log/nginx/symfony_access.log;

Save and close the file when you are finished. Then, enable the Nginx virtual host with the following command:
ln -s /etc/nginx/sites-available/symfony.conf /etc/nginx/sites-enabled/

Next, check the Nginx for any syntax error with the following command:
nginx -t

You should see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart the Nginx service to implement the changes:
systemctl restart nginx

Access Symfony5

Symfony4 is now installed, you can access it by visiting the URL http://your-server-ip on your web browser. You should see the Symfony 5 welcome page:

Symfony 4 on Debian

Congratulations! you have successfully installed Symfony5 on Debian 10 server. You can now host any PHP application using Symfony 5.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !