Laravel is best installed with the help of dependency manager composer. So jump into getComposer.org if you haven’e installed composer and install composer in your system.
After composer has been properly installed we now set up the laravel framework with composer (optional). Open up a terminal and run
$ composer global require "laravel/installer=~1.1"
this will install laravel executables in your computer thus you can then execute laravel commands too.
So lets create a laravel project with composer. Go to the folder where you want your project to be created and open up a terminal.
For windows users that may be where ever your htdocs is or your www folder is and for linux users that probably would be /var/www/html or its equivalent.
Then in the terminal execute
$ composer create-project laravel/laravel project-name --prefer-dist
or if you want a specific version, in this case, latest version of 5.2 i.e. 5.2.*
$ composer create-project laravel/laravel project-name "5.2.*" --prefer-dist
This will create a project with name “project-name” in your current directory that you are in. This may take a while so you can brew yor self a coffee while composer does the heavy work for you.
When composer has finished. cd project-name/ and you can see that a skeleton laravel framework has been installed in your computer. Go ahead and run the project in your browser. It should run fine.
In Ubuntu 16.04 or in any machine running php7.0 there may be some issues where laravel won’t run. This is because php7.0 doesn’t have some packages installed or either the packages are not configured with correct versions that laravel requires by default. The packages are
php7.0-xml or php7.0-dev
These packages may be installed but due to mis-configured versions of the packages the framework wont work. So its best to upgrade or re-install these packages manually.
To install these packages, for linux users
$ sudo apt-get install package-name
If you get “held broken package” error check out this post to solve the issue.
Also you may come upon a situation where you must put index.php after public/ to run the laravel urls.
i.e. localhost/project_name/public/index.php/your/url/path instead of localhost/project_name/public/your/url/path.
This may be due to your apache not configured to read the .htaccess file or your virtual host not configured to do the same.
To counter this issue you may just configure your apache/virtual host to enable the url rewrite module.
$ sudo a2enmod rewrite
In Ubuntu 16.04 new apache version has change in some way. If your apache version is 2.4 then you have to go to
/etc/apache2/. There will be a file named
apache2.conf. You have to edit that one(you should have root permission). Change directory text like this
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>