How to install laravel on linux

Server Management Services

We’ll show you how to install Laravel on Linux. 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 community and clean and classy code. Installing Laravel on Linux is fairly easy task, just carefully follow the steps bellow and you should have Laravel installed on your Linux machine in less then 10 minutes.

1. Prerequisites

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.

2. Go to the web server’s root directory

Debian/Ubuntu

cd /var/www

CentOS/Fedora

cd /var/www/html

3. Download Laravel

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

4. Extract the archive contents

unzip laravel.zip
mv laravel-laravel-* laravelsite

5. Change ownership

Debian/Ubuntu

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

CentOS/Fedora

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

6. Create new apache or nginx virtual host

Nginx

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_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Apache

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

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.

7. Restart Your Webserver

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/

You don’t have to Install Laravel on Linux, if you use one of our Managed Laravel Hosting services, in which case you can simply ask our expert Linux admins to install and set up Laravel for you. They are available 24×7 and will take care of your request immediately.

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