Atlantic.Net Blog

How to Install Symfony Framework on Fedora

Symfony is a free and open-source PHP web application framework for building web applications, APIs, microservices, and web services. It provides tools and features for building scalable PHP web applications with a robust caching system. It has comprehensive documentation and an active community, making it an excellent resource for developers looking to create high-quality PHP web applications.

This post will show you how to install the Symfony framework on Fedora Linux.

In This Article

Step 1 – Install the LAMP Server

Symfony is based on PHP, so you will need to install the LAMP server on your server.

First, install the Apache and MariaDB server using the following command.

dnf install httpd mariadb-server -y 

Next, add the PHP Remi repo to get the latest PHP version.

dnf install -y http://rpms.remirepo.net/fedora/remi-release-34.rpm
dnf module install php:remi-8.1

Next, install PHP with other required PHP extensions using the following command.

dnf install php php-cli php-common php-spl php-fpm php-hash php-ctype php-json php-mbstring  php-gd php-curl php-mysqli php-xml php-gmp php-xmlrpc php-bcmath php-soap php-ldap unzip -y

Next, start and enable Apache, MariaDB, and PHP-FPM.

systemctl start httpd mariadb php-fpm
systemctl enable httpd mariadb php-fpm

Step 2 – Install Symfony

First, install Composer with the following command.

wget https://getcomposer.org/installer -O composer-installer.php
php composer-installer.php --filename=composer --install-dir=/usr/local/bin

Next, navigate to the Apache web root directory and install Symfony 6 with the following command.

cd /var/www/html
composer create-project symfony/website-skeleton symfony6

Next, set proper permission and ownership to the Symfony directory.

chown -R apache:apache /var/www/html/symfony6
chmod -R 755 /var/www/html/symfony6

Now, change the directory to Symfony and start the Symfony server with the following command.

cd /var/www/html/symfony6
php -S 0.0.0.0:8000 -t public

You will see the following output.

[Thu Aug 17 00:17:19 2023] PHP 8.1.9 Development Server (http://0.0.0.0:8000) started

Now, open your web browser and access Symfony using the URL http://your-server-ip:8000. You will see the following screen.

Next, press CTRL+C to stop the Symfony server. We will configure Apache for Symfony.

Step 3 – Configure Apache for Symfony 6

Next, you must create an Apache virtual host configuration file for Symfony.

nano /etc/httpd/conf.d/symfony.conf

Add the following configuration:

<VirtualHost *:80>
   ServerAdmin [email protected]
   DocumentRoot "/var/www/html/symfony6/public"
   ServerName symfony.example.com

    <Directory /var/www/html/symfony6/public>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

   ErrorLog "/var/log/httpd/example.com-error_log"
   CustomLog "/var/log/httpd/example.com-access_log" combined

</VirtualHost>

Save and close the file when you are done.

Then, restart the Apache service to apply the changes.

systemctl restart httpd

Step 4 – Access Symfony Web Interface

Now, open your web browser and access the Symfony dashboard using the URL http://symfony.example.com.

symfony dashboard

Conclusion

In this post, we showed you how to install Symfony6 on Fedora Linux. You can build and deploy a scalable PHP application using the Symfony framework. You can now try Symfony on dedicated server hosting from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year