Install Symfony 5 on Ubuntu with Apache

Richard
Written by
Richard
Jan 9, 2020 Updated Apr 26, 2026 4 min read

This guide helps you ubuntu-linux/" class="sal-link" rel="noopener" target="_blank" data-sal-id="21781">install the Symfony 5 framework on Ubuntu. Symfony is a tool for developers that makes building websites and apps faster. It handles the repetitive coding tasks so you don’t have to.

Why use Symfony? It provides ready-made components that save you time and help you build professional web applications more efficiently.

What happens when done? You will have a working web server running the Symfony framework, ready for you to start building your own web projects.

To learn more, visit the official Homepage website.

Step 1: Install the Apache2 Web Server

Symfony needs a web server to run. Apache2 is a popular choice. Requires admin privileges.

🐧Bash / Shell
sudo apt update
sudo apt install apache2

Use these commands to manage the server:

🐧Bash / Shell
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Check if it works by opening your web browser and typing:

💻Code
http://localhost

Step 2: Install PHP

Symfony is built using PHP. You need to install it and its related modules. Requires admin privileges.

🐧Bash / Shell
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
🐧Bash / Shell
sudo apt update
🐧Bash / Shell
sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-sqlite3 php7.2-mysql php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-ldap php7.2-gd php7.2-bcmath php7.2-xml php7.2-cli php7.2-zip

Now, edit your PHP configuration file:

🐧Bash / Shell
sudo nano /etc/php/7.2/apache2/php.ini

Update the file with these settings and save your changes:

💻Code
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Restart Apache to apply the new settings:

🐧Bash / Shell
sudo systemctl restart apache2.service

Create a test file to make sure PHP is working correctly:

🐧Bash / Shell
sudo nano /var/www/html/phpinfo.php

Add this code to the file and save:

🐘PHP
<?php phpinfo( ); ?>

Open your browser and visit:

🐘PHP
http://localhost/phpinfo.php
PHP Test Page

Step 3: Download Symfony

We will use a tool called Composer to download the framework. Requires admin privileges.

🐧Bash / Shell
sudo apt install curl git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Change to the web directory and create your project folder:

Command Prompt
cd /var/www/
sudo composer create-project symfony/skeleton symfony5

Set the correct permissions so the server can access the files:

🐧Bash / Shell
sudo chown -R www-data:www-data /var/www/symfony5/
sudo chmod -R 755 /var/www/symfony5/

Step 4: Configure Apache

Create a configuration file to tell Apache how to serve your Symfony project. Requires admin privileges.

🐧Bash / Shell
sudo nano /etc/apache2/sites-available/symfony.conf

Paste this content into the file. Make sure to update your domain name and folder path:

💻Code
<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/symfony5/public
     ServerName example.com
     ServerAlias www.example.com

     <Directory /var/www/symfony5/public/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step 5: Enable Symfony

Activate your new configuration and restart the server. Requires admin privileges.

🐧Bash / Shell
sudo a2ensite symfony.conf
sudo systemctl restart apache2.service

Visit your site in your browser:

💻Code
http://example.com/
Symfony Ubuntu Install

Your Symfony 5 setup is complete and ready for use.

Summary

In this tutorial, we installed the Apache2 web server, set up PHP, downloaded the Symfony 5 framework using Composer, and configured the server to display your new application. You are now ready to begin developing your web projects.

How do I install Symfony 5 on Ubuntu?

To install Symfony 5 on Ubuntu, first install Apache2 and PHP 7.2. Follow the step-by-step guide to update your package list, install the necessary software, and configure PHP settings.

What are the system requirements for Symfony 5?

Symfony 5 requires PHP 7.2 or higher and a web server like Apache2. Ensure that you have the necessary PHP extensions installed for optimal performance.

Can I use Symfony 5 without Apache2?

Yes, while Apache2 is a popular choice, Symfony 5 can also run on other web servers like Nginx. You will need to configure your server settings accordingly.

What is the purpose of the PHP configuration file in Symfony?

The PHP configuration file (php.ini) allows you to set various parameters that affect PHP's behavior, such as memory limits and file upload sizes, which are crucial for running Symfony applications smoothly.

How can I test if Apache2 is installed correctly?

After installing Apache2, you can test its installation by opening your web browser and navigating to http://localhost. If you see the default Apache2 page, the installation was successful.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

0 Comments

  • victoria

    hello, i have a problem would you help me please?
    [Composer\Downloader\TransportException]
    Content-Length mismatch, received 640535 bytes out of the expected 1912309
    thank you

    Reply
  • Dustin Dinsmore

    All my steps went well, but it keeps displaying Apache2 Ubuntu Default Page?

    Reply
  • Hello, very good tutorial which was very useful to me since I am new to symfony. I just wanted to add that I had some problems accessing my web page http://www.example.com from my web browser on windows. I am using windows 10 and I installed symphony on a virtual machine with the operating system Ubuntu 18 server. however I was able to solve the problem by editing the etc / hosts file under windows. Otherwise the tutorial is good.

    Thank you so much !

    Reply
  • j carranza

    Thanks,

    I would like the same for Ubuntu 20.04
    php 7.4.10

    I’ve installed XAMPP and it works fine but I would like to continue with Symfony 5

    Reply
  • Great achievement, I really appreciate.

    Reply
  • Hello! This is one of the best tutorials for this theme i’ ve seen, because everything else i try – simply doesnt work. But in the last step here i have again some trouble – when i try to open http://www.example.com, it opens page with text Example Domain in a gray square in middle of screen. Not the symfony page that you have in picture in the ending. What to do?

    Reply
  • Luis Silveira

    Nice tutorial and very easy to follow. I installed Symfony on my Ubuntu 20.04 LTS and it works perfectly.
    As I have to use Symfony and Doctrine with PostgreSQL, I had to add the command below in order to enable the PHP module for the database:

    $ sudo apt install php7.2-pgsql

    Reply
  • Didier Roy

    very nice tuto. All working fine.
    Just added 127.0.0.1 example.com into /etc/hosts

    Reply
  • mohammed

    Thank you very much bro

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version