This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
nginx is a high performance web server software. It is a much more flexible and lightweight program than apache.
The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.
To install nginx, open terminal and type in:
sudo apt-get install nginx
When prompted, say yes. nginx is now installed on your virtual private server.
nginx does not start on its own. To get nginx running on your VPS, type:
sudo service nginx start
You can confirm that nginx has been installed as your web server by directing your browser to your IP address.
**You can run the following command to reveal your virtual server’s IP address.
ifconfig eth0 | grep inet | awk '{ print $2 }'
When you visit your IP address page in your browser, you will see the words, “Welcome to nginx”
You can see a screenshot of the utilitarian nginx welcome page here
To ensure that nginx will be up after reboots, it’s best to add it to the startup. Type this command into terminal:
update-rc.d nginx defaults
You may see a message like:
System start/stop links for /etc/init.d/nginx already exist.
If that is the case, then nginx is set up to run on startup, and you are all set.
Congratulations! You have now installed nginx
Once you have installed nginx on your virtual private server, you can do a variety of things on your server such as Set Up Virtual Hosts or Create an SSL certificate for your site
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
For the last step in setting up nginx to startup after reboots, you may need to install chkconfig first. sudo apt-get install chkconfig
Then proceed with the last two commands: sudo chkconfig --add nginx sudo chkconfig nginx on
Than you for the the suggestion.
The tutorial has been updated to reference just update-rc.d which is an ubuntu command that does not need any additional installation.
There is an another alternative, in my opinion better than remembering the path, of ‘sudo /etc/init.d/nginx start’
‘sudo service nginx start’ -will do the same thing.
Absolutely right, Etel updated the article =]
With 12.10, I am getting the following errors when I try to start nginx:
Starting nginx nginx nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] still could not bind()
It’s not loading
@info - perhaps apache2 is installed? if debian / ubuntu enter: service apache2 status and if it comes back Apache2 is running (pid …) Then you likely have apache configured to run off of port 80.
Another possible solution is found in /etc/nginx/sites-available/default. Do the following and see if it clears it up (I’m running of memory, don’t know if you NEED sudo or not):
sudo vim /etc/nginx/sites-available/default
Look for the following lines: listen 80; listen [::]:80 default_server;
Change them so they read (hit i to enter insert mode): listen 80; listen [::]:80 ipv6only default_server;
Sorry should say ipv6only=on
I was also getting the same error. nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) and when i typed the localhost in the browser, then i was getting
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet. instead of nginx welcome page
that is apcache2 is running on the same port, so the solution is given below
1- find the apache2 ports.conf file
sudo /etc/apache2/ports.conf
2- change the port other then 80 , i make it as 70
3- save the file
4- restart your system
it will works for you also, if you type the localhost in the browser , you will get nginx welcome page
– Thanks
Saurabh
<3