0
我一直在爲此奮鬥一段時間。我想設置一個Wordpress博客,從服務器上的「/ blogname」路徑而不是根目錄運行。我也希望路徑具有不同的名稱,然後是Wordpress腳本所在的目錄,因爲服務器本身將運行django。如何設置php從Nginx的單個位置運行
我有Nginx作爲反向代理,我設置了php-fpm來運行wordpress。下面是我的Nginx的配置文件:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#tcp_nopush on;
#gzip on;
server {
root /Users/username/Dev/Wordpress/;
index index.php index.html index.htm;
listen 8080;
server_name localhost;
# Do not serve hidden files
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
# Static files
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# This is the problem
location /blogname {
try_files $uri $uri/ /index.php;
rewrite /blogname(.*) /blog$1 last;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /Users/username/Dev/Wordpress/blog$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
}
現在當我訪問本地主機:8080/BLOGNAME我剛剛下載的index.php腳本,而不是執行它。
其他技巧也歡迎。