nginx config的多個config配置
阿新 • • 發佈:2018-07-21
pla nop size header pub default http fast processes
在我們的一臺服務器上,一個nginx服務器下面可能跑著許多許多的項目;
那麽就需要配置多個對應的配置 端口號 已經文件入庫目錄等等
那麽項目多了以後,把這些項目都寫到一個文件裏 到後期難以查看與管理
我們只需要新建一個文件夾,下面全部存放 我們的子配置 然後在主配置中把這個子目錄引入即可
然後我們的主配置文件如下
user www www; worker_processes 8; error_log /www/logs/error.log info; #access_log /www/logs/nginx.access.log main; pid /var/run/nginx.pid; worker_rlimit_nofile51200; events { use epoll; worker_connections 51200; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main ‘"$time_local","$remote_addr","$http_x_forwarded_for","$http_host","$request","refer:$http_referer","$http_user_agent","$status","$request_time","$upstream_response_time","$body_bytes_sent","$upstream_addr","$upstream_status","$upstream_response_time","$http_cookie_pgv_pvi","$request_body","$uid_got"‘; server_names_hash_bucket_size128; client_header_buffer_size 128k; large_client_header_buffers 4 128k; client_max_body_size 100m; client_body_buffer_size 1024k; sendfile on; tcp_nopush on; keepalive_timeout 30; tcp_nodelay on; fastcgi_intercept_errors on; fastcgi_connect_timeout 300; fastcgi_send_timeout300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; user www www; worker_processes 8; error_log /www/logs/error.log info; #access_log /www/logs/nginx.access.log main; pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main ‘"$time_local","$remote_addr","$http_x_forwarded_for","$http_host","$request","refer:$http_referer","$http_user_ag ent","$status","$request_time","$upstream_response_time","$body_bytes_sent","$upstream_addr","$upstream_status","$upstream_response _time","$http_cookie_pgv_pvi","$request_body","$uid_got"‘; server_names_hash_bucket_size 128; client_header_buffer_size 128k; large_client_header_buffers 4 128k; client_max_body_size 100m; client_body_buffer_size 1024k; sendfile on; tcp_nopush on; keepalive_timeout 30; tcp_nodelay on; fastcgi_intercept_errors on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; 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 image/jpeg image/gif image/png; gzip_vary on; #server { # listen 80; # server_name localhost; # location / { # proxy_next_upstream http_502 http_504 http_404 error timeout invalid_header; # proxy_pass http://78list.cn; #proxy_set_header Host www.yourdomain.com; # proxy_set_header X-Forwarded-For $remote_addr; # } #} #upstream 78list.cn { # server 192.168.8.113:8080; #} include /etc/nginx/default.conf; include /etc/nginx/upstream/*.conf; include /etc/nginx/conf.d/*.conf; // 這裏就是引入的子配置文件夾 }
一個範例 子配置的conf
server { listen 832; // 端口號 server_name localhost; // 域名 index index.html index.htm index.php; root /home/www/ai/crm/web/public; //項目的入口文件夾 location ~ /.svn/ { deny all; } location / { rewrite ^/$ /index.php last; rewrite ^/(?!index\.php|index\.html|layui|css|js|bootstrap|robots\.txt)(.*)$ /index.php/$1 last; } location ~ \.php { fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~/uploads/.*\.(php|php5)?$ { deny all; } location ~/public/.*\.(php|php5)?$ { deny all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 8d; } #access_log /www/logs/access.log main; }
nginx config的多個config配置