Quick Laravel 5 installation guide

There are many guideline for setting up Laravel in your localhost and majority of them are quite good. However, I have realized the are not very complete and some are very confusing. Hence, I have decided to write a simple and short guideline on how to setup Laravel 5 quickly in your Ubuntu box.

The first thing you need to do is running the following commands to install LAMP.

$ sudo apt-get install apache2
$ sudo apt-get install mysql-server
$ sudo apt-get install php5 libapache2-mod-php5
$ sudo apt-get install phpmyadmin
$ sudo /etc/init.d/apache2 restart

Then the next step is installing and setting configuration of some Laravel dependencies

$ sudo apt-get install php5-curl
$ sudo apt-get install php5-mcrypt
$ sudo php5enmod mcrypt  # Enable extension
$ sudo service apache2 reload # Restart Apache
$ curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer

Now run the these commands to install Laravel 5.

$ cd /var/www/
$ composer create-project laravel/laravel your-project --prefer-dist

Or if you have existing project you can skip the above step and instead using your own project.

Now last step is configuring virtual server to point to your Laravel project which is assumed it is located under /var/www/laravel

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

After you open example.com.conf with the editor, you should add the following content to it or change the content accordingly.

<VirtualHost *:80>    
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/laravel/public
    <Directory />
            Options FollowSymLinks
            AllowOverride None
            AllowOverride All
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Need to apply the changes and restart Apache server

$ sudo a2ensite example.com.conf
$ sudo service apache2 restart

The last step is to add a virtual server for pointing example.com domain to /var/www/laravel

$ sudo nano /etc/hosts

Then add the following line to the file and save it example.com

Following are some useful materials that I have used to write this article.




Send your idea and information to kasra@madadipouya.com

Leave a Reply