centos6使用rpm 安裝nginx(可以不聯網)、配置靜態資源訪問、遇到的問題以及解決方法

一、使用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

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章