Here’s how you can install the LEMP (Linux, Nginx, MySQL, and PHP) stack on an Ubuntu Linux 14.04 LTS server:
- Update the package repository:
sudo apt-get update
- Install Nginx web server:
sudo apt-get install nginx
- Start Nginx and enable it to start at boot:
sudo service nginx start
sudo update-rc.d nginx defaults
- Install MySQL server:
sudo apt-get install mysql-server
- Start MySQL and enable it to start at boot:
sudo service mysql start
sudo update-rc.d mysql defaults
- Install PHP:
sudo apt-get install php5-fpm php5-mysql
- Configure Nginx to use PHP:
sudo nano /etc/nginx/sites-available/default
Edit the default server block to look 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 localhost;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
- Restart Nginx and PHP-FPM:
sudo service nginx restart
sudo service php5-fpm restart
After these steps, you should have a working LEMP stack on your Ubuntu Linux 14.04 LTS server.