We will look into an easy and brief installation process to install laravel on ubuntu with apache.

Complete installation process with ubuntu:

Laravel is one of the most powerful frameworks for PHP which has expressive code syntax backed with great documentation. Laravel is fast, efficient, user-friendly, and easy to use.

Below are the easiest steps to install laravel:
1. Install Apache
2. Install PHP
3. Download and Install a database manager
4. Install Composer
5. Install Laravel using Composer

I will walk you through with each steps to install Laravel on Ubuntu:

1. Install Apache

Apache helps laravel to run. It is one the most popular server tool. It provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards. To install apache run the below command.

sudo systemctl status apache2

Ubuntu starts the Apache service and makes it boot during system loading.

If you are using a firewall, then you need to set rules so that apache can run successfully. If you don't run any firewall then feel free to skip this step.

sudo ufw allow “Apache Full”

After that, check if the Apache service is running by using below command.

sudo systemctl status apache2

Finally open the address in your web browser. If you are running your service in local device, try with http://localhost or if with server then put your IP address (eg. assigned or you can simply put your domain address (like If you can see the below image, then your apache service is up and running.


2. Install PHP

Next step is to install PHP. Laravel also requires some extra modules of PHP to work smoothly. To install PHP with other node modules, exceute the below command.

sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip php-bcmath php-tokenizer php-json php-pear

If the above command gives output of package not found then you need to udpate your ubuntu by running the below command and then rerun the above command.

apt-get update

Now, we can test if PHP and its modules are working correctly. To do this, we need to create a file in Apache's root directory. Let the name of the file test.php. Now execute the below command.

sudo nano /var/www/html/test.php

Now add the below code to file created.


We have to save it and close it. To save, hit CTRL+O, and to exit, hit CTRL+X Then, open the web browser and go to If you see this screen, you can be sure that PHP is working as it should.


3. Download and install a database manager

A database manager is required to install for the development with Laravel. Laravel supports MySQL, MariaDB, SQLite, PostgreSQL and SQL Server. You can configure whichever you want. For this tutorial, we will install MariaDB.

sudo apt install mariadb-server

After successful installation, we need to set a password for the root. We need to use the mysql_secure_installation script. This step is optional but I recommend you to follow this step for security reasons.

sudo mysql_secure_installation

After we define the root password, we will be asked several MariaDB configuration questions. The answers you should input are next to the lines of code:

Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y


Now MariaDB has been installed successfully.

4. Install Composer

Composer is a dependency manager which helps to download the PHP libraries in our project. For downloading composer, execute the below command.

curl -sS | php

Composer should be used globally and should be also made executable. Execute the below the command inorder to make it executable.

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

5. Install Laravel using Composer

Now you can install Laravel after installing Composer. To do this, execute the below command.

composer create-project --prefer-dist laravel/laravel [name_of_your_project]

Please keep in mind that you need to replace the [name_of_your_project] with yours. Hope you would have successfully installed laravel on your development or production environment. Thank you for your patience!


If you are running Laravel for Local Development and want to specify host and server then click here. and if you are using laravel to deploy an application, click here.

Topics: How To Tags: ubuntu ,   apache ,   installation ,   laravel

Popular Posts


How to install Laravel in Ubuntu


How to install apache in ubuntu


Newsletter Subscribe

Subscribe our newsletter to get daily updates!