Nginx
用於執行 php 腳本的 Nginx 全域配置
要配置 Nginx 來處理 PHP 應用程序,可以在 下創建一個專用的conf 文件
sites-available
,然後在 下創建一個相應的符號連結sites-enabled
,但我不想使用這種方法 - 我更喜歡一個全域conf 來執行 php 腳本,適用於所有項目。可以放進去的東西nginx.conf
。我在任何地方都找不到這樣的全球會議。是否有用於執行 php 腳本的 Nginx 全域配置?
像這樣的東西。您只需要將項目保存在與其域名 ($host) 一致的文件夾中檢查 nginx 變數: http: //nginx.org/en/docs/http/ngx_http_core_module.html#var_host
user www-data; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 8192; } http { server_tokens off; 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; tcp_nodelay on; keepalive_timeout 65; #gzip on; server { listen 80 default_server; root /var/www/$host; index index.php; location / { try_files $uri $uri/ /index.php?$args; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 24h; log_not_found off; } location ~ /\. { access_log off; log_not_found off; deny all; } rewrite /files/$ /index.php last; if ($uri !~ wp-content/plugins) { rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last; } location ~ \.php$ { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; client_max_body_size 25M; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } } }