Como faço para mover uma instalação do CMS da raiz para o subdiretório (nginx)

0

Eu inadvertidamente instalei o Wordpress na raiz do meu servidor nginx do Ubuntu. Como faço para mover esta instalação da raiz para um subdiretório chamado / blog? ex. mysite.com/blog

O que eu tenho agora:

server {
listen 80;
server_name mysite.com;
root /srv/www/wordpress;
index index.php index.html index.htm;

include conf.d/wp/restrictions.conf;

# Additional rules go here.

include conf.d/wp/wordpress.conf;
}

Abaixo está o conf.d / wp / wordpress.conf

# WordPress single blog rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule

location / {
        index index.html index.htm index.php;
}

location /blog {
        index index.html index.htm index.php;
        try_files $uri $uri/ /blog/index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
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;
}

# Uncomment the line below for the W3 total caching plugin (if used).
#include conf.d/wp/wordpress-w3-total-cache.conf;

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#       fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
}

Apesar de adicionar:

location /blog {
        index index.html index.htm index.php;
        try_files $uri $uri/ /blog/index.php?$args;
}

O FYI Wordpress ainda está localizado em / srv / www / wordpress

... ainda não está funcionando, o que me faz pensar se realmente entendi o que estou fazendo!

Qualquer ajuda é apreciada. Obrigado.

    
por Atlas2k 28.07.2015 / 16:01

1 resposta

0

Corrigido isso movendo /srv/www/wordpress para um subdiretório. O URI final é: /srv/www/html/blog com os arquivos do Wordpress em /srv/www/html/blog

O bloco do servidor terá isso: root /srv/www/html;

# Redirects users from root to /blog
location = / {
    return 301 http://example.com/blog;
}

location /blog {
#       index index.html index.htm index.php;
        try_files $uri $uri/ /blog/index.php?$args;
}
    
por 29.07.2015 / 08:02