第一步创建yum源
http://nginx.org/en/linux_packages.html#stable
去文件夹/etc/yum.repos.d/
创建nginx.repo文件
然后输入一下内容
[nginx]
name=nginxrepo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
替换相应的系统版本
Replace “OS
” with “rhel
” or “centos
”, depending on the distribution used, and “OSRELEASE
” with “6
” or “7
”, for 6.x or 7.x versions, respectively.
Yum源就创建好了。
yum install nginx –y 安装即可。
Rpm –q nginx 查看系统是否正常安装,如果显示出版本号,说明已正常安装。
Nginx 的配置文件在/etc/nginx/nginx.conf
可以通过命令 find / -name nginx.conf 查找
或是通过使用命令 nginx –t 来输出正在使用的nginx配置文件。
刚安装好的nginx不会自动启动。启动命令
Systemctl start nginx.service
这个时候就可以通过IP地址访问了。界面会显示:welcome to nginx
如果没能正常启动,检查一下防火墙。把防火墙关掉即可。
Systemctl stop firewalld.service
设置nginx开机启动
Systemctl enable nginx.service
网站文件存放默认目录
/usr/share/nginx/html
默认站点配置
/etc/nginx/conf.d/default.conf
自定义nginx站点配置文件存放目录
/etc/nginx/conf.d/