I’m trying to configure Nginx to serve a wordpress install (and a rails app – but this is not the problem).
I have a strange problem : I managed to get PHP work well (a basic test.php is correctly parsed), but when I want to install wordpress, Nginx send me the install.php file – I can download it.
It’s the only file for which Nginx do that : the other wordpress files as well-served, and do redirect to install.php much more time.
I am on a Gentoo.
I work with spawn-fcgi and here is below my nginx.conf. The concerning part is the second server (wp.domain.local) :
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/error_log info;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
ignore_invalid_headers on;
index index.html;
upstream rails_app {
server unix:/tmp/.sock fail_timeout=0;
}
server {
server_name domain.local www.domain.local;
access_log /var/log/nginx/domain.local.access_log main;
error_log /var/log/nginx/domain.local.error_log info;
root /path/to/rails/app/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://rails_app;
}
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /path/to/rails/app/public;
}
}
server {
server_name wp.domain.local *.wp.domain.local;
access_log /var/log/nginx/wp.domain.local.access_log main;
error_log /var/log/nginx/wp.domain.local.error_log info;
root /path/to/wordpress;
try_files $uri $uri/ /index.php;
index index.php index.html index.htm default.html default.htm;
location ~ .php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:65532;
fastcgi_index index.php;
}
}
server {
server_name localhost www.localhost;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
index index.php index.html index.htm default.html default.htm;
location ~ .php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:65532;
fastcgi_index index.php;
}
}
}
Try changing your try_files directive to
try_files $uri $uri/ /index.php?$args;
to handle the query strings WordPress uses.Please replace ‘/wordpress’ to your subdirectory.