Linux-nginx用法及配置檔案
阿新 • • 發佈:2022-05-31
Nginx編譯安裝
安裝編譯前置程式包
[root@centos7-liyj ~]#yum install -y gcc pcre-devel openssl-devel zlib-devel wget
現在nginx程式包
[root@centos7-liyj ~]#wget https://nginx.org/download/nginx-1.18.0.tar.gz
解壓縮
[root@centos7-liyj ~]#tar xf nginx-1.18.0.tar.gz -C /usr/local/src/
建立nginx安裝目錄和系統使用者
[root@centos7-liyj ~]#mkdir /usr/local/nginx [root@centos7-liyj ~]#groupadd nginx [root@centos7-liyj ~]#useradd -r -g nginx -s /sbin/nologin nginx
進入nginx編譯包
編譯程式安裝路徑,使用者,模組
[root@centos7-liyj ~]#cd /usr/local/src/nginx-1.18.0/ [root@centos7-liyj /usr/local/src/nginx-1.18.0]#./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module \
--with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module \
--with-stream_realip_module
安裝
[root@centos7-liyj /usr/local/src/nginx-1.18.0]#make -j 2 && make install
修改安裝好的nginx目錄許可權
[root@centos7-liyj /usr/local]#chown -R nginx.nginx /usr/local/nginx
編譯命令引數,方便使用
[root@centos7-liyj /usr/local]#ln -s /usr/local/nginx/sbin/nginx /usr/sbin/ [root@centos7-liyj /usr/local]#cd [root@centos7-liyj ~]#ng ngettext nginx [root@centos7-liyj ~]#ng ngettext nginx
安裝完成後的nginx檔案
[root@centos7-liyj /usr/local]#tree nginx/ nginx/ ├── conf #配置檔案存放 │ ├── fastcgi.conf │ ├── fastcgi.conf.default │ ├── fastcgi_params │ ├── fastcgi_params.default │ ├── koi-utf │ ├── koi-win │ ├── mime.types │ ├── mime.types.default │ ├── nginx.conf │ ├── nginx.conf.default │ ├── scgi_params │ ├── scgi_params.default │ ├── uwsgi_params │ ├── uwsgi_params.default │ └── win-utf ├── html #頁面檔案存放 │ ├── 50x.html │ └── index.html ├── logs #日誌 └── sbin #主程式 └── nginx
nginx用法幫助
[root@centos7-liyj ~]#nginx -h nginx version: nginx/1.18.0 Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit #顯示版本和編譯引數 -t : test configuration and exit #測試配置檔案是否異常 -T : test configuration, dump it and exit #測試並列印 -q : suppress non-error messages during configuration testing #靜默模式 -s signal : send signal to a master process: stop, quit, reopen, reload #傳送訊號,reload訊號 會生成新的worker,但master不會重新生成 -p prefix : set prefix path (default: /etc/nginx/) #指定Nginx 目錄 -c filename : set configuration file (default: /etc/nginx/nginx.conf) #配置檔案路徑 -g directives : set global directives out of configuration file #設定全域性指令,注意和配置檔案不要同時配置,否則衝突