Install Laravel on Ubuntu, Lubuntu, & Elementary OS |

Congrats, You are Subscribed to Receive Updates.

Install Laravel on Ubuntu, Lubuntu, & Elementary OS

Install Laravel on Ubuntu,  Lubuntu,  Kubuntu and Elementary OS (Luna,  Freya, Loki). Installing Laravel 5 needs php 5. 6.  If your php is more than 5. 6 no problem.  Otherwise you have to upgrade your php with help of this tutorial. And you need Composer to install it. If you already installed composer than no problem. And If you want to install Composer click here to read about it.

Now with the help of Composer we can install laravel.  You need active internet connection as well. To install Laravel, move to the public html directory on your system. Since we are on Ubuntu and using Apache, we would install it in /var/www/html directory.

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

The above command will create a your-project directory with laravel installation in it. Composer uses git to download and install all the packages and modules that Laravel requires for functioning.
Configuring Apache

Now that we have installed Laravel, we move on to the step of configuring Apache webserver. Next step is to give proper permissions to the project directory. For this we need to enable access to it from the www-data group and to give it writing permissions to the storage directory.

sudo chgrp -R www-data /var/www/html/project
 sudo chmod -R 775 /var/www/html/project/storage

Now go to the /etc/apache2/sites-available directory and use the following command to create a configuration file for our laravel install.

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

Now add the following content to the file and close it after saving.

<VirtualHost *:80>
    ServerName localhost

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/project/public

    <Directory /var/www/html/project>
        AllowOverride All

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

Now we have to enable this newly created .conf file and disable the default .conf file that is installed with the default Apache install. Also we need to enable mod_rewrite so that permalinks can function properly.

 sudo a2dissite 000-default.conf
 sudo a2ensite laravel.conf
 sudo a2enmod rewrite
 sudo service apache2 restart

After restarting Apache, It will work fine. If you  like my tutorials, follow me on social medias below.


About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *


Current ye@r *