使用nginx搭建WordPress的配置文件

开始按照网上的配置安装之后,在访问blog主页时会导致无限重定向的问题,而后来来回回多次修改之后,终于可以正常访问了,记下来以备以后查询,同时也让其他同学有个参考 :)

对了,对于默认开有防火墙的机器需要如下命令打开http访问

firewall-cmd –permanent –zone=public –add-service=http

firewall-cmd –permanent –zone=public –add-service=https(本条如未打开https服务非必须)

 

For more information on configuration, see:

* Official English Documentation: http://nginx.org/en/docs/

* Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
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;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

Load modular configuration files from the /etc/nginx/conf.d directory.

See http://nginx.org/en/docs/ngx_core_module.html#include

for more information.

include /etc/nginx/conf.d/*.conf;

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name just4fun.im;
access_log /var/wordpress/logs/access.log;
error_log /var/wordpress/logs/error.log;

root /var/wordpress/wordpress;
index index.php index.html index.htm;

Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;

location / {
root /var/wordpress/wordpress;
index index.php index.html index.htm;
}

location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}
}