您的位置:首页 > 运维架构 > Nginx

centos6使用rpm 安装nginx(可以不联网)、配置静态资源访问、遇到的问题以及解决方法

2019-01-14 11:28 856 查看

一、使用rpm安装nginx

1、下载rpm,nginx-1.10.2-1.el6.ngx.x86_64.rpm(百度搜)

2、上传到centos中

[code][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、输入命令

[code]rpm -ivh nginx-1.10.2-1.el6.ngx.x86_64.rpm

4、启动nginx(任意目录)

[code]service nginx start

5、停止nginx

[code]service nginx stop

6、刷新配置文件

[code]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包的版本

[code]rpm -ivh nginx-1.10.2-1.el6.ngx.x86_64.rpm

 

 

 

 

 

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