The method tutorial for installing Nginx with yum in CentOS 7

  • 2020-05-13 04:31:33
  • OfStack

preface

Because of the recent preparations for the Docker series, which involves installing Nginx in CentOS 7. I have encountered some problems, so I want to share the process summary for your reference and study. Let's take a look at the detailed introduction below:

When you installed Nginx using the following command, you found that the installation failed.


yum install -y nginx

You have to do a little bit of processing.

Install Nginx source

Execute the following commands:


rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Install the rpm after, we can in the/etc/yum repos. d/directory to see one called nginx. repo file.

Install Nginx

Once you have installed the Nginx source, you are ready to officially install Nginx.


yum install -y nginx

Nginx default directory

Input command:


whereis nginx

You can see something like the following:


nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx

Here is the default path for Nginx:

(1) Nginx configuration path: /etc/nginx/

(2) PID directory: / var run/nginx pid

(3) the error log: / var/log/nginx/error log

(4) access log: / var/log/nginx/access log

(5) the default site directory: / usr share/nginx/html

In fact, only know Nginx configuration path, the other path, are available on/etc nginx/nginx conf and etc/nginx/conf d/default conf query to.

Common commands

(1) launch:


nginx

(2) test whether the Nginx configuration is correct:


nginx -t

(3) elegant restart:


nginx -s reload

This command is similar to the following:


kill -HUP nginx Process of no. 

Of course, Nginx can also be compiled and installed manually. The steps are relatively tedious, but in general, it is relatively simple and will not be covered in this article.

conclusion


Related articles: