Saturday, July 11, 2015

Install Laravel 5 Framework on Ubuntu OS

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

Website : laravel.com

1) Install LAMP server
  • sudo apt-get install python-software-properties
  • sudo add-apt-repository ppa:ondrej/php5-oldstable
  • sudo apt-get update
  • sudo apt-get install -y php5 php5-mcrypt
2) Install Apache
  • sudo apt-get install apache2 libapache2-mod-php5
3) Install MySQL
  • sudo apt-get install mysql-server php5-mysql
4) Install Composer
  • curl -sS https://getcomposer.org/installer | php
  • sudo mv composer.phar /usr/local/bin/composer
  • sudo chmod +x /usr/local/bin/composer
5) Install Laravel
  • cd /var/www/html/
  • git clone https://github.com/laravel/laravel.git
  • cd /var/www/html/laravel/
  • sudo composer install
  • sudo chown -R www-data.www-data /var/www/html/laravel
  • sudo chmod -R 755 /var/www/html/laravel
  • sudo chmod -R 777 /var/www/html/laravel/storage
6) New Apache VirtualHost
  • sudo vim /etc/apache2/sites-available/laravel.example.com.conf
    • Add Below code and save file.
<VirtualHost *:80>
        
        ServerName laravel.example.com
        DocumentRoot /var/www/html/laravel/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/html/laravel>
                AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

7) Start Website
  • a2ensite laravel.example.com
  • sudo service apache2 reload
8) Visit URL
If URL is not working then follow below steps:

A) Add new site entry in hosts file.
  • sudo vim /etc/hosts
  • Add "127.0.0.1 laravel.example.com"
B) Generate APP_KEY
  • php artisan key:generate
  • Vim "/var/www/html/laravel/config/app.php"
  • If app key is not updated in above file then enter key manually in below code.
  • 'key' => env('APP_KEY', '<ENTER_YOUR_NEW_APP_KEY>'),

If you get any issue in above then put it in comment.

Total Pageviews