Today Nginx version 1.9.1 was released and this brief tutorial is going to show you how to install or upgrade to it in Ubuntu/CentOS 7. Nginx is a great web server and is being used by millions of webmasters across the Internet to manage and power their websites or blogs.
We do use Nginx on this site as well. We started off with Apache2, but quickly switch to Nginx after experiencing some unexplained issues with Apache2.. We uninstalled Apache2, installed and configured Nginx, and our site has been stabled since.
Most will argue that the two servers are great. Maybe few will slightly give Nginx a small edge over Apache2. My experience is Nginx helped us where Apache2 failed. It might just be that I didn’t configure Apache2 correctly and that was why it failed on my site.
That can be argued.
For those who wish to install Nginx as their webserver can continue below to learn how to install or upgrade to the latest version in either Ubuntu or CentOS 7. For those who have chosen Apache2, can also just read and learn. This guide will come in handy for new users as well.
Here’s what you’ll find the new release;
- a change to disable SSLv3 by default
- some long deprecated directives are not supported anymore
- the “reuseport” parameter of the “listen” directive.
- a fix that for Nginx that might fail to start on some old Linux variants; the bug had appeared in 1.7.11.
and other changes.
If you update your servers but didn’t get updates for Nginx, it might just mean that you have a stable version of Nginx’s repository installed. In order to get the latest version of Nginx, you must install Nginx mainline repositories for your systems.
To install Nginx’s mainline repository in CentOS 7, run commands below to create a Nginx’s repository on your system
sudo vi /etc/yum.repos.d/nginx.repo
Then copy and paste the lines below into the file and save it.
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
To install Nginx’s mainline repository in Ubuntu, run the command below to obtain Nginx repository authentication key
cd /tmp/ && wget http://nginx.org/keys/nginx_signing.key
Then run the commands below to install or add the key to your system
sudo apt-key add nginx_signing.key
Next, run the commands below to create Nginx’s repository on your system
sudo vi /etc/apt/sources.list.d/nginx.list
Finally, add the lines below into 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 your Ubuntu system (ex. Ubuntu 14.10 is known as Utopic)
After that, run the commands below to install Nginx on Ubuntu
sudo apt-get update && sudo apt-get install nginx
To install Nginx CentOS 7 after adding the new repository, run the commands below.
sudo yum update && sudo yum install nginx
That’s how you install the latest version of Nginx on Ubuntu or CentOS 7.
Enjoy!
Frequently Asked Questions
How to install Nginx 1.9.1 in CentOS 7?
To install Nginx 1.9.1 in CentOS 7, you can follow the steps outlined in the official Nginx documentation or refer to tutorials available online for a detailed guide.
What are the benefits of using Nginx over Apache2?
Nginx offers better performance and scalability compared to Apache2 due to its asynchronous, event-driven architecture. It is known for handling high traffic loads efficiently.
Is Nginx a suitable web server for managing websites and blogs?
Yes, Nginx is a popular choice for managing websites and blogs due to its lightweight nature and ability to handle concurrent connections effectively.
How can I upgrade Nginx to the latest version in Ubuntu?
To upgrade Nginx to the latest version in Ubuntu, you can use the package manager to check for updates and install the newer version if available.
What changes were introduced in the latest Nginx 1.9.1 release?
The latest Nginx release includes changes such as disabling SSLv3 by default, dropping long-deprecated directives, and introducing the 'reuseport' parameter in the 'listen' directive.
Why might Nginx fail to start on some old Linux variants?
Nginx might fail to start on old Linux variants due to a bug that appeared in version 1.7.11, which has been fixed in the latest releases.
How can I ensure I have the latest version of Nginx installed on my server?
You can ensure you have the latest version of Nginx by installing the Nginx mainline repository for your system, which provides access to the most up-to-date versions of Nginx.
What are some key considerations when choosing between Apache2 and Nginx for web hosting?
Consider factors such as performance requirements, ease of configuration, and compatibility with your website's technology stack when choosing between Apache2 and Nginx for web hosting.