How to install Laravel on Linux

This tutorial will show you how to install Laravel on your Linux VPS. Laravel is an open source web application framework written in PHP which follows the model-view-controller (MVC) paradigm. Laravel is a young framework, but it quickly gained popularity thanks to the extensive documentation, friendly comunity and clean and classy code.

This tutorial assumes that you have :
-Web server (apache or nginx)
-PHP 5.3 or newer
* Please refer to the following articles about how to set up a LAMP or LNMP server.

Go to the web server’s root directory


cd /var/www


cd /var/www/html

Download Laravel

wget -O laravel.zip http://laravel.com/download

Extract the archive contents and rename the extracted directory to “laravelsite” or whatever you like.

unzip laravel.zip
mv laravel-laravel-* laravelsite

Change ownership


chown -R www-data: /var/www/laravelsite


chown -R apache: /var/www/html/laravelsite

Create new apache or nginx virtual host


server {
  server_name laravelsite.dev;
  listen 80;
  root /var/www/laravelsite/public;
  # Uncomment the following line for Centos/Fedora
  # root /var/www/html/laravelsite/public
  index index.php;
  location / {
    try_files $uri $uri/ @rewrites;
  location @rewrites {
    rewrite ^ /index.php last;
  location ~ \.php {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


<VirtualHost *:80>
    DocumentRoot /var/www/laravelsite/public
    # Uncomment the following line for Centos/Fedora
    # DocumentRoot /var/www/html/laravelsite/public
    ServerName laravelsite.dev

If you want to use “Cleaner URLs”, add the following code in the .htaccess file.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

As you noticed the DocumentRoot points to the ‘public’ directory.

Finaly, restart your web server and open your newly created Laravel installation in a web browser. For further documentation please visit http://laravel.com/docs/

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.



Categories: Tutorials

View Comments

Leave a Comment