How to install the Symfony PHP Framework on Ubuntu 22.04

by time news

2023-10-18 12:44:33

Symfony is one of the most popular PHP frameworks used for web applications. It is known for its standalone components, which can be easily integrated into any other PHP project. Symfony is released as open source software and is suitable for creating PHP applications of any size.

This tutorial will show you how to install the Symfony PHP framework on Ubuntu 22.04.

Previous requirements

A server running Ubuntu 22.04. A valid domain name points to your server’s IP. A root password is set on the server.

Install PHP

Symfony is a PHP framework so PHP must be installed on your server. If it is not installed, you can install it with other dependencies using the following command.

apt install php php-json php-ctype php-curl php-mbstring php-xml
php-zip php-tokenizer php-tokenizer libpcre3 git zip unzip

Once PHP and other PHP components are installed, you can proceed to the next step.

Install Symfony on Ubuntu 22.04

The simplest and easiest way to install Symfony is through an automatic installation script.

You can download and run the Symfony installation script using the following command.

wget -O – | bash

Once Symfony is installed, you will get the following output.

2022-12-21 10:59:24 (11.6 MB/s) – written to stdout [6100/6100]

Symfony CLI installer

Environment check
[*] cURL is installed
[*] Tar is installed
[*] Git is installed
[*] Your architecture (amd64) is supported

Download
Downloading
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
100 5232k 100 5232k 0 0 2309k 0 0:00:02 0:00:02 –:–:– 7400k
Uncompress binary…
Installing the binary into your home directory…
The binary was saved to: /root/.symfony5/bin/symfony

The Symfony CLI was installed successfully!

Use it as a local file:
/root/.symfony5/bin/symfony

Or add the following line to your shell configuration file:
export PATH=”$HOME/.symfony5/bin:$PATH”

Or install it globally on your system:
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony

Then start a new shell and run ‘symfony’

Next, you will need to define the Symfony system path on your system. You can do it with the following command:

export PATH=”$HOME/.symfony5/bin:$PATH”
source ~/.bashrc

Create a Symfony project

At this point, Symfony is installed on your server. Now, you will need to create a new Symfony project to use it.

symfony new project –full

You will get the following result.

* Setting up the project under Git version control (running git init /root/project)

[OK] Your project is now ready in /root/project

Next, navigate to your project and run the web server using the following command.

cd project
symfony server:start

You should get the following result.

[OK] Web server listening
The Web server is using PHP CLI 8.1.2

[Web Server ] Dec 21 11:01:36 |DEBUG | PHP Reloading PHP versions
[Web Server ] Dec 21 11:01:36 |DEBUG | PHP Using PHP version 8.1.2 (from default version in $PATH)
[Application] Dec 21 11:01:15 |INFO | DEPREC User Deprecated: The “MonologLogger” class is considered final. It may change without further notice as of its next major version. You should not extend it from “SymfonyBridgeMonologLogger”.
[Web Server ] Dec 21 11:01:36 |INFO | PHP listening path=”/usr/bin/php8.1″ php=”8.1.2″ port=44005
[PHP ] [Wed Dec 21 11:01:36 2022] PHP 8.1.2-1ubuntu2.9 Development Server ( started

Acceder a Symfony

At this point, the Symfony server starts and listens on the port 8000. You can now access it using the URL You should see the default Symfony page on the next screen. Conclusion

Congratulations! You have successfully installed the Symfony PHP framework on Ubuntu 22.04. Now you can start creating a PHP based web application using the Symfony framework. Don’t hesitate to ask me if you have any questions.

#install #Symfony #PHP #Framework #Ubuntu

You may also like

Leave a Comment