Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern and based on Symfony.

In this guide, we will explain how to install Laravel on an Ubuntu 16.04 server with Apache, MariaDB And PHP Support.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Prerequisites: Laravel requires that the following be installed: PHP >= 7.1.3, OpenSSL PHP Extension, PDO PHP Extension, Mbstring PHP Extension, Tokenizer PHP Extension, XML PHP Extension, Ctype PHP Extension,JSON PHP Extension,BCMath PHP Extension. We'll be installing these also as we proceed.

Step 1 – Install Apache Web Server
We are going to install Apache web server from Ubuntu official repositories using the apt command line:

sudo apt-get install -y apache2

As a non-root user, you will be required to enter the sudo password for the account in use. Enter the password and continue the installation.

Check the status of the Apache Web server with the command below:

sudo systemctl status apache2

Step 2: Install the MySQL Database (MariaDB)
You can read the guide on installing MariaDB on an Ubuntu 16.04 server here.

Step 3: Install PHP
You can read the guide on installing PHP on an Ubuntu 16.04 server here.

Step 4: Install Composer
After our installation of Apache and PHP, issue the commands below to install the composer package.

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

Navigate into the Laravel directory and issue the commands below to download and install Laravel for the project you want to create. For this guide, we are going to create a project titled CloudwaferProject

cd /var/www/html
sudo composer create-project laravel/laravel CloudwaferProject --prefer-dist

After running the commands above, a new project directory will be created. Run the commands below to set the correct permissions for that directory.

sudo chown -R www-data:www-data /var/www/html/CloudwaferProject/

Step 5: Configure Apache Next, we will configure the Apache web server for our Laravel project. The file to be created will control how users access Laravel content. Issue the command below:

sudo nano /etc/apache2/sites-available/laravel.conf

Type the commands below to edit the laravel.conf file replacing CloudwaferProject with the name of your project and with the name of your domain:

<VirtualHost *:80>

    Options +FollowSymlinks
    AllowOverride All
    Require all granted

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

Next, change the permission using the command below:

sudo chmod -R 755 /var/www/html/CloudwaferProject/

Step 6: Enable the Laravel and Rewrite Module
Next, enable the Laravel VirtualHost file by running the commands below:

sudo a2ensite laravel.conf
sudo a2enmod rewrite

Next, restart Apache with the command below:

sudo systemctl restart apache2

You can now visit your server domain name or IP on the browser.