How to Install Nginx on Ubuntu 12.04 LTS

Introduction

 

Nginx is a free and open-source, high performance web server software popular for its stability, simplicity in configuration and low resource consumption. Being a popular web server, many high traffic sites have been hosted using it. When compared to Apache, its considered to be more resource friendly.

This tutorial will guide you to install Nginx on Ubuntu 12.04 server. You will need to have configured a regular user other than root, who also has sudo privileges on your server. Check out this tutorial on server set up, to configure a user on Ubuntu 12.04.

Installation of Nginx

 

Installation of Nginx is pretty much easy, as the Ubuntu itself has an nginx package in its default repositories.

Before installing nginx, you need to update the local package index using apt command so that we have the most up-to-date information.

sudo apt-get update
sudo apt-get install nginx

While the installation progresses, you may have to enter user’s password to complete the process. Nginx will be downloaded and automatically installed on to your server.

Nginx does not start on its own. So you need to start it using the command:

sudo service nginx start

 

Verifying the Nginx

 

After the installation, you can check the nginx landing page to verify if the software is running appropriately. For that, you need to visit your server’s domain name or IP address in your browser. For finding your server’s public IP address, you can run this command from your command prompt:

ifconfig eth0 | grep inet | awk '{ print $2 }'

You just have to enter the server IP address into your web browser’s address bar:

http://server_IP_address

You should be taken to the default nginx landing page which will look similar to this:

nginx-install

 

The display of this default page will ensure that the server is installed properly.

 

Managing Nginx Processes

 

Now that you have nginx installed and running on your server, let’s discuss some of the useful management commands.

To start nginx at the time of system reboot, you can add it to the startup using following command:

update-rc.d nginx defaults

The system may show a message like this:

System start/stop links for /etc/init.d/nginx already exist.

It may have already been enabled and it is just to let you know that the configuration is correct and no further action is required.

sudo service nginx stop

It will stop your web server.

sudo service nginx start

It will start the web server if it is stopped.

sudo service nginx restart

It will restart the web server. It will stop first and then start the service again.

sudo update-rc.d nginx defaults

 

 

 

support2 has written 111 articles

Leave a Reply