Nginx Config - I can't access WordPress admin area

Posted by WebDevDude on Server Fault See other posts from Server Fault or by WebDevDude
Published on 2012-12-02T00:03:50Z Indexed on 2012/12/02 11:08 UTC
Read the original article Hit count: 202

Filed under:
|

I am a complete noob when it comes to Nginx, but I'm trying to make the switch over for my WordPress site. Everything works, even the permalink, but I can't access my WordPress admin directory (I get a 403 error).

I have my WordPress install in a subfolder, so that complicates things a bit for me. Here is my Nginx config file:

server {
server_name mydomain.com;
access_log /srv/www/mydomain.com/logs/access.log;
error_log /srv/www/mydomain.com/logs/error.log;
root /srv/www/mydomain.com/public_html;

location / {
    index index.php;
    # This is cool because no php is touched for static content.
    # include the "?$args" part so non-default permalinks doesn't break when using query string
    try_files $uri $uri/ /index.php?$args;
}
location /myWordpressDir {
    try_files $uri $uri/ /myWordpressDir/index.php?$args;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/www/mydomain.com/public_html$fastcgi_script_name;
    fastcgi_split_path_info ^(/myWordpressDir)(/.*)$;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off;
    log_not_found off;
    expires max;
}

}

© Server Fault or respective owner

Related posts about nginx

Related posts about Wordpress