We are going to learn how to install Laravel on Ubuntu 22.04. This information can also be used as a Laravel installation guide on the VPS server. Read each step carefully to get a clear idea. You can directly for step 3 if you already have the server ready with Apache, PHP, MySQL and configured the host for the website. Ie skip the step 1 to 3 if you are trying to install Laravel with Cpanel

Step 1: Install the Apache, MySQL, and PHP on Linux Server

All you need to install Apache, PHP, and MySQL on the Linux server for installing the Laravel framework. An open source PHP framework.

To do so please visit the link:

Installation of Apache, MySQL, and PHP

Once your installation of PHP, MySQL, and Apache is completed, you can now start installing the Laravel to your VPS.

Step 2: Create a Virtual Host on Linux VPS

To create a virtual host you need to add the host entry to the apache conf file.

First copy the default Apache virtual host 000-default.conf file to your_domain.com.conf, This will copy the entire content from the default file to your virtual host conf file.

$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/your_domain.com.conf

Now open the newly created conf file for adding our host details.
$ sudo nano /etc/apache2/sites-available/alpha.www.dev9.sunsoftworld.com.conf

This will open the file for editing, Now add/append the following content to it.

<VirtualHost *:80>
    ServerName your_domain.com
    ServerAlias your_domain.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/your_domain/public/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/www/your_domain/public/">
         AllowOverride all
         Require all granted

Save the file by ctrl + X confirm by Y and then press Enter.

Now you need to disable the default configuration and enable the new configuration file you just saved.

Disable the default host configuration file by Command
$ sudo a2dissite 000-default.conf

Enable the newly created Virtual Host configuration file by Command
$ sudo a2ensite your_domain.com.conf

Restart Apache server by Command:
$ sudo systemctl restart apache2

Check Apache server Status by Command:
$ sudo systemctl status apache2

Now test the newly created host in the browser.
curl http://your_domain.com

Step 3: Install phpMyAdmin on Ubuntu

On VPS there is no user interface for you to work with a database so if you want to make the Database import and alteration easy you can install the phpMyAdmin. else you can go to step 4 directly.

By Composer

$ composer create-project /var/www/your_domain.com/phpmyadmin

if the auto installation is not working for some reason you can install it manually


1) Download the zip file from
Download latest version
2) Upload it to /var/www/ directory
3) unzip all content to /var/www/your_domain.com directory
4) take ownership:
$ sudo chown -R $user:$user /var/www/your_domain.com
5) Create a new virtual host as pma.your_domain.com (See step 1 to create a virtual host)
6) If the following occurred:
Composer detected issues in your platform: Your Composer dependencies require the following PHP extensions to be installed: XML
then run the following commands:
sudo apt-get update
sudo apt install php-xml
sudo apt-get install php-mbstring
sudo reboot

Now the phpMyAdmin will be accessible at http://pma.your_domain.com/phpmyadmin/

Step 4: Install Laravel on ubuntu

By Laravel installer

Install the Laravel installer
 $ composer global require laravel/installer
Cretae a project:
 $ laravel new your_laravel_project_name

By Composer

$ composer create-project /var/www/your_domain.com/ your_laravel_project_name

Your Laravel app is ready to work on. Now you can start coding in laravel. But before that, you may need to directory permission and generate an app key. You can do so by following commands.

To grant the permissions for Laravel installation type the command:

$ chmod 755 -R /var/www/yourdomain.com/your_laravel_project_name/storage

$ chmod 755 – R /var/www/yourdomain.com/your_laravel_project_name/bootstrap/cache

To generate a new Laravel application key use:

$ php artisan key:generate

I hope this guide is helpful for you to be able to install the Laravel on ubuntu 22.04, if there is any query please ask in the comment, I would be happy if I could help you

For more detailed information, please visit the How to install Laravel on Linux server step-by-step guide

Leave a Reply

Your email address will not be published.