WAMP x64 安裝

  • Post author:
  • 帖子最後修改:2023 年 1 月 2 日

Windows x64之下架設Apache+MySQL+PHP+wordpress

Visual C++套件。 All VC Redistribuable Packages (x86_x64) (32 & 64bits)

NotePad++編輯器安裝。Installer

WampServer 安裝包安裝WAMP3.2 X64

MySQL Workbench。8.0.23-winx64

1.安裝先期作業
Visual C++套件
WampServer使用 Visual c++ redistributable packs 編譯, 並需要有這些套件才能執行. 如果沒有VC這些套件, 就 會出現如MSVCR120.dll, VCRUNTIME140.dll之類的錯誤.

假如系統有安裝Visual Studio 2017/2019的話, 這些套件都已安裝完成, 所以不會出現上面的錯誤.

all_vc_redist4程式, 可檢查系統欠缺什麼軟体all_vc_redist_x86_x64

2.D槽建置以下資料夾↓ D:\server D:\server\mysql D:\server\wordpress

3.安裝NotePad++ 取代記事本修改設定方便。 安裝MySQL Workbench(操作資料庫),不要使用php admin。

4.WampServer 安裝。(安裝前無Visual Studio 2017/2019,請先安裝Visual C++套件) 安裝時到下圖時選擇Mysql 8.0.21

5.WampServer 安裝後選擇開啟的瀏覽器(chrome)→選是。(我兩台windows路徑不一樣) 資料夾路徑為 C:\Program Files (x86)\Google\Chrome\Application\chrome.exe 或 C:\Program Files\Google\Chrome\Application\chrome.exe 詳下圖

6.WampServer 安裝後選擇開啟的文件夾(Notepad++)→選是 資料夾路徑為 C:\Program Files\Notepad++\Notepad++.exe 詳下圖

7.桌面開啟Wampserver64 更改為中文介面 右下角 右鍵點選Wampserver64 詳下圖

8.變更資料儲存目錄 更改MySQL資料儲存目錄 請於工作列右下角綠色WampServer圖示點選一下, 選Stop all server 停止所有服務 一口氣開啟需要被更改的文件,WampServer圖示點選一下 Wampserver64\mysql\mi.ini , Wampserver64\apache\httpd.conf , Wampserver64\apache\httpd-vhosts.conf 詳下圖

9.更改MySQL資料儲存目錄 右下角圖示Wampserver64\mysql\mi.ini 更改如下設定

datadir="D:/server/mysql";#更改目錄注意 / 方向
innodb_flush_log_at_trx_commit = 0 #加速效能很有效
max_allowed_packet = 500M #查詢過久斷線解決方式(Lost connection while query)
innodb_buffer_pool_size=2048M #緩衝區, 可大輻減少磁碟負載, 而且可加速查詢效能, 尤其是在select count(*)

10.儲存後, 停止所有伺服器, 然後把 C:\wamp64\bin\mysql\mysql8.0.21\data, 將data之下的所有檔案 copy 到 D:\server\mysql之下. 最後重新啟動所有伺服器 。如下詳圖

11.資料庫設定路徑 mysql的登入程式位於 C:\wamp64\bin\mysql\mysql8.0.21\bin, 請於開始按右鍵/系統/系統資訊/進階系統設定/環境變數/系統變數區塊選取 path, 按下編輯再新增, 把上面那串路徑貼上 詳下圖

12.登入資料庫 在Dos模式下輸入

mysql -u root

root登入, 不用密碼, 但僅能在本機登入, 登入後再新增帳號及權限(以下紅色為要輸入字元)

mysql> use mysql;
Database changed
mysql> create user '你的帳號'@'%' identified by '你的密碼';
Query OK, 0 rows affected (0.03 sec)
mysql> grant all privileges on *.* to '你的帳號'@'%';
Query OK, 0 rows affected (0.03 sec)
mysql>exit;

exit登出資料庫後, 再使用新帳號登入測試. 請依如下紅色的指令測試DOS登入Mysql看看

C:\Users\student>mysql -u 你的帳號 -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.21 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.08 sec)

mysql>

13.開啟MySQL Workbench 建立 wordpress 資料夾 按下圖順序操作

這邊先把12項的帳密建立進去如下圖 Connection Name: localhost Hostname: localhost username:輸入第12項建立帳密資訊

MySQL Workbench建立 wordpress 資料夾 如下圖順序操作

  1. create a new schema in the connected server(在連接的服務器中創建一個新的架構)。
  2. name: wordpress
  3. Charset(字元集):utf8
  4. Collation(核對): utf8_unicode_ci
  5. 5.Apply
  • MySQL Workbench 資料庫備份
  • 進DOS 到你要的資料夾
  • 代碼自譯,把mysql傾倒 從 你的帳號 輸入密碼 例程 是 wordpress資料庫 存到 wordpress.sql的檔案
  • 開啟Dos 進入到你要放置備份檔的目錄下輸入以下代碼
