Technology Blog

Complete Install Nginx Stack Under 15 Minutes On Ubuntu

0

This will show you how to install Nginx, PHP5 (fpm) with Zend OPCache, MySQL, PHPMyadmin, Postfix (and WordPress) on Ubuntu under 15 minutes. This is possible using EasyEngine tool from RTCamp.

What is Easy Engine? It is a nice little software (linux-shell script) to build a working web server to host your websites on an Ubuntu VPS (or Dedi server). The script will install complete LEMP / LNMP stack (Linux, Nginx, MySQL and PHP) along with all necessary softwares (like Postfix and PHPMyAdmin) so your VPS can act as a webhosting server.

Nginx is a better free alternative to Apache because its lightweight and RAM-friendly. It can perform better and faster than Apache, particularly when the number of concurrent site visitors is on the rise. The only downside of Nginx is that not many users familiar with Nginx because it has different DNA and anatomy compared to Apache. For instance, Nginx doesn’t support Apache’s .htaccess so users need to convert their htaccess content to nginx configuration.

So here comes EasyEngine (ee), a great script to uncomplicate what users think is complicated from Nginx. Shortly, ee is built to simplify the process of installing, configuring and managing Nginx (or full LNMP stack exactly) to host websites on Ubuntu server.

However, you can also read my previous tutorials about building Nginx server on Ubuntu if you wish to learn it from the very beginning.

Requirements

You’ll need:

  1. A VPS / Dedicated server with at least 256MB of RAM
  2. Fresh install of Ubuntu (12.04, 12.10, 13.10, 14.04) or Debian 6/7
  3. A dose of EasyEngine
  4. Basic knowledge of SSH command
  5. Basic knowledge to use Putty (Windows) or Terminal (Linux/Mac)
  6. A cup of coffee.

In this example I use Ubuntu 14.04 VPS with 512MB of RAM from XVMLabs. Need recommended VPS? Try checking out my list of recommended VPS or this 15+ top low end cloud vps providers.

Preparation

Step 1 – Login to your server as root. Use the details (IP address, ssh port and root password) given by your provider.

1-login-ubuntu-vps

Step 2 – Check if Apache is already installed and running. If so, stop it (or remove it):

service apache2 stop
 apt-get remove apache2

pic:

2-stop-apache

In this example I removed postfix as well:

2-stop-postfix

Step 3 – Before proceeding, and if you are hesitating about your Ubuntu / Debian version, you can check it using this command syntax:

cat /etc/*-release

output example:

3-check-ubuntu-version

How to Install EasyEngine

Step 1 – Issue this main command to install EasyEngine on your VPS:

curl -sL rt.cx/ee | sudo bash

It should be finished in seconds:

1-install-easyengine

common problems:

curl command not found – Issue this command to fix:

apt-get install curl libcurl3 libcurl3-dev

unable to install bc –  Issue this command to fix:

apt-get install bc

install-bc

unable to install Git – Install git using this command:

install-git

Basic EasyEngine Configuration

So now you have EasyEngine installed, what next to do -before everything else- is to edit default ee‘s configuration. Use your favorite editor (mine is Nano):

nano /etc/easyengine/ee.conf

then edit necessary entries:

apt-get-assume-yes = false

Set to “true” if you want to avoid answering confirmation each time new software will be installed.

gpg-keys-fix= false

Set to “true” to fix GPG Key issue so easyengine can try another mirror and fetch the key

htpasswduser & htpasswdpass

leave it blnk if you don’t need it. This part is only needed if you want to password-protect the protected access control area (an area where you can manage easyengine). By default both username and password is easyengine.

ip_address

You can simply leave it blank if you work / frequently access your server from remote location. You can add your own IP address there to add more security layer by blocking access from IPs other than yours.

mysqlhost

Default is localhost but if you changed MYSQL to bind on your VPS IP (other than 127.0.0.1) than you can change it here. Otherwise leave it blank.

customdbname

easyengine create database automatically for wordpress as well as php/mysql sites where database-name is based on domain name provided. If you like to specify database name manually, set this value to true.

customdbuser

easyengine create a new mysql user automatically for wordpress as well as php/mysql sites where mysql username is based on domain name provided. If you like to specify mysql username manually, set this value to true.

wpdbprefix

If you want to change WordPress table prefix to something else than wp_, you can provide that string here.

wpadminuser

Default value is admin (if you leave it blank), you can change it to any name.

wpadminemail

EasyEngine prompts for email address at the time of installation. If you haven’t specified it correctly, you can change it to any valid email address. By default easyegine uses git config user.email as email address for default WordPress username (see wpadminuser above).

For more detailed information can be found here.

Example:

ee-config-1

ee-config-2

How to Install Nginx, PHP, MySQL, Postfix, phpMyAdmin

It’s time to install the main softwares: Nginx (web server), PHP, MySQL (database server), Postfix (mail server), and phpMyAdmin (database manager) and luckily with ee you can do that in one go using one simple line of command:

ee system install

pic:

install-nginx-ee-command2

Sit tight and wait for ee to install the whole LEMP/LNMP stack

2014-06-10_150318

In the middle of installation, EasyEngine will ask for HTTP authentication username and password. It is recommended that you specify this to something other than defaults, especially on production server:

install-nginx-ee-auth

Once done, you’ll see something like this:

easyengine-install-done

That’s it. Now you’ve installed complete Nginx stack (including latest version of PHP5 -fpm with ZendOPCache):

latest-php-zendopcache

You can check status of all running stack packages using following command:

ee system status

Sample output:

easyengine-status

What’s next? Creating your first website or setup a working WordPress site using this command:

ee site create example.com --wp