一、使用rpm安装nginx
1、下载rpm,nginx-1.10.2-1.el6.ngx.x86_64.rpm(百度搜)
2、上传到centos中
[root@ONE nginx]# ll
总用量 828
-rw-r--r-- 1 root root 844528 1月 14 09:46 nginx-1.10.2-1.el6.ngx.x86_64.rpm
3、输入命令
rpm -ivh nginx-1.10.2-1.el6.ngx.x86_64.rpm
4、启动nginx(任意目录)
service nginx start
5、停止nginx
service nginx stop
6、刷新配置文件
nginx -s reload
二、配置静态资源访问
1、在/etc/nginx/nginx.conf中http节点下加入如下代码(#是注释)
#static resource
server{
listen 80; nginx监听的端口
server_name 10.56.28.107; nginx监听的ip地址
location / { 我理解为浏览器中输入的
root /; 实际对应的目录
autoindex on;
}
2、我在/root/pictest放了一张为111.jpg的图片
3、通过nginx访问在浏览器中输入的路径为 http://10.56.28.107/root/pictest/111.jpg
三、过程中遇到的问题
1、nginx 403 forbidden
在/etv/nginx/nginx.conf中
2、使用rpm命令报Dependencies错误
更换rpm包的版本
rpm -ivh nginx-1.10.2-1.el6.ngx.x86_64.rpm