WAMP Architecture Building
相關(guān)信息
Windows 10 Enterprise Version 1607 64-bit | i7-4710HQ | 8G
軟件版本及獲取
Apache 2.4.25 win64 | MySQL Server 5.7.17 win64 | PHP 7.0 x64 Thread Safe
Apache 2.4.25 win64
- Apache HTTP Server(阿帕奇網(wǎng)站服務(wù)器)http://httpd.apache.org/
圖片.png -
點(diǎn)擊Download,并向上翻頁(yè)
圖片.png - 可根據(jù)需要選擇網(wǎng)站鏡像
-
點(diǎn)擊Apache HTTP Server 2.4.25欄下的Files for Microsoft Windows
圖片.png - 點(diǎn)擊Apache Lounge,轉(zhuǎn)到https://www.apachelounge.com/download/
圖片.png - Apache 2.4 binaries VC14
Apache 2.4.25 Win64
點(diǎn)擊httpd-2.4.25-win64-VC14.zip下載
*下載地址
https://www.apachelounge.com/download/VC14/binaries/httpd-2.4.25-win64-VC14.zip
httpd是Apache HTTP Server(阿帕奇網(wǎng)站服務(wù)器)的英文簡(jiǎn)稱(chēng)。
The Apache HTTP Server ("httpd") was launched in 1995 and it has been the most popular web server on the Internet since April 1996. It has celebrated its 20th birthday as a project in February 2015.
From: http://httpd.apache.org/
The Apache HTTP Server Project本身并未提供軟件的二進(jìn)制發(fā)行版,而只提供了源代碼。獨(dú)立的提交者們可能提供了二進(jìn)制程序包以提供便利,但這些程序包并不是發(fā)布的可交付使用的產(chǎn)品。
如果你自己不能編譯the Apache HTTP Server,你可以通過(guò)互聯(lián)網(wǎng),從眾多可用的二進(jìn)制分發(fā)(網(wǎng)站)獲取二進(jìn)制程序包。Apache Lounge 為其一。
The Apache HTTP Server Project itself does not provide binary releases of software, only source code. Individual committers may provide binary packages as a convenience, but it is not a release deliverable.
If you cannot compile the Apache HTTP Server yourself, you can obtain a binary package from numerous binary distributions available on the Internet.
From: http://httpd.apache.org/docs/current/platform/windows.html#down
Apache 2.4 VC14 Windows Binaries and Modules利用VC14構(gòu)建,需要安裝Microsoft Visual C++ 2015 Redistributable Update 3(vc_redist_x64/86.exe)。
Windows? Visual Studio C++ 2015 亦稱(chēng) VC14。
Apache 2.4 VC14 Windows Binaries不能在Windows XP和Windows 2003上運(yùn)行,可以在運(yùn)行在7 SP1, Vista SP2, 8 / 8.1, 10, Server 2008 SP2 / R2 SP1, Server 2012 / R2, Server 2016上。
Build with the latest Windows? Visual Studio C++ 2015 aka VC14.
The binaries below do not run on XP and 2003. Runs on: 7 SP1, Vista SP2, 8 / 8.1, 10, Server 2008 SP2 / R2 SP1, Server 2012 / R2, Server 2016.
Be sure that you have installed the latest C++ Redistributable Visual Studio 2015 : vc_redist_x64/86.exe.
From: https://www.apachelounge.com/download/
MySQL Server 5.7.17 win64
- 進(jìn)入https://www.mysql.com/
- 選擇Download標(biāo)簽,并點(diǎn)擊Windows
- 點(diǎn)擊MySQL Installer
- 選擇mysql-installer-community-5.7.17.0.msi,并點(diǎn)擊Download
- 點(diǎn)擊No thanks, just start my download.
MySQL Installer 為所需的MySQL軟件提供了一種簡(jiǎn)便的基于向?qū)У陌惭b體驗(yàn)。
MySQL產(chǎn)品見(jiàn)下。
MySQL Installer provides an easy to use, wizard-based installation experience for all your MySQL software needs. Included in the product are the latest versions of:
MySQL Server
MySQL Connectors
MySQL Workbench and sample models
Sample Databases
MySQL for Excel
MySQL Notifier
MySQL for Visual Studio
Documentation
From: https://dev.mysql.com/downloads/installer/
mysql-installer-web-community是MySQL在線安裝工具,mysql-installer-community是離線安裝工具。
Choosing the right file:
If you have an online connection while running the MySQL Installer, choose the mysql-installer-web-community file.
If you do NOT have an online connection while running the MySQL Installer, choose the mysql-installer-community file.
From: https://dev.mysql.com/downloads/installer/
雖然MySQL Installer是32位的,但可以安裝32位和64位的MySQL文件。
Note: MySQL Installer is 32 bit, but will install both 32 bit and 64 bit binaries.
From: https://dev.mysql.com/downloads/installer/
PHP 7.0.14(已更新至7.0.15) win64
- 進(jìn)入http://windows.php.net/ ,點(diǎn)擊Download
- 向下翻頁(yè),選擇PHP7.0 VC14 x64 Thread Safe,點(diǎn)擊Zip下載。
非線程安全版本適用于IIS,線程安全版本適用于Apache。推薦使用由Apache Lounge提供的Apache構(gòu)建,apache.org提供的由于VC版本過(guò)于老舊而不推薦使用。
IIS
If you are using PHP as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP.
Apache
Please use the Apache builds provided by Apache Lounge. They provide VC9, VC11 and VC14 builds of Apache for x86 and x64. We use their binaries to build the Apache SAPIs.
If you are using PHP as module with Apache builds from apache.org (not recommended) you need to use the older VC6 versions of PHP compiled with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of PHP with the apache.org binaries.
With Apache you have to use the Thread Safe (TS) versions of PHP.
From: http://windows.php.net/download/
用于 Windows 的 PHP 5 的 x64構(gòu)建是實(shí)驗(yàn)性的,并且不提供64位的整合或大文件支持。
PHP 7 提供全整的64位支持。PHP 7 的 x64構(gòu)建原始的64位整合,LFS(邏輯文件結(jié)構(gòu)/系統(tǒng)),64位的內(nèi)存限制及更多。
x86_64 Builds
The x64 builds of PHP 5 for Windows are experimental, and do not provide 64-bit integer or large file support.
PHP 7 provides full 64-bit support. The x64 builds of PHP 7 support native 64-bit integers, LFS, 64-bit memory_limit and much more.
From: http://windows.php.net/download/
所需文件總結(jié):
安裝與配置
Apache與PHP解壓即可,MySQL為圖形界面安裝。且Apahce與PHP路徑有要求。方便起見(jiàn),建議將三者(即下文的文件夾A、文件夾P和文件夾M)置于同一路徑,如下。
Apache安裝
- httpd-2.4.25-win64-VC14.zip解壓,得到文件夾Apache24、文件-- Win64-2.4.25 VC14 --和文件ReadMe.txt。
稱(chēng)文件夾Apache24為文件夾A,此文件夾可改名,建議不含中文及空格。
PHP 安裝
- php-7.0.14-Win32-VC14-x64.zip解壓到文件夾php7.0.14中。稱(chēng)文件夾php7.0.14為文件夾P,此文件夾可改名,建議不含中文及空格。
MySQL安裝與配置
- 新建文件夾MySQL,作為MySQL系列產(chǎn)品(如最關(guān)鍵的MySQL Server 5.7)的安裝路徑。稱(chēng)文件夾MySQL為文件夾M,此文件夾可改名,建議不含中文及空格。
- 運(yùn)行mysql-installer-community-5.7.17.0.msi,以下若未說(shuō)明,按圖示點(diǎn)擊即可。
- Documents可選,點(diǎn)擊右欄上方MySQL Server 5.7.17 - X64,點(diǎn)擊下方Advanced Options,選擇MySQL Server組件安裝路徑和數(shù)據(jù)存放路徑。
- 其他組件可選安裝。
優(yōu)先選擇64位版本,只有32位版本的(比如MySQL Notifier 1.1)也可以運(yùn)行。
MySQL For Excel 要求 Visual Studio Tools for Office 2010已經(jīng)安裝。
Connecter/Python 2.1 for Python 3.4/3.3/2.7 需要Python 3.4/3.3/2.7已經(jīng)安裝。
選擇完成后點(diǎn)擊Next。
- 安裝已經(jīng)完成,點(diǎn)擊Next配置MySQL Server。
- 配置MySQL Server已經(jīng)完成,點(diǎn)擊Next配置Samples and Examples。
- MySQL安裝與配置全部完成。
啟動(dòng)MySQL服務(wù)
-
控制面板
-所有控制面板項(xiàng)
-管理工具
-服務(wù)
,啟動(dòng)MySQL57
亦可使用 MySQL Notifier啟動(dòng)MySQL服務(wù)
Apache配置
- 編輯 /apache24/conf/httpd.conf文件
- 替換默認(rèn)路徑,搜索
c:/Apache24
,替換為C:/AMP_DE/Apache24
。共有6處,分別位于第37、245、246、362、375、378行,其中375為注釋?zhuān)恍杼鎿Q。其他5處,如行前有#
,應(yīng)去掉。
Paste_Image.png
- 增加PHP7模塊的加載支持。在179行的下一行增加兩行。
LoadModule php7_module C:/AMP_DE/php7.0.14/php7apache2_4.dll
PHPIniDir C:/AMP_DE/php7.0.14
- 其中第一行最后的路徑和文件視自身情況而定,打開(kāi)文件資源管理器,找到文件夾P,找到
php7apacheXXXXX.dll
文件。
Paste_Image.png
單擊選中,按住Alt
并雙擊,打開(kāi)文件屬性
Paste_Image.png
復(fù)制位置:C:\AMP_DE\php7.0.14
和文件名php7apache2_4.dll
,連接成為C:\AMP_DE\php7.0.14\php7apache2_4.dll
,并把/
換為/
,最后得到LoadModule php7_module C:/AMP_DE/php7.0.14/php7apache2_4.dll
。 - 其中第二行最后的路徑即為文件夾P的路徑,該行指定了
php.ini
的路徑。
Paste_Image.png
- 其中第一行最后的路徑和文件視自身情況而定,打開(kāi)文件資源管理器,找到文件夾P,找到
- 214行
ServerAdmin admin@example.com
改為自己的郵箱地址。 - 221行
#ServerName www.example.com:80
改為ServerName localhost:80
(本地服務(wù)器)。 - 279行
DirectoryIndex index.html
改為DirectoryIndex index.php index.htm index.html
。 - 在418行(原為416行,180行左右增加兩行)后,增加一行
AddType application/x-httpd-php .php .html
- Apahce配置完成。
Apache服務(wù)安裝與啟動(dòng)
- 資源管理器進(jìn)入
C:\AMP_DE\Apache24\bin
Paste_Image.png - 輸入命令
httpd.exe -k install -n “l(fā)ocalhost”
,安裝名為localhost
的Apache服務(wù)
Paste_Image.png
Errors reported here must be corrected before the service can be started.
該行表示,如果有錯(cuò)誤,會(huì)在該行下方顯示,沒(méi)有顯示則成功安裝。 - 啟動(dòng)Apache服務(wù)
命令行輸入httpd.exe -k start -n "localhost"
,啟動(dòng)成功無(wú)輸出。
- 停止Apache服務(wù)
httpd.exe -k stop -n "localhost"
- 卸載Apache服務(wù)(先停止服務(wù))
httpd.exe -k uninstall -n "localhost"
也可通過(guò)C:\AMP_DE\Apache24\bin
中的ApacheMonitor.exe
來(lái)啟動(dòng)/停止Apache
服務(wù)。
盡量以管理員身份運(yùn)行各項(xiàng)程序和命令行。
- 打開(kāi)瀏覽器,地址欄輸入
http://localhost
并回車(chē),顯示It works!
,表明Apache配置成功。
PHP配置
- 資源管理器進(jìn)入
C:\AMP_DE\php7.0.14
,將php.ini-production
復(fù)制一份,并重命名為php.ini
。 - 編輯
php.ini
- 723行
; extension_dir = "ext"
去掉分號(hào) - 881行
;extension=php_gd2.dll
去掉分號(hào) - 888行
;extension=php_mbstring.dll
去掉分 號(hào) - 890行
;extension=php_mysqli.dll
去掉分號(hào) - 894行
;extension=php_pdo_mysql.dll
去掉分號(hào)
- 723行
- 添加環(huán)境變量
-
控制面板
-所有控制面板項(xiàng)
-系統(tǒng)
-高級(jí)系統(tǒng)設(shè)置
-高級(jí)
-環(huán)境變量
-系統(tǒng)變量
-Path
-編輯
-
新建
-C:\AMP_DE\php7.0.14
-
新建
-C:\AMP_DE\php7.0.14\ext
確定
-
- 文件資源管理器進(jìn)入本地服務(wù)器文件根目錄(默認(rèn)為
C:\AMP_DE\Apache24\htdocs
) - 新建
phpinfo.php
文件,文本編輯器打開(kāi),輸入
<?php phpinfo(); ?>
并保存 - 瀏覽器地址欄輸入
http://localhost/phpinfo.php
-
顯示PHP信息,表明PHP配置成功,頁(yè)面如下。
Paste_Image.png
測(cè)試MySQL與Apache、PHP的連接
- 運(yùn)行
MySQL 5.7 Command Line Client
,輸入ROOT密碼
Paste_Image.png - 新建數(shù)據(jù)庫(kù)testDB
CREATE DATABASE testDB;
- 切換到數(shù)據(jù)庫(kù)testDB
USE testDB;
- 新建數(shù)據(jù)表test_table
CREATE TABLE test_table ( test_info varchar(30), test_time datetime );
- 文件資源管理器進(jìn)入本地服務(wù)器文件根目錄(默認(rèn)為
C:\AMP_DE\Apache24\htdocs
) - 新建
testDB.php
文件,文本編輯器打開(kāi),輸入
<?php
$connection = mysqli_connect('localhost','root','password','testDB')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO test_table (".
"test_info,test_time)".
"VALUES (".
"'It works!',NOW())";
$result = mysqli_query($connection,$query)
or die('Error querying database.');
mysqli_close($connection);
?>
其中的password
改為自己的ROOT賬戶密碼,保存并退出 - 瀏覽器地址欄輸入
http://localhost/testDB.php
并回車(chē) - 切換到MySQL窗口,輸入
SELECT * FROM test_table;
并回車(chē) - 結(jié)果顯示數(shù)據(jù)表test_table中有新行,顯示
It works!
及當(dāng)前時(shí)間,表明MySQL與Apache、PHP的連接成功,如下。
Paste_Image.png
經(jīng)過(guò)Apache、MySQL和PHP的安裝、配置與測(cè)試,WAMP環(huán)境已經(jīng)成功搭建。
Reference:
http://bbs.qcloud.com/thread-12375-1-1.html
http://blog.csdn.net/tengdazhang770960436/article/details/51374423
MySQL安裝程序停止運(yùn)行