cd c:\你的資料夾
mysqldump -u 你的帳號 -p --routines wordpress > wordpress.sql
dir

MySQL遠端備份

mysqldump -h 你的IP -u 你的帳號 -p --routines wordpress > wordpress.sql
  • 刪除資料庫還原
  • 刪除後要還原時須在你的MySQL先重建一個空的資料庫(重建請往上2圖看)
  • 下圖是刪除的圖片 在wordpress 資料庫案右鍵
  • MySQL Workbench 資料庫還原 (資料庫裡要有你重建的資料庫)
  • 代碼自譯,把mysql 從 你的帳號 輸入密碼 默認字元utf8 wordpress.sql的檔案 放回 wordpress 資料庫
  • 開啟Dos 進入到你要放置還原檔的目錄下輸入以下代碼(記得要在你放wordpress.sql的資料夾下執行)
mysql -u 你的帳號 -p --default-character-set=utf8 wordpress < wordpress.sql

14.Apache 網頁目錄設定

  • 在右下角圖示開啟Wampserver64/apache/httpd.conf, 搜詢DocumentRoot,
  • Apache 的網站根目錄我們是設在D:/server/wordpress
  • #字號為註解為不破壞帶原代碼我們先在原代碼前加上#,在複製到他下一行進行更改
  • 紅色為要修改,並將+Indexes刪除, 然後加入 Require all granted
DocumentRoot "D:/server/wordpress"
<Directory "D:/server/wordpress">
     #Options +Indexes +FollowSymLinks +Multiviews     
     Options +FollowSymLinks +Multiviews     
     AllowOverride all     
     #Require local     
     Require all granted 
</Directory>
  • apache/httpd-vhosts.conf修改成如下
  • #字號為註解為不破壞帶原代碼我們先在原代碼前加上#,在複製到他下一行進行更改
<VirtualHost *:80>
#ServerName leojsp.kozow.com (放置自己網址的地方) #←為註解
#ServerAlias leojsp.kozow.com (放置自己網址的地方)
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "D:/server/wordpress"
  <Directory "D:/server/wordpress">
#Options +Indexes +Includes +FollowSymLinks +MultiViews
  Options +Includes +FollowSymLinks +MultiViews
  AllowOverride All
#Require local
Require all granted

改好儲存後, 重新啟動所有伺服器

測試

致於Apache/PHP到底有沒有真的成功運轉呢, 請於 d:\server\wordpress 之下, 編寫 info.php檔案, 內容如下

<?php
    phpinfo();
?>

15.wordpress 安裝 把下載好的檔案放入 D:\server\wordpress

打開Google Chrome 網址列打上 localhost 案開始安裝

  • 再來填寫下圖資料 (這裡是要填寫MySQL資料庫的訊息)
  • 資料庫名稱:wordpress
  • 使用者名稱:你的MySQL資料庫帳號
  • 密碼:你的MySQL資料庫密碼
  • 資料庫主機位置:localhost

傳送無誤後會得到下圖再繼續安裝

安裝網站所需資訊(這是要登入網站的資料)填寫後安裝

再來安裝布景主題 外觀→佈景主題→安裝佈景主題

收尋Ribosome 安裝後啟用

  • 把申請好的網址放到網站 設定→一般
  • wordprsee 位址(網址):http://xxx.xx.xx←(你的網址)
  • 網站位址(網址):http://xxx.xx.xx←(你的網址)
  • 輸入完後記得在最下方儲存設定 (在apache/httpd-vhosts.conf也要記得修改上14項)
  • 修改完右下角Wampserver64/重啟所有服務

16.開機自動啟動Apache/MySQL 服務程式
重新開機後, WAMP並不會自動啟動, 需登入系統後按下桌面的wampserver64管理程式才會啟動Service. 所以如果希望電腦開機完成後就自動啟動Apache/MySQL Service, 請先使用系統管理者身分進入DOS, 然後執行如下指令

sc config wampapache64 start= auto
sc config wampmysqld64 start= auto

如此就可以把服務設定為開機自動啟動,特別注意 start=(空格)auto

17.新增 Apache MySQL 安全性規則

開啟後點選 輸入規則→新增規則 如下圖

新增輸入規則精靈 apache:80 MySQL:3306
選擇 連接埠→下一步

apache:80 MySQL:3306

下圖選允許→下一步

下圖全套用→下一步

打入名稱→按完成