Now that our lab is configured.. it’s time to begin writing tutorials. Our first tutorial today is about installing the latest version of Nginx webserver on Ubuntu, CentOS and openSUSE Linux distributions.
We use Nginx web server on this site to power our WordPress blog. It’s a lightweight, fast and secure web server.
There are other great web servers in the opensource community that you may want to try, like Apache2, Lighttpd and others.
This brief tutorial is going to show you how to install and configure Nginx on these three distributions.
Users can then choose which distribution works great for their environments. After this tutorial, you’ll be able to install Nginx on Ubuntu, CentOS and openSUSE.
- Installing Nginx web server on Ubuntu
Your first challenge is to install Nginx on Ubuntu server. To do that, all you have to do is run the commands below.
sudo apt-get install nginx
The commands above will install a stable version of Nginx. However, if you wish to install the latest version of Nginx, you’ll have to add additional repositories.
To do that, run the commands below to download Nginx’s mainline repository key on your Ubuntu server.
cd /tmp/ && wget http://nginx.org/keys/nginx_signing.key
Nginx run the commands below to install the repository key
sudo apt-key add nginx_signing.key
After installing Nginx repository key, run the commands below to create a repository file for Nginx.
sudo vi /etc/apt/sources.list.d/nginx.list
Then add these lines in the file and save it.
deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx
Replace ‘codename’ with the codename of Ubuntu.. ex (Wily for Ubuntu 15.10)
Save the file and run the commands below to install the latest version of Nginx.
sudo apt-get update && sudo apt-get install nginx
That’s how you install Nginx on Ubuntu.
- Installing Nginx web server on CentOS
This is how you install Nginx web server on CentOS by running the commands below.
sudo yum install nginx
Running the above commands will install a stable version of Nginx web server. However, if you want to install the latest version of Nginx, you’ll have to add additional repositories.
Below is how you install the latest version of Nginx web server on CentOS. First run the commands below to create a Nginx repository file.
sudo vi /etc/yum.repos.d/nginx.repo
Then add the lines below in it and save it.
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Finally, run the commands below to install the latest version of Nginx.
sudo yum update && sudo yum install nginx
That’s how you install Nginx on CentOS
- Installing Nginx web server on openSUSE
Finaly, here’s how to install Nginx webserver on openSUSE by using the commands below.
sudo zypper install nginx
The commands above will install a stable version of Nginx… However, if you wish to install the latest version of Nginx, you’ll have to add additional repositories.
To do that, go to this site.. there you’ll find the latest version of Nginx
http://software.opensuse.org/package/nginx
Select your version of openSUSE, then expand the link to show ‘unstable packages‘
From there you can click the 1 Click Install link to add new repository and install Nginx.
One of the repositories that contains the latest version of Nginx is Micro Chip 8.
To install it, run the commands below.
sudo zypper ar http://download.opensuse.org/repositories/home:/microchip8/openSUSE_Factory/ "Micro Chip 8"
After that, update your source repositories by running the commands below.
sudo zypper update
When prompted whether to add or reject Micro Chip 8 repository key, choose to trust by typing t
After that run the commands below to install nginx
sudo zypper install nginx
That’s how to install Nginx web server on openSUSE.
Enjoy!