yum安裝nginx後可經過命令rpm -pl nginx查看相關的安裝目錄。以下:
路徑 | 類型 | 做用 |
---|---|---|
/etc/logrotate.d/nginx | 配置文件 | Nginx日誌輪轉,用於logrotate服務的日誌切割 |
/etc/nginx /etc/nginx/nginx.conf /etc/nginx/conf.d /etc/nginx/conf.d/default.conf | 目錄,配置文件 | nginx主配置文件 |
/etc/nginx/fastcgi_params /etc/nginx/uwsgi_params /etc/nginx/scgi_params | 配置文件 | cgi配置相關,fastcgi配置 |
/etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/win-utf | 配置文件 | 編碼轉換映射轉換文件 |
/etc/nginx/mime.types | 配置文件 | 設置http協議的content-type與擴展名對應關係 |
/usr/lib/systemd/system/nginx-debug.service /usr/lib/systemd/system/nginx.service /etc/sysconfig/nginx /etc/sysconfig/nginx-debug | 配置文件 | 用於配置系統守護進程管理器管理方式 |
/usr/lib64/nginx/modules /etc/nginx/modules | 目錄 | nginx模塊目錄 |
/usr/sbin/nginx /usr/sbin/nginx-debug | 命令 | nginx服務的啓動管理的終端命令 |
/usr/share/doc/nginx-版本號 /usr/share/doc/nginx-版本號/COPYRIGHT /usr/share/man/man8/nginx.8.gz | 文件、目錄 | nginx手冊、幫助文件 |
/var/cache/nginx | 目錄 | nginx的緩存目錄,nginx佈景能夠用做服務代理,還能夠用來作緩存服務 |
/var/log/nginx | 目錄/nginx日誌目錄 |
使用nginx -V查看配置參數:nginx
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
編譯選項 | 做用 |
---|---|
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock | 安裝目的目錄或路徑 |
--http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp | 執行對應的模塊時,nginx所保留的臨時性文件 |
--user=nginx --group=nginx | 設定nginx進程啓動的用戶和用戶組 |
nginx.conf的配置相關
第一塊:緩存
參數 | 說明 |
---|---|
user | 設置nginx服務的系統使用用戶 |
worker_processes | 工做進程數,與cpu核數保持一致 |
error_log | nginxd的錯誤日誌 |
pid | nginx服務啓動時候的pid |
第二塊:app
模塊 | 參數 | 說明 |
---|---|---|
events | worker_connections | 每一個進程容許最大鏈接數 |
use | 工做進程數 |
第三塊:dom
http { include /etc/nginx/mime.types; // http的content-type設置 default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; // 標準的方式是將多個server配置成多個.conf文件放在/etc/nginx/conf.d下include進來 #include /etc/nginx/conf.d/*.conf; server { listen 80; server_name localhost; localtion / { root .... index .... } error_page .... localtion = /50x.tml { ..... } } server { .... } server { .... } }
log_format定義access_log的日誌內容格式,可自定義。例如添加user_agent信息:$http_User_Agent.tcp