image

STEP.1 下載worldpress

https://tw.wordpress.org/download/#download-install

image

環境需求:

建議採用執行 PHP 7.4 及MySQL 5.7 或更新版本的伺服器,
建議在 Apache  Nginx 這兩種最適合執行 WordPress 的網頁伺服器中擇一使用

 

STEP.2 PHP

https://windows.php.net/download#php-8.2

載下來的php整包解壓縮跟nginx放在一起

image

把php目錄中的php.ini-production複製一份,並改名為php.ini,修改配置

extension_dir = "ext"
cgi.fix_pathinfo = 1
extension = bz2
extension = curl
extension = mysqli
extension = pdo_mysql

添加系統變數, 否則會報錯php指令not found 

php -v bash: php: command not found

image

整個php路徑塞進path裡

image

php -v
PHP 8.2.6 (cli) (built: May  9 2023 16:07:30) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies

 

STEP.3 NGINX
nginx教學可以參考這篇:

image

 

nginx官網上有快速配置worldpress參考:

Unix socket:server unix:/tmp/php-cgi.socket;這行代碼在Windows中不適用,
因為Windows並不支持Unix sockets。

要更改include fastcgi_params;這行代碼的路徑,
以匹配您的Nginx安裝目錄中fastcgi_params文件的實際路徑。
例如,
如果fastcgi_params位於conf資料夾中,則應該更改為include conf/fastcgi_params;

# Upstream to abstract backend connection(s) for php
upstream php {
        server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:9000;
}

server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

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

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

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                #The following parameter can be also included in fastcgi_params file
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

 

上面php到位+nginx配置完+worldpress就定位

 

STEP.4 MySQL 資料庫

  1. 資料庫名稱
  2. 資料庫使用者名稱
  3. 資料庫密碼
  4. 資料庫主機位址
  5. 資料表前置詞 (用於在單一資料庫中安裝多個 WordPress)

這些資訊會用於建立 wp-config.php 檔案。 
如果因故導致無法自動建立檔案,請不必擔心,
這時只需要將資料庫相關資訊填入網站組態檔案中即可。
安裝人員也可以在文字編輯器中開啟 wp-config-sample.php 並填寫必要的資訊,
然後將檔案另存為 wp-config.php

 

 

載mysql資料庫

https://dev.mysql.com/downloads/file/?id=518834

image

image

image

image

 

image

 

進到安裝位置 bin

進入MySQL Shell

image

退出MySQL的Shell的話,可以使用exit退出

image

 

MySQL shell 裡建一個database 備用:

image

 

STEP.5 運行

啟動PHP CGI服務給nginx使用 :

php-cgi.exe -b 127.0.0.1:9000 -c php.ini

光標在那閃閃閃是正常的

image

 

NGINX啟動:

image

image

 

配置的網址打開看到熟悉的logo

image

輸入前面見的DATABASE名稱

image

安裝時如有下方報錯可能是資料庫還沒建立好

SHOW DATABASES確認一下

無法選取資料庫

可以連線至資料庫伺服器,代表目前的使用者名稱及密碼正確無誤,但無法選取 wp_db 資料庫。

  • 請確認資料庫是否存在。
  • 資料庫使用者 root 是否具備使用 wp_db 資料庫的權限?
  • 在某些系統中,會將使用者名稱設定為資料庫名稱的前置詞,因此資料庫名稱會成為 username_wp_db,或許就是這個原因所造成。

 

 

image

image

 

image

 

 

 

 

錯誤:

進到設定的網址一直跳下載
用無痕開可以正常開啟網頁

image

F12-NetWork 勾選Disable cache
載刷新頁面就能正確進入網頁

F12-NetWork 勾選Disable cache 載刷新頁面就能正確進入網頁

 


 

 

 

 

安裝指南參考:

https://developer.wordpress.org/advanced-administration/before-install/howto-install/

 

arrow
arrow

    MonkeyJ 發表在 痞客邦 留言(0) 人氣()