2. Install Nginx
Contents
Ways to install Nginx on CentOS 7
Before we begin our journey, we must prepare a CentOS 7 Linux Server, if you don’t have one, you can consider getting one from Linode for very cheap price. Or you can follow along with your existing CentOS 7 Linux Server if you have one. If you are ready, then let’s begin our High-Performance Journey!
There are two ways of installation:
1. Nginx package installation
This option is suggested to the newcomers since they don’t know much details about what exactly Nginx use for, so the first thing they need to do is to quickly install it and start playing around with it.
Add Nginx repo into yum.repos.d directory
Create nginx.repo under yum.repos.d directory
|
|
Paste in the following content:
|
|
Update the local yum repository
Update the local repo:
|
|
Installation begins
Install Nginx:
|
|
Start Nginx and enable it at boot
After the installation, we start Nginx immediately, and we should enable Nginx at boot:
|
|
Check if it is working properly
Make sure Nginx has started both master and worker processes:
|
|
The results of running the command should be similar to the screenshot listed below:
Check if it is listening on port 80
Make sure Nginx is listening on port 80:
|
|
The results of running the command should be similar to the screenshot listed below:
Check to see if it is actually working
Finally, let’s also make sure we can visit Nginx’s default home page:
|
|
Result should look like:
2. Nginx source code installation
Source code installation is recommended for more complex situations, for example: customizing prefix directory, include necessary modules and exclude unnecessary modules.
Download source code
Download the source code to tmp directory:
|
|
Configure a path to install
|
|
Compile to executable files
|
|
Copy executable files to the configured prefix directory
|
|
References: Pre-Built Packages for Stable version, Building nginx from Sources
If you think the content of this article has helped you, and if you would like some more high-quality materials in the near future, please give me some modest support.
Author Dong Chen
LastMod Wed Oct 10 2018