How to install nginx on CentOS 7
Nginx is primarily a web server for various protocols such as HTTP, HTTPS, IMAP, POP3 and SMTP. It also performs other functions, including HTTP caching, load balancing and acting as a reverse proxy. Nginx is open-source software that runs on Linux-like operating systems such as CentOS. It’s distributed as a binary package that contains all of the files needed to install nginx, including a public PGP key and configuration file. This installation requires you to install the nginx software repository and then install the actual software from the repository.
|DIFFICULTY||Basic - 1 | Medium - 2 | Advanced - 3|
|TIME REQUIRED||10 min|
|RELATED PRODUCTS||CentOS-based VPS or dedicated servers|
Here is a quick tutorial on how to install nginx on CentOS 7.
Install the nginx software repository
Connect to your server via SSH (more info).
Switch to the root user (more info).
Enter the directory where you’ll install the repository. Assuming you wish to use the tmp directory, you’ll use the following command:
Download the appropriate nginx binary package for CentOS. The following wget command downloads the most current version of this package:
Install the nginx yum configuration file for this package with the following rpm command:
The following yum command will install nginx from the yum configuration file by automatically answering "yes" to all questions.
The yum command will produce output similar to the following if nginx installs successfully:
Enter the following commands to enable and start nginx:
(If you have another service listening on port 80, such as Apache - you will have to stop that service prior to starting nginx. You can also change the port that nginx listens on by modifying the
Enter the following URL into your browser:
This page should look like the following screenshot if nginx is running correctly: