之前因為公司網站被植入惡意程式的關係,建置了一個新的網站平臺,並且捨棄 appserv 這類快速建置但僅適用於開發環境的套件,改以手動建置 Apache、MariaDB 以及 PHP,之後並以每半年更新一次的頻率做維護,本篇即為記錄更新 Apache、MariaDB 以及 PHP 這三個程式的步驟。
首先停止 Apache、mysql (MariaDB) 服务。
【更新 PHP – 非线程安全】
- 到 官方网站 下载非线程安全压缩包。
- 解压缩,复制目录到目标位置。
- 将 php.ini-production 修改为 php.ini,使用 WinMerge 对比旧版 php.ini。
- 如果 php 目录名称与原名称不同,開啟 Apache 的 httpd.conf ,修改以下内容:
FcgidInitialEnv PHPRC "D:/Web/php-7.4.6" # 讓 FastCGI 知道 php.ini 所在目錄。 FcgidWrapper "D:/Web/php-7.4.6/php-cgi.exe" .php # FastCGI 設定。
【更新 PHP – 线程安全】
- 到 官方网站 下载线程安全压缩包。
- 解压缩,复制目录到目标位置。
- 将 php.ini-production 修改为 php.ini,使用 WinMerge 对比旧版 php.ini。
- 如果 php 目录名称与原名称不同,開啟 Apache 的 httpd.conf ,修改以下内容:
PHPIniDir "D:\Web\php-7.1.5" # 指定 php.ini 存放的資料夾位置。 LoadModule php7_module "D:\Web\php-7.1.5\php7apache2_4.dll" # 載入 php 的模組。
【更新 Apache】
- 到 Apache Haus Download the compressed file (x64)。
- 解压缩,Copy the Apache24 directory to the desired location。
- Open httpd.conf,Use WinMerge to compare the old httpd.conf。
- Copy the data from the original Apache24/htdocs directory to the new Apache24/htdocs。
- Compare the old and new Apache24/bin directories,Copy the custom lib***.dll files,To the new Apache24/bin,Such as libsasl.dll、libssh2。
- If PHP uses Non Thread Safe,Copy mod_fcgid.so from the original Apache24/Modules,To the new Apache's Apache24/Modules。
- 若還有其他 SSL 憑證或修改過的檔案,也記得搬移。
- 雙擊 httpd.exe,如果出现错误,逐一修复,沒問題後再改以服務啟動。
【更新 MariaDB】
- 到 MariaDB 官網下載 64bit msi 檔。
- 停止 mysql 服務,執行 .msi 檔更新即可。
【更新 phpMyAdmin】
- 到 phpMyAdmin Download the compressed file,解压缩,複製到 Apache24\htdocs。
- 将 config.sample.inc.php 重命名为 config.inc.php,用 WinMerge 比對舊版 config.inc.php
【相關連結】








留下回复