Configurar WordPress como subdirectorio con NGINX
En este caso necesitamos configurar el blog en un directorio por ejemplo: www.midominio.com/blog
Cómo instalar WordPress con Nginx en Ubuntu 14.04 en DigitalOcean – Ingles
Pero en mayoría de los casos en raíz tenemos instalado otro proyecto (Django, Symfony, etc.) y necesitamos levantar un subdirectorio.
Ahora modificamos la configuración del dominio ubicado en /etc/nginx/sites-available/default
En este caso tengo instalado symfony en base:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
server { listen 80; root /var/html/symfony/web/; index index.php index.html index.htm; server_name www.rogerca.com; location / { # try to serve file directly, fallback to app.php try_files $uri /app.php$is_args$args; } location ~ ^/app\.php(/|$) { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; # When you are using symlinks to link the document root to the # current version of your application, you should pass the real # application path instead of the path to the symlink to PHP # FPM. # Otherwise, PHP's OPcache may not properly detect changes to # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 # for more information). fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; # Prevents URIs that include the front controller. This will 404: # http://domain.tld/app.php/some-path # Remove the internal directive to allow URIs like this internal; } location @wp { rewrite ^/blog(.*) /blog/index.php?q=$1; } location ^~ /blog { root /var/html/; index index.php index.html index.htm; try_files $uri $uri/ @wp; location ~ \.php { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass unix:/var/run/php5-fpm.sock; } } error_log /var/log/nginx/base_error.log; access_log /var/log/nginx/base_access.log; } |