下载:wget 增加用户:groupadd wwwuseradd -g www -s /sbin/nologin -M www安装:tar -zxvf nginx-1.9.15.tar.gz cd nginx-1.9.15less README ./configure --helpyum install gcc-c++ pcre-devel.x86_64 libssl-dev openssl-devel.x86_64./configure --user=www --group=www --prefix=/opt/app/nginx --with-pcre --with-http_ssl_module --with-http_addition_module --with-http_realip_module --with-http_flv_module --with-http_stub_status_modulemake && make install
配置文件: zabbix使用
nginx.conf
user www www;worker_processes 16;error_log /opt/app/nginx/logs/error.log;pid /opt/app/nginx/logs/nginx.pid;worker_rlimit_nofile 65535;events { use epoll; worker_connections 10240;}http { include mime.types; default_type application/octet-stream; log_format main '$request_filename - $document_root - $fastcgi_script_name' '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format download '$remote_addr remote_user [$time_local]' '"$request" $status $bytes_sent' '"$http_referer" "$http_user_agent"' '"$http_range" "$sent_http_content_range"'; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; server_tokens off; fastcgi_connect_timeout 30; fastcgi_send_timeout 30; fastcgi_read_timeout 30; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; access_log logs/access.log main; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; include /opt/app/nginx/conf/conf.d/*.conf; }
z.conf
server { listen 80 ; server_name jk.zbbix.cn; root /data/www/php; default_type text/html; charset utf8; access_log logs/jk.access.log; error_log logs/jk.error.log; location / { index index.html index.htm index.php; if (-f $request_filename) { expires max; break; } if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } error_page 404 /404.php; error_page 500 502 503 504 /50x.html; location ~ .*\.php { root /data/www/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /opt/app/nginx/conf/fastcgi_params; set $real_script_name $fastcgi_script_name; fastcgi_param SCRIPT_NAME $real_script_name; }}