Install LEMP stack on Ubuntu 14.04
Steps to install LEMP stack.
Ubuntu 14.04 LTS is out and it’s now time to get our webserver running on it.
Nginx
(Pronounced EngineX)
With 14.04 Trusty Tahr, nginx has now finally been included in the official Ubuntu repositories. Installing it is a breeze.
Nginx configuration lies at /etc/nginx/nginx.conf
which you’ll be needing later.
If you want to host your domain, then we need to setup a virtual hosts file. Note that this can be repeated if you want to host multiple sites.
Use nano or your any of your favourite editor and edit the virtual host file to reflect the following. Of course you should modify root to the location of your website. Also, server_name should be the same as the domain with which you will be accessing the website.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
listen 80;
server_name mydomain.com www.mydomain.com;
root /home/user/mydomain.com/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Now we enable the domain by using a symlink of the file from sites-available to sites-enabled,
Restart nginx for the changes to take effect.
Note that I’ve configured my root directory as /home/user/mydomain.com/public/
. I find this easier to navigate.
Next, we set permissions on the root directory
Also if you would like to be able to write to the root directory of your webserver without getting permissions issue - we’ll add your user account to the group www-data.
PHP
Next we have to edit /etc/php5/fpm/php.ini
and uncomment the following
MariaDB
This is simple as this
You will be prompted to enter a password for MariaDB root user. Remember it.
To start, stop mariadb
You’re good to go!