How to Install Laravel with an Nginx Web Server on Ubuntu 14.04

How to Install Laravel with an Nginx Web Server on Ubuntu 14.04

1) Install the Backend Components
1.1) sudo apt-get update
1.2) sudo apt-get upgrade
1.3) sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt git
--------------------------------------------------------------------------------------------------------------------------
2) Modify the PHP Configuration
2.1) sudo nano /etc/php5/fpm/php.ini
2.2) cgi.fix_pathinfo=0 
2.3) sudo php5enmod mcrypt
2.4) sudo service php5-fpm restart
--------------------------------------------------------------------------------------------------------------------------
3) Configure Nginx and the Web Root
3.1) sudo mkdir -p /var/www/laravel
3.2) sudo nano /etc/nginx/sites-available/default
=======================================================
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
=======================================================
3.3) sudo service nginx restart
3.4) if you want to setup 2 virtual block
3.4.1) sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
3.4.2) sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
2.4.3) sudo nano /etc/nginx/nginx.conf
2.4.4) server_names_hash_bucket_size 64;
2.4.5) sudo service nginx restart
--------------------------------------------------------------------------------------------------------------------------
4) Create Swap File (Optional)
4.1) sudo fallocate -l 1G /swapfile
2) sudo mkswap /swapfile
3) sudo swapon /swapfile
--------------------------------------------------------------------------------------------------------------------------
5) Install Composer and Laravel
5.1) cd ~
5.2) curl -sS https://getcomposer.org/installer | php
5.3) sudo mv composer.phar /usr/local/bin/composer
5.4) sudo composer create-project laravel/laravel /var/www/laravel
5.5) sudo composer create-project laravel/laravel /var/www/laravel 4.2
5.6) sudo chown -R :www-data /var/www/laravel
5.7) sudo chmod -R 775 /var/www/laravel/app/storage
5.8) http://server_domain_or_IP
------------------------------------------------------------------------------------------------------------------------------
Conclusion
------------------------------------------------------------------------------------------------------------------------------






















Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s