33 Nginx基础配置实例配置实现
33 Nginx基础配置实例配置实现
33.1 主nginx.conf配置
[root@nginx-100 /usr/local/nginx/conf]# cat nginx.conf user www; worker_processes 2; error_log logs/error.log; pid logs/nginx.pid; #daemon on; # 默认on events { accept_mutex on; multi_accept on; worker_connections 1024; use epoll; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; log_format server1 '======> server1 access log format'; log_format server2 '======> server2 access log format'; include /home/www/conf.d/*.conf; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
33.2 server1.conf
[root@nginx-100 /home/www/conf.d]# cat server1.conf server { listen 8081; server_name localhost; access_log /home/www/myweb/server1/logs/access.log server1; location /server1/location1 { root /home/www/myweb; index index_sr1_location1.html; } location /server1/location2 { root /home/www/myweb; index index_sr1_location2.html; } error_page 404 /404.html; location = /404.html { root /home/www/myweb; index 404.html; } }
33.3 server2.conf
[root@nginx-100 /home/www/conf.d]# cat server2.conf server { listen 8082; server_name localhost; access_log /home/www/myweb/server2/logs/access.log server2; location /server2/location1 { root /home/www/myweb; index index_sr2_location1.html; } location /server2/location2 { root /home/www/myweb; index index_sr2_location2.html; } error_page 404 /404.html; location = /404.html { root /home/www/myweb; index 404.html; } }
———————————————————————————————————————————————————————————————————————————
无敌小马爱学习
浙公网安备 33010602011771号