使用yum命令安装
yum install -y nginx
查看安装命令
whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz
Nginx的默认路径
Nginx配置路径:/etc/nginx/
PID目录:/var/run/nginx.pid
错误日志:/var/log/nginx/error.log
访问日志:/var/log/nginx/access.log
默认站点目录:/usr/share/nginx/html
启动Nginx
cd /etc/nginx
nginx
测试Nginx配置是否正确
nginx -t
显示如下
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
查看Nginx进程
ps -ef | grep nginx
若配置文件有变更,重启加载新的配置文件
nginx -s reload
Web访问
在浏览器输入IP地址即可访问(默认80端口)
如是云服务器,请在访问规则中开通80端口
参考链接:https://www.centos.bz/2018/01/centos-7,使用yum安装nginx/