Skip to content

Instantly share code, notes, and snippets.

@lehtu
Forked from milon/LEMP SERVER on Ubuntu 14.04.md
Last active December 13, 2017 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lehtu/bfd4358a4d0bd092fccd344623b9f140 to your computer and use it in GitHub Desktop.
Save lehtu/bfd4358a4d0bd092fccd344623b9f140 to your computer and use it in GitHub Desktop.
Installing LEMP Server on Ubuntu 14.04

LEMP Server on Ubuntu 14.04

For detail look here

Update timezone

sudo dpkg-reconfigure tzdata

Add user and prevent root login

adduser sammy
usermod -aG sudo sammy
su sammy
mkdir ~/.ssh
chmod 700 ~/.ssh
vim ~/.ssh/authorized_keys // paste here your id_rsa.pub content
chmod 600 ~/.ssh/authorized_keys
exit

change PermitRootLogin yes to PermitRootLogin no

vim /etc/ssh/sshd_config
service ssh restart

and before logging out try to login with your new user form another shell.

Install nginx

sudo apt-get install nginx

then get IP address and try it on browser

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Install mysql

sudo apt-get install mysql-server mysql-client

then create mysql directory structure

sudo mysql_install_db

then make it more secure

sudo mysql_secure_installation

Install PHP

sudo apt-get install php5-fpm php5-mysql

then configure php processor by editing /etc/php5/fpm/php.ini file with changing the value of cgi pathinfo like this-

cgi.fix_pathinfo=0

then restart php

sudo service php5-fpm php5-cli restart

Configure nginx for using PHP

edit /etc/nginx/sites-available/default file like this-

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/ =404;
    }

    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;
    }
}

then restart nginx

sudo service nginx restart

after that test php by creating a file named /usr/share/nginx/html/index.php and edit it like this-

<?php

phpinfo();

and then show in browser.

Setup WordPress

Setupping MySQL

mysql -u root -p
mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

continue with this one: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment