My Setup
I am running nginx 0.7.67 on Debian Lenny as a webserver, not as a reverse proxy. I am using php5-fpm to handle my PHP requests, which works fine.
My Aim
I would like to have a WordPress installation that is laid out as described here clean wordpress subversion installation. I would like to have a clean WordPress installation without cluttering my server root directory with all the WordPress files.
That means that my wordpress installation would be in /wordpress
and my themes and plugins inside /wordpress-content
.
The important point however is that if you navigate to my domain www.example.com then you would be taken directly to the WordPress blog, without having to specify the subdirectory where WordPress lives.
I found a how-to at the nginx site installing wordpress but unfortunately this is for moving the entire WordPress directory instead of redirecting the traffic to it.
I tried with the following configuration:
example.conf in sites-available
server {
listen 80;
server_name www.example.com;
access_log /var/log/nginx/www.example.com.access.log main;
root /var/www/example/htdocs;
location / {
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
include /etc/nginx/includes/php5-wordpress.conf;
include /etc/nginx/includes/deny.conf;
}
php5-wordpress.conf in includes
location /wordpress {
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(/wordpress)(/.*)$;
fastcgi_ignore_client_abort on;
fastcgi_pass unix:/var/run/php5-fpm.socket;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
fastcgi_params
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
The problems I have is that when I go to the address "http://www.example.com" I get a 403 error as I disabled directory listing. Instead I would like my WordPress to appear then. Also if I navigate to "http://www.example.com/wordpress" I get a "file not found" error. However if I comment out the fastcgi_split_path_info line in my php5-wordpress.conf at least the WordPress installation works inside /wordpress.
I need help how to debug this behavior or where I can find more information.
Update: Added error log entry for the 403 error.
in the error.log I get the following entry for the 403 error:
2010/12/11 07:54:24 [error] 9496#0: *1 directory index of
"/var/www/example/htdocs/" is forbidden, client: XXX.XXX.XXX.XXX,
server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Update 2: Added the nginx.conf below:
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
index index.php index.html;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
You're just lacking an index directive
Why not just use the steps here: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory and then have SVN update the wordpress folder only. index.php has not changed for Wordpress in 3 years, you can check the Wordpress trac as I cant link to it, so you can follow the steps for the SVN for all the other stuff like moving wordpress content out but move index.php to the root and change set it up as the codex I linked too says. In the rare chance that index.php gets update its only one file you will manually need to copy again for the root.
I am able to setup Wordpress with its own directory on my nginx server with no problem at all and no tweaking of my .conf files.