CentOS 7, install Nginx using YUM (easy)

When using the following command to install Nginx, it is found that the installation cannot be successful

yum install -y nginx

Required Do a little bit of processing.

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 installing the rpm, we can see a file named nginx in the /etc/yum.repos.d/ directory .repo files.

Install Nginx

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

yum install -y nginx

Nginx default directory

Enter the command :

whereis nginx

You can see something similar to the following:
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) PID directory: /var/run/nginx.pid
(3) 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, only Know the Nginx configuration path, other paths can be found in /etc/nginx/nginx.conf and /etc/nginx/conf.d/default.conf.

Common Command

(1) Start:

nginx

(2) Test whether the Nginx configuration is correct:

nginx -t

(3) Graceful restart:

p>

nginx -s reload

(4) View the process number of nginx:

< pre>ps -ef |grep nginx

(5) nginx service stop

nginx -s stop

kill
-9 pid

Of course, Nginx can also be compiled and installed from source, the steps are relative To be more cumbersome,

yum install -y nginx

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

yum install -y nginx

whereis nginx

You can see something similar to the following:
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx

nginx

nginx -t

nginx -s reload

ps -ef |grep nginx

nginx -s stop

kill
-9 pid

Leave a Comment

Your email address will not be published.