php-docker
php-docker copied to clipboard
improvements to wordpress vhost for nginx
Hi Juan, I found that the bundled Wordpress configuration for Nginx doesn't work well. Please consider providing the following configuration instead. I'm no expert, but this works:
# /etc/nginx/sites-available/wordpress.conf
# Wordpress
map $cookie_XDEBUG_SESSION $my_fastcgi_pass {
default 127.0.0.1:9000;
xdebug 127.0.0.1:${phpfpm_xdebug_port};
}
server {
listen *:${nginxport} default_server;
server_name _;
root /var/www;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# WPLM fix
rewrite ^/en/wp-login.php /wp-login.php break;
rewrite ^/de/wp-login.php /wp-login.php break;
rewrite ^/fr/wp-login.php /wp-login.php break;
rewrite ^/es/wp-login.php /wp-login.php break;
rewrite ^/it/wp-login.php /wp-login.php break;
location ~ \.php(/|$) {
set $path_info $fastcgi_path_info;
fastcgi_pass $my_fastcgi_pass;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\. {
deny all;
}
location ~ /\.svn/* {
deny all;
}
location ~ /\.git/* {
deny all;
}
location /nginx_status {
stub_status on;
access_log off;
}
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
allow 127.0.0.1;
deny all;
}
}