Your cart is currently empty!
Install the Symfony PHP Framework on Ubuntu Server 22.04
Symfony is a powerful PHP framework used by developers worldwide to build robust web applications. If you’re running Ubuntu Server 22.04 and want to get Symfony up and running, follow these steps. No fluff, just the essentials.
Prerequisites
Before you start, make sure you have:
- A fresh Ubuntu 22.04 server
- Access to the terminal (SSH)
- A user with sudo privileges
Optional:
If you’d prefer to work with a graphical interface on your server instead of the command line, check out this guide:
How to Install a Desktop Environment/GUI in Ubuntu Server
1. Update Your Server
First, update your package list and upgrade the installed packages:
sudo apt update
sudo apt upgrade -y
2. Install PHP and Required Extensions
Symfony needs PHP 8.1 or higher. Let’s install PHP along with the necessary extensions:
sudo apt install -y php php-cli php-fpm php-xml php-mbstring php-zip php-curl php-intl php-sqlite3 unzip git
Check your PHP version:
php -v
You should see PHP 8.1 or newer.
3. Install Composer
Composer is the dependency manager for PHP. Download and install it globally:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version
4. Install Symfony CLI
Symfony has its own CLI tool to make your life easier. Here’s how to install it:
wget https://get.symfony.com/cli/installer -O - | bash
This puts the symfony
binary in your home directory’s .symfony/bin
folder. To make it available globally:
sudo mv ~/.symfony/bin/symfony /usr/local/bin/symfony
symfony -v
5. Create a New Symfony Project
Pick a directory where you want your project to live. For example, in your home directory:
cd ~
symfony new my_project_name --webapp
This command sets up a new Symfony project with all the typical web features.
6. Start the Local Web Server
Move into your project folder:
cd my_project_name
Run the local web server:
symfony serve
By default, your app is available at http://localhost:8000
. If you want it available from other machines, use:
symfony serve --allow-http
Wrapping Up
You’ve now got Symfony running on Ubuntu 22.04. From here, you can start building your web application. If you want to deploy or use a production web server (like Apache or Nginx), you’ll need to configure your web server to point to the public/
directory of your Symfony project.
Questions or stuck somewhere? Drop a comment below.
Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!