一、yum安装nginx
[root@localhost conf]# yum install nginx
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
没有可用软件包 nginx。
错误:无须任何处理
二、报错,需添加nginx源,添加完成后在/etc/yum.repos.d/ 会多出一个 nginx.repo
[root@localhost sbin]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root@localhost ~]# ll /etc/yum.repos.d/
总用量 32
-rw-r--r--. 1 root root 1664 8月 30 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 8月 30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root 649 8月 30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 8月 30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 8月 30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月 30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月 30 2017 CentOS-Vault.repo
-rw-r--r--. 1 root root 113 7月 15 2014 nginx.repo
三、再次执行yum install nginx -y
四、安装完成,查看nginx目录
[root@localhost ~]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/local/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
以下是Nginx的默认路径:
(1) Nginx配置路径:/etc/nginx/
(2) PID目录:/var/run/nginx.pid
(3) 错误日志:/var/log/nginx/error.log
(4) 访问日志:/var/log/nginx/access.log
(5) 默认站点目录:/usr/share/nginx/html
五、nginx相关的验证命令及启动命令
1、启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# nginx # 两种方法
2、测试
[root@localhost ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
3、nginx -s reload 修改nginx.conf之后,可以重载
[root@localhost ~]# nginx -s reload