How to install Laravel on Linux

How to install laravel on linux

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.

3 thoughts on “How to install Laravel on Linux”

    • The installation is simple, login to your server via SSH and:

      1. Install composer as root
      root@vps~# curl -sS https://getcomposer.org/installer | php
      root@vps~# mv composer.phar /usr/local/bin/composer

      2. Install Laravel 4.2 as user
      user@vps~# cd /home/user/
      user@vps~# composer create-project laravel/laravel –prefer-dist
      user@vps~# rm -rf public_html
      user@vps~# ln -s laravel/public/ public_html

      Please note Laravel requires: PHP >= 5.4 and MCrypt PHP Extension

      Reply

Leave a Comment