配置以下php
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { # host server_name example.com www.example.com; #設置長鏈接 keepalive_timeout 70; #減小點擊劫持 add_header X-Frame-Options DENY; #禁止服務器自動解析資源類型 add_header X-Content-Type-Options nosniff; #防XSS攻擊 add_header X-Xss-Protection 1; # 默認index index index.html index.htm index.php default.html default.htm default.php; # 代碼的根目錄 root /home/wwwroot/example; # 訪問日誌 access_log /usr/local/nginx/logs/example.com.log main; } }