CentOS 7, using the Nginx yum installation (easy)

When using the following command to install Nginx , we found that you can not install successfully

yum install -y nginx

We need to do a little deal.

Install Nginx source

Execute the following command:

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

After you install the rpm, we can see a file called nginx.repo in /etc/yum.repos.d/ directory.

Install Nginx

After installing Nginx source, you can install Nginx the official.

yum install -y nginx

Nginx default directory

input the command:

whereis nginx
You can see something like the following contents:
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx

The following is the default path of Nginx:

(1) Nginx configuration path: / etc / Nginx /
(2) the PID directory: / var / RUN / nginx.pid
(. 3) the error log: / var / log / Nginx / error .log
(. 4) access log: / var /log/nginx/access.log
(5) default site directory: / usr / share / nginx / html

In fact, just know Nginx configuration path, the other path can be queried in /etc/nginx/nginx.conf and /etc/nginx/conf.d/default.conf in.

Common Commands

(1) Start:

nginx

(2) test Nginx configuration is correct:

nginx -t

(3) Graceful Restart:

nginx -s reload

(4) View nginx process ID:

ps -ef | grep nginx

(5) nginx service stops

nginx -s stop
kill -9 pid

Of course, Nginx compile the source code may be installed, some of the steps is relatively cumbersome,

 

Guess you like

Origin www.cnblogs.com/lee-qi/p/11355474.html