Install Laravel in your Ubuntu 14.04

Below given are the server requirements to install laravel.

LAMP should be Installed
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension

To upgrade php version, follow this link.

You can find out if this PHP module is installed or not by looking at the list that is produced by this command.

$ php -m

Those are not installed, install it by applying below given command.

$ sudo apt-get install php-mbstring

You can check it though phpinfo(); function

Laravel use composer to install dependencies. So, we need to install composer first.

$ sudo apt-get update
$ sudo apt-get install curl php5-cli git
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test installation of composer, run composer.

$ composer

However, if you want to install it in your local project directory.

$ cd /var/www/html/
$ curl -sS https://getcomposer.org/installer | php

After installation of composer, follow below given steps to install laravel.

$ cd /var/www/html
$ git clone https://github.com/laravel/laravel.git
$ cd /var/www/html/laravel
$ sudo composer install

If above given command, produce error like this.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– phpunit/phpunit 4.8.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.

Perform below given steps.

$ sudo apt-get install php-xml
$ sudo apt-get install php7.0-xml

Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.

$ php artisan key:generate

Application key [cdfnvjfnvjkenfnkjnekjcnjkdnvknf] set successfully.

Edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.

'key' => env('APP_KEY', 'uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75'),

‘cipher’ => ‘AES-256-CBC’,

Don’t forget to give permissions.

$ chown -R www-data.www-data /var/www/html/laravel
$ chmod -R 755 /var/www/html/laravel
$ chmod -R 777 /var/www/html/laravel/app/storage

You are done with laravel installation, to run the website, ping your browser with below given URL.

http://localhost/laravel/public

To Create apache virtual host.

Add Virtual Host in your Apache configuration file to access Laravel framework from web browser.

vim /etc/apache2/sites-available/laravel.example.com.conf

<VirtualHost *:80>

ServerName laravel.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>

Run the command to enable laravel website and restart apache.

$ a2ensite laravel.example.com
$ sudo service apache2 reload

Now you can browse your laravel from this URL(http://laravel.example.com)

Cheers!

Leave a Reply

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