Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created by Taylor Otwell. In this guide, we will install Laravel 5.6 on Ubuntu 16.04 and as you might already know Laravel 5.6 depends on PHP 7.1+ so we are going to install the latest stable version of PHP which is 7.1 and finally serve the whole thing with Apache web server.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.

Install Apache

First of all, you need to issue the following command to update your repository list:

apt-get update

Then you can install Apache 2 easily using “apt” with the following command:

apt-get install apache2

After the installation process is finished you can use the commands below to start your Apache service and make it run at startup:

systemctl start apache2 systemctl enable apache2

Install PHP 7.1

PHP 7.1 is not provided by the official repository so you have to add “PPA” repo in order to install it easily.

First, install Python Software Package with the following command:

apt-get install python-software-properties

Now you can add the preferred repository:

add-apt-repository ppa:ondrej/php

Update your repository list to fetch the latest packages with the command below:

apt-get update

execute the command below to easily install PHP 7.1 and the needed extensions:

apt install php7.1 php7.1-xml php7.1-mbstring php7.1-mysql php7.1-json php7.1-curl php7.1-cli php7.1-common php7.1-mcrypt php7.1-gd libapache2-mod-php7.1 php7.1-zip

Download Composer

For installing the latest version of Laravel we need to get the Composer dependency manager:

curl -sS https://getcomposer.org/installer | php

Execute the following command to move your Composer binary file to the executable path:

mv composer.phar /usr/bin/composer

Now you can run the command below to download and install Laravel directly into your Apache document root:

composer create-project laravel/laravel /var/www/html/laravel

Set the correct DocumentRoot

Open the Apache configuration file:

nano /etc/apache2/sites-available/000-default.conf

Find the line that refers to:

DocumentRoot "/var/www/html"

and change it like below:

DocumentRoot "/var/www/html/laravel/public"

Then save and exit.

Restart Apache to take effect:

systemctl restart apache2

Set the Permissions

Execute the following command one by one to set the proper permissions:

chown -R www-data:www-data /var/www/html/laravel chmod -R 755 /var/www/html/laravel/storage

Test if everything works fine

Now you can open your browser and see your public IP address or your Domain through it.

You should see a page like below:

And you can verify that you installed Laravel 5.6 with the following command:

cd /var/www/html/laravel php artisan -V

You probably see something like below:

Laravel Framework 5.6.3


Continue Reading...

Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created...

Read Post

Laravel is a powerful MVC-PHP framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel was created...

Read Post