1、安裝指引:html
一、獲取版本包,例如: wget http://nginx.org/download/nginx-1.8.1.tar.gzandroid
二、解壓版本包: tar -zxvf nginx-1.8.1.tar.gznginx
三、釋放配置: ./configurec++
四、安裝:make && make installapi
五、啓動: /usr/local/nginx/sbin/nginxapp
六、重啓: /usr/local/nginx/sbin/nginx -s reloadiphone
2、安裝出現的問題:ui
一、 ./configure: error: C compiler cc is not found.net
解決方案: yum install gcc gcc-c++ ncurses-devel perl日誌
二、 ./configure: error: the HTTP rewrite module requires the PCRE library.
解決方案: yum -y install pcre-devel
三、 ./configure: error: the HTTP gzip module requires the zlib library.
解決方案: yum install -y zlib-devel
四、 ./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決方案: yum -y install openssl openssl-devel
3、實踐配置:
一、修改默認端口:
文件名:/usr/local/nginx/conf/nginx.conf
修改配置:listen 81;
二、增長靜態頁面訪問:
文件名:/usr/local/nginx/conf/nginx.conf
location /html/{
root /usr/local/static/;
autoindex on;
}
三、靜態資源下載:
①、支持的文件類型,文件名:/usr/local/nginx/conf/mime.type
支持下載APK文件:
application/vnd.android.package-archive apk;
application/iphone pxl ipa;
②、文件名:/usr/local/nginx/conf/nginx.conf
location /apk/ {
#root html;
#index index.html index.htm;
if ($request_filename ~* ^.*?\.(txt|apk)$){
add_header Content-Disposition: 'attachment;';
}
}
4、問題排查:
一、查看error.log日誌
/usr/local/nginx/logs/error.log
例如:
2018/04/01 14:05:47 [error] 29512#0: *99 open() "/usr/local/nginx/html/apk/xiadanla_103.apk" failed (2: No such file or directory), client: 223.73.59.167, server: localhost, request: "GET /apk/xiadanla_103.apk HTTP/1.1", host: "api.xiadanla.com:81"
二、查看訪問日誌:
/usr/local/nginx/logs/access.log
例如:183.61.51.60 - - [01/Apr/2018:14:36:08 +0800] "GET /apk/xiadanla_103.apk HTTP/1.1" 200 960160 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; vivo X9 Build/MOB31K)"
5、輔助信息
安裝:https://blog.csdn.net/fordarkuse5/article/details/51100251,https://wenku.baidu.com/view/0aa6c28fcc22bcd126ff0c49.html 啓動:https://blog.csdn.net/stuartjing/article/details/6909319 修改ngnix端口:https://blog.csdn.net/dongdong9223/article/details/60573953 nginx配置反轉:https://blog.csdn.net/tobacco5648/article/details/51099426 安裝內容:https://blog.csdn.net/tjcyjd/article/details/50695922 文件下載配置:https://blog.csdn.net/zhang_ruiqiang/article/details/48141783