###centos7安裝_Nginx_ centos7安裝Nginxhtml
若是訪問不了Nginx,請檢查一下本身的防火牆呦。nginx
###配置web
vi /usr/local/nginx/conf/nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; 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; #include /etc/nginx/conf.d/*.conf; upstream p2pweb.com { server 192.168.3.106:8780; server 192.168.3.106:8880; } server { listen 80; server_name p2pweb; add_header backendIP $upstream_addr; add_header backendCode $upstream_status; location / { proxy_pass http://p2pweb.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Cookie $http_cookie; } location ^~ /p2pweb-static/ { root /mnt/service/tomcat/tomcat-cluster/; access_log off; expires -1; } location ^~ /P2P/ { root /home/upload-file/; access_log off; expires -1; } location ^~ /studentInfoImages/ { root /home/upload-file/; access_log off; expires -1; } location ^~ /userfiles/ { root /home/upload-file/P2P/; access_log off; expires -1; } location ^~ /zhaopin/ { root /home/upload-file/; access_log off; expires -1; } } } user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; 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; #include /etc/nginx/conf.d/*.conf; upstream p2pweb.com { server 192.168.3.106:8780; server 192.168.3.106:8880; } server { listen 80; server_name p2pweb; add_header backendIP $upstream_addr; add_header backendCode $upstream_status; location / { proxy_pass http://p2pweb.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Cookie $http_cookie; } "/etc/nginx/nginx.conf" 78L, 1917C } location ^~ /p2pweb-static/ { root /mnt/service/tomcat/tomcat-cluster/; access_log off; expires -1; } location ^~ /P2P/ { root /home/upload-file/; access_log off; expires -1; } location ^~ /studentInfoImages/ { root /home/upload-file/; access_log off; expires -1; } location ^~ /userfiles/ { root /home/upload-file/P2P/; access_log off; expires -1; } location ^~ /zhaopin/ { root /home/upload-file/; access_log off; expires -1; } } }