Seegatesite.com – Laravel is different from other PHP framework, where you can download the master file fully and placed on your web server. Laravel has a dependence on some PHP library, where the library isn’t included in the laravel’s source. So we need to download the library separately.
Is laravel installation complicated ??
In my opinion, extremely complicated. This might be the first PHP framework I am trying to learn. Probably for those professionals who familiar with composer, lavarel installation becomes very easy. One of the interesting things of the laravel framework is about Composer. The whole requirement done by the composer, so any dependency with other libraries can be resolved by the composer. In other words, we don’t need to download one by one libraries needed by laravel. The principle is similar to apt-get in linux or NPM in nodejs. Because Composer is cool stuff, then there is no harm in us to install it first.
This article discusses how to install laravel on the ubuntu operating system, for Windows’s users, there could be some similarities, because using the composer.
Table of Contents
How to install laravel 5 on ubuntu for beginners
In laravel official site has been described in detail how to install laravel 5 step by step. But still some starters like me failed to do the installation. Here are the steps :
Laravel need requirement as follows
- PHP >= 5.5.9
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
Make sure you have fulfilled the above request
Install the composer on ubuntu / linux
How to install the composer on linux easy enough. According getcomposer.com run the following script on the terminal ubuntu
1 2 3 4 5 6 7 | php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '41e71d86b40f28e771d4bb662b997f79625196afcca95a5abf44391188c695c6c1456e16154c75a211d238cc3bc5cb47') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" |
We will get composer.phar file in the directory where we run the script above
Please check with the command “php composer.phar” on terminal, if it looks like the image below, you have successfully perform the installation composer on ubuntu
So that we can use composer in any folder , please move the composer.phar to /usr/local/bin/composer
mv composer.phar /usr/local/bin/composer
For windows’s users please use the following links https://getcomposer.org/doc/00-intro.md#installation-windows
Installation laravel 5
Please go to the web server folder ( cd /var/www/html/ ). Then run the following script to download laravel by composer
composer create-project laravel/laravel {directory} "~5.0.0" --prefer-dist
or
composer create-project laravel/laravel laravelApp "~5.0.0" --prefer-dist
Wait composer download files until completion. Then type ls on ubuntu terminal, you will find laravelApp folder that contains the complete file.
Then go to the laravelApp folder and run the command “composer update” to perform the update dependencies on laravel. But when doing the composer update, I had an error like below
- laravel/framework v5.0.9 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
Don’t worry, you only need to install the ext-mcrypt on your php server. Here are the steps to install ext-mcrypt on php ubuntu :
sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart
If you’re windows user, i found link that can help you to resolve ext-mcrypt problems http://www.kvcodes.com/2014/07/laravel-requires-mcrypt-php-extension/
Do the composer update again
composer update
Installation laravel 5 has finished, please check on your browser http://localhost/laravelApp/public/
Check what happened? you will only be given a white screen on your browser. In order to run normally, we have to change the file permissions on the storage’s folder with code below
chmod -R o+w storage/
Check again on your browser and voila, You have successfully installed laravel 5 on your machine
Until this point we have managed to install laravel 5. Here are some of errors that occur when you install laravel 5, may be able to help solve your problem.
1. No folders vendor on laravel application
1 2 3 4 5 6 7 8 9 10 11 | PHP Warning: require(/var/www/html/laravelApp/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/laravelApp/bootstrap/autoload.php on line 17 PHP Fatal error: require(): Failed opening required '/var/www/html/laravelApp/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/laravelApp/bootstrap/autoload.php on line 17 Script php artisan clear-compiled handling the pre-update-cmd event returned with an error [RuntimeException] Error Output: PHP Warning: require(/var/www/html/laravelApp/bootstrap/../v endor/autoload.php): failed to open stream: No such file or directory in /v ar/www/html/laravelApp/bootstrap/autoload.php on line 17 PHP Fatal error: require(): Failed opening required '/var/www/html/laravel App/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/ share/pear') in /var/www/html/laravelApp/bootstrap/autoload.php on line 17 |
Solutions :
Please check the vendor’s folder in the ~/.composer/ and then copy the vendor’s folder to your application folder
If no vendor’s folder in ~/.composer please run the following code at the terminal
composer global require "laravel/installer"
2. Error call to undefined method illuminate\Foundation\application::getCachedCompilePath().
Solution :
Delete the vendor/compiled.php and run composer update again. Or also delete the storage/framework/compiled.php.
Hopefully the above tutorial can help you.
Holy cow dude, I want to kiss you! Thanks for this awesome guide!
Something that I (A complete apache buffoon) ran into was this:
The folder name in the /var/www/your_folder_name had to be /var/www/html to work. (Yeah, I know, I should configure apache) .
Again, Many thanks!