Install Nginx, MySQL, PHP (LEMP)

Nginx !! it is fast…
I need a fast server to host Magento and wordpress

OS: Ubuntu 14.04
Installing nginx is easy as apache

install nginx from here https://nginx.org/en/linux_packages.html#mainline

sudo apt-get update
sudo apt-get install nginx

MySQL

sudo apt-get install mysql-server
sudo mysql_install_db
sudo mysql_secure_installation

PHP

sudo apt-get install php5-fpm php5-mysql
sudo nano /etc/php5/fpm/php.ini

Find line, and set
cgi.fix_pathinfo=0

sudo service php5-fpm restart

Configure Nginx for Sites

sudo nano /etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name server_domain_name_or_IP;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =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;
    }
}
sudo service nginx restart

Kill all process that belongs to a particular user
# kill -9 `lsof -t -u ashraful`


Posted

in

by

Tags: