How to Install Nginx on Ubuntu

Nginx is a free, open source, high-performance web server. If you need HTTP and HTTPS but don’t want to run Apache, then Nginx is good choice at least for Linux.

Install nginx

First make sure the list of available packages is up to date:

apt-get -y update

Run the following command to install it:

apt-get -y install nginx

Once the installation is done the nginx service should automatically start and start listening on port 80.

Find your server’s IP address run the following command:

ip addr show eth0 | grep inet

Your result may look similar to:

inet brd yyy.yyy.yyy.yyy scope global eth0

Where is the IP address of your server.

Verify that nginx is running by visiting http://yourserverip For example:

Manage the nginx Service

Here are the some example commands for Nginx:

Start the nginx Service:

service nginx start

Stop the nginx Service:

service nginx stop

Restart the nginx Service:

service nginx restart

Check the Status of the nginx Service:

service nginx status

Assure that nginx starts at boot:

update-rc.d nginx defaults