安裝php:https://windows.php.net/download/,php默認啟動命令:php-cgi.exe -b 127.0.0.1:9000
安裝wordpress:https://cn.wordpress.org/
原來wordpress是部署在iis中,安裝了nginx以后,實際上可以直接通過nginx配置好php,而不再通過iis:
server { listen 80; server_name help.adomain.cn; location ~ \.php$ { root E:/ServerCore/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
E:/ServerCore/wordpress是wordpress的安裝目錄
127.0.0.1:9000是php-cgi.exe監聽的9000端口,需要在啟動php-cgi.exe時配置,nginx和php的啟動參考:Nginx的使用(三)把nginx和php-cgi.exe注冊成windows服務
wordpress官方的偽靜態是通過.htaccess實現的,但nginx並不支持.htaccess,網上找到wordpress偽靜態的方法:
location / { root E:/ServerCore/wordpress; index index.php; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } }
偽靜態后頁面什么的確實可以訪問了,結果卻出現新的問題,后台不能訪問了,仔細觀察發現后台所有地址都缺少wp-admin目錄,又在網上去尋找答案,就是簡單地加一行斜杠重定向而已,方法如下:
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
wordpress域名修改以后,可以通過以下的sql語句修改wordpress數據庫實現數據升級:
UPDATE wp_options SET option_value = replace( option_value, 'http://www.old.com', 'http://www.new.com' ) WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = replace( post_content, 'http://www.old.com', 'http://www.new.com' ) ; UPDATE wp_posts SET guid = replace( guid, 'http://www.old.com', 'http://www.new.com' ) ;