安装WordPress,我想设置我的博客同一个网站的子目录下的example.com/blog
在子目录中的Nginx
我使用多种设置它尝试过,但没有工作中。有的给出502错误,有的给404以下配置给出没有指定输入文件错误。
server {
listen 80;
server_name www.example.com;
gzip on;
location/{
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
proxy_pass http://localhost:8080;
}
location ^~ /blog{
root /home/myubuntu/www/blog;
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
我运行一个子域此相同的博客与成功配置如下:
server {
listen 80;
root /home/myubuntu/www/blog;
index index.php index.html index.htm;
server_name blog.example.com;
gzip on;
location/{
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx.html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
可能有人请告诉我,我在做什么错
任何人都可以管理这个代码,即删除HTML标签('code'和pre)并以系统化的方式进行管理。因为它是经过测试的代码并且工作正常。 – Shankaranand 2015-07-03 11:41:37