Wordpress 从Apache转换为Nginx+;PHP-FPM

Wordpress 从Apache转换为Nginx+;PHP-FPM,wordpress,apache,nginx,php,Wordpress,Apache,Nginx,Php,我有一个网站,它托管在使用PHP和Apache的服务器上。我想把这个站点迁移到另一个运行在PHP-FPM和Nginx上的主机上。显然,更改名称服务器、mysql转储和传输实际的wp文件夹是比较容易的部分。但是,我想知道在迁移站点之前要修改哪些设置 据我所知,我唯一需要担心的是漂亮的URL。我也许能做到 try_文件$uri$uri//index.php?$query_字符串如果有效。然而,如果不是这样,在将名称服务器恢复到其原始状态之前,I将冒着站点被破坏数小时的风险 这里有一篇很棒的文章:关于

我有一个网站,它托管在使用PHP和Apache的服务器上。我想把这个站点迁移到另一个运行在PHP-FPM和Nginx上的主机上。显然,更改名称服务器、mysql转储和传输实际的wp文件夹是比较容易的部分。但是,我想知道在迁移站点之前要修改哪些设置

据我所知,我唯一需要担心的是漂亮的URL。我也许能做到
try_文件$uri$uri//index.php?$query_字符串如果有效。然而,如果不是这样,在将名称服务器恢复到其原始状态之前,I将冒着站点被破坏数小时的风险

这里有一篇很棒的文章:关于Wordpress的NGINX配置,这里是我用于普通(而不是多站点)Wordpress的文章。我将其保存在一个单独的文件(wordpress.conf)中,然后将其包含在wordpress支持的站点的服务器块中:

location = /favicon.ico {
        log_not_found off;
        access_log off;
}

location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
}

# Deny access to any files with a .php extension in the uploads directory
location ~* ^/wp-content/uploads/.*.php$ {
        deny all;
        access_log off;
        log_not_found off;
}

# Deny access to any files with a .php extension in the uploads directory for multisite
location ~* /files/(.*).php$ {
        deny all;
        access_log off;
        log_not_found off;
}

# 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 / {
        try_files $uri $uri/ /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 ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires 24h;
        log_not_found off;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/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/php-fpm/php-fpm.sock;
}

这太棒了。非常感谢。