قالب وردپرس درنا توس
Home / How To / How to install Symfony 5 Framework with Nginx on Debian 10

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. With Symfony you can create web applications without monotonous and extensive coding. Symfony comes with a set of tools to help you test, troubleshoot, 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.

Prerequisites [19659004] A server running Debian 10.
  • A root password is configured on your server.
  • Getting Started

    Before you begin, it is recommended that you update your server with the latest version with the following command:

      apt-get update -y 
    apt-get upgrade -y

    When your server has updated, restart it to implement the changes.

    Installing Nginx, MariaDB and PHP

    First you need to install Nginx, MariaDB, PHP and other required libraries on your server. You can install all 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 packages have been installed, start Nginx and MariaDB service and allow them to start at system startup with the following command: [1

    9659007] systemctl start nginx
    systemctl start mariadb
    systemctl enable nginx
    systemctl enable mariadb

    When you are finished, you can proceed to the next step.

    Installing Symfony 5

    First you need to install Composer on your server. You can download the Composer install script with the following command:

      wget https://getcomposer.org/installer tu 1919900900 Next, run the installer as shown below: 

      php installer 

    Once Composer has been downloaded, you should see the following output:

      All settings correct to use Composer
    Downloading...
    
    Composer (version 1.9.1) has been successfully installed at: /root/composer.phar
    Use it: php composer.phar
    

    Then 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 [19659008] Now change the directory to / var / www / html and install Symfony4 with the following command:

      cd / var / www / html 
    composer create-project symfony / skeleton symfony5

    Next, give appropriate permissions to symfony4 directory 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 need to create an Nginx virtual host configuration file for Symfony4. You can create it with the following command:

      nano /etc/nginx/sites-available/symfony.confebrit19659009vardAdd 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;
    internal;
    }
    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 done. Then enable the Nginx virtual host with the following command:

      ln -s /etc/nginx/sites-available/symfony.conf / etc / nginx / sites-enabled / 

    Next, check Nginx for syntax errors with the following command:

      nginx -t 

    You should see the following output:

      nginx: configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: /etc/nginx/nginx.conf test configuration file succeeded
    

    Finally, restart the Nginx service to implement the changes:

      systemctl restart nginx 

    Access Symfony5

    Symfony4 is now installed, you can access it by visiting URL http: // your-server-ip in your browser. You should see Symfony 5 Welcome Page:

     Symfony 4 on Debian

    Congratulations! you have installed Symfony5 on the Debian 10 server. You can now host all PHP applications with Symfony 5.

      Hitesh Jethva

    About Hitesh Jethva

    Over 8 years of experience as a Linux system administrator. My skills include deep knowledge of Redhat / Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, octopus proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud , Postfix Mail Server, Security etc.


    Source link