3 C
Texas
angeloma
Senior Writer and partner

How to install Symfony PHP framework on Ubuntu 18.04?

On other occasions, we have talked about various PHP frameworks. For example, I taught you how to install Cake and Yii, but today I’ll teach you how to install Symfony which is perhaps one of the most robust.

Symfony PHP is a high-performance framework for developing web applications. So, it is very popular among groups of developers working on medium to large scale projects. In addition, it is one of the best-documented frameworks, with many books that teach you how to use its full potential.

So, let’s install Symfony on Ubuntu 18.04.

1. Install Apache web server

The first step is to install a web server, in this case, I will use Apache because it is easy to install and use.

- Advertisement -
:~$ sudo apt install apache2

1.- Install apache web server
1.- Install an Apache web server

Then, start and enable the service.

:~$ sudo systemctl enable apache2
:~$ sudo systemctl start apache2

2.- Enabling Apache
2.- Enabling Apache

And that’s it.

2. Install PHP

Since it is a PHP framework it is obvious that you have to install the PHP language. So let’s go for it.

:~$ sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip php-mysql php-curl

3.- Install PHP
3.- Install PHP

Now, restart apache.

:~$ sudo systemctl restart apache2

3. Install MariaDB

If you are going to develop with a framework, it is necessary to have a database manager, so install MariaDB.

:~$ sudo apt install mariadb-server

4.- Install MariaDB
4.- Install MariaDB

Then, enable and start the service.

:~$ sudo systemctl enable mariadb
:~$ sudo systemctl start mariadb

5.- Enabling MariaDB service
5.- Enabling MariaDB service

Now, set a root password for MariaDB. You can do it using the mysql_secure_installtion script.

:~$ sudo mysql_secure_installation

6.- Setting a root password for MariaDB
6.- Setting a root password for MariaDB

There you can configure other options, however, I leave it to your discretion the answers as for this tutorial are not decisive.

4. Install Symfony PHP

To install Symfony 4, you must first install Composer. Composer is a dependency manager for PHP.

:~$ wget https://getcomposer.org/installer
:~$ php installer

10.- Composer installed
10.- Composer installed

As you can see, after an initial connection error, composer is installed properly.

Next, make Composer a global command.

:~$ sudo mv composer.phar /usr/local/bin/composer 
:~$ sudo chmod +x /usr/local/bin/composer

11.- Setting Composer globally
11.- Setting Composer globally

5. Create a new project

Now it’s time to create a new Symfony project. It’s very simple.

:~$ composer create-project symfony/website-skeleton example

12.- Install Symfony
12.- Install Symfony

Obviously, put the name of the project you want.

13.- Symfony installed
13.- Symfony installed

Then, serve the project.

:~$ cd example
:~$ php bin/console server:run

14.- Symfony running
14.- Symfony running

Finally, open the web browser an go to http://IP_SERVER:8000. Or you can specify the IP and the port. It is useful if you are using a VM.

16.- Symfony running on a specific IP
16.- Symfony running on a specific IP

15.- Symfony is alive!
15.- Symfony is alive!

And that’s it.

Conclusion

While it is true that Symfony is a framework not so easy to learn, its installation on Ubuntu 18.04 is quite simple. All that’s left is for you to develop brilliant applications with it.

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article