Win10 64位 Apache 2.4+MySQL 5.7+PHP 7环境搭建

WAMP Architecture Building


相关信息

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


httpd是Apache HTTP Server(阿帕奇网站服务器)的英文简称。

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本身并未提供软件的二进制发行版,而只提供了源代码。独立的提交者们可能提供了二进制程序包以提供便利,但这些程序包并不是发布的可交付使用的产品。
如果你自己不能编译the Apache HTTP Server,你可以通过互联网,从众多可用的二进制分发(网站)获取二进制程序包。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构建,需要安装Microsoft Visual C++ 2015 Redistributable Update 3(vc_redist_x64/86.exe)。
Windows® Visual Studio C++ 2015 亦称 VC14。
Apache 2.4 VC14 Windows Binaries不能在Windows XP和Windows 2003上运行,可以在运行在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

图片.png
  • 选择Download标签,并点击Windows
图片.png
  • 点击MySQL Installer
Paste_Image.png
  • 选择mysql-installer-community-5.7.17.0.msi,并点击Download
图片.png
  • 点击No thanks, just start my download.
图片.png

MySQL Installer 为所需的MySQL软件提供了一种简便的基于向导的安装体验。
MySQL产品见下。

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

图片.png
  • 向下翻页,选择PHP7.0 VC14 x64 Thread Safe,点击Zip下载。
图片.png

非线程安全版本适用于IIS,线程安全版本适用于Apache。推荐使用由Apache Lounge提供的Apache构建,apache.org提供的由于VC版本过于老旧而不推荐使用。

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构建是实验性的,并且不提供64位的整合或大文件支持。
PHP 7 提供全整的64位支持。PHP 7 的 x64构建原始的64位整合,LFS(逻辑文件结构/系统),64位的内存限制及更多。

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/


所需文件总结:

Paste_Image.png

安装与配置

Apache与PHP解压即可,MySQL为图形界面安装。且Apahce与PHP路径有要求。方便起见,建议将三者(即下文的文件夹A、文件夹P和文件夹M)置于同一路径,如下。

4490640-d1b839bd815cb667.png

Apache安装

  • httpd-2.4.25-win64-VC14.zip解压,得到文件夹Apache24、文件-- Win64-2.4.25 VC14 --和文件ReadMe.txt。
4490640-44b800aa3a6ce8de.png

称文件夹Apache24为文件夹A,此文件夹可改名,建议不含中文及空格。

Paste_Image.png

PHP 安装

  • php-7.0.14-Win32-VC14-x64.zip解压到文件夹php7.0.14中。称文件夹php7.0.14为文件夹P,此文件夹可改名,建议不含中文及空格。
4490640-75a50529bfc62659.png

MySQL安装与配置

  • 新建文件夹MySQL,作为MySQL系列产品(如最关键的MySQL Server 5.7)的安装路径。称文件夹MySQL为文件夹M,此文件夹可改名,建议不含中文及空格。
  • 运行mysql-installer-community-5.7.17.0.msi,以下若未说明,按图示点击即可。
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • Documents可选,点击右栏上方MySQL Server 5.7.17 - X64,点击下方Advanced Options,选择MySQL Server组件安装路径和数据存放路径。
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • 其他组件可选安装。
    优先选择64位版本,只有32位版本的(比如MySQL Notifier 1.1)也可以运行。
    MySQL For Excel 要求 Visual Studio Tools for Office 2010已经安装。
    Connecter/Python 2.1 for Python 3.4/3.3/2.7 需要Python 3.4/3.3/2.7已经安装。
    选择完成后点击Next。
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • 安装已经完成,点击Next配置MySQL Server。
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • 配置MySQL Server已经完成,点击Next配置Samples and Examples。
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • MySQL安装与配置全部完成。

启动MySQL服务

  • 控制面板-所有控制面板项-管理工具-服务,启动MySQL57

亦可使用 MySQL Notifier启动MySQL服务

Apache配置

  • 编辑 /apache24/conf/httpd.conf文件
  • 替换默认路径,搜索 c:/Apache24,替换为C:/AMP_DE/Apache24。共有6处,分别位于第37、245、246、362、375、378行,其中375为注释,不需替换。其他5处,如行前有#,应去掉。
    Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
  • 增加PHP7模块的加载支持。在179行的下一行增加两行。
    LoadModule php7_module C:/AMP_DE/php7.0.14/php7apache2_4.dll
    PHPIniDir C:/AMP_DE/php7.0.14
    • 其中第一行最后的路径和文件视自身情况而定,打开文件资源管理器,找到文件夹P,找到php7apacheXXXXX.dll文件。
      Paste_Image.png

      单击选中,按住Alt并双击,打开文件属性
      Paste_Image.png

      复制位置: 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
  • 214行ServerAdmin admin@example.com改为自己的邮箱地址。
  • 221行#ServerName www.example.com:80改为ServerName localhost:80(本地服务器)。
  • 279行DirectoryIndex index.html改为DirectoryIndex index.php index.htm index.html
  • 在418行(原为416行,180行左右增加两行)后,增加一行
    AddType application/x-httpd-php .php .html
  • Apahce配置完成。

Apache服务安装与启动

  • 资源管理器进入C:\AMP_DE\Apache24\bin
    Paste_Image.png
  • 输入命令httpd.exe -k install -n “localhost”,安装名为localhost的Apache服务
    Paste_Image.png

    Errors reported here must be corrected before the service can be started.该行表示,如果有错误,会在该行下方显示,没有显示则成功安装。
  • 启动Apache服务
    命令行输入httpd.exe -k start -n "localhost",启动成功无输出。

  • 停止Apache服务httpd.exe -k stop -n "localhost"
  • 卸载Apache服务(先停止服务)httpd.exe -k uninstall -n "localhost"
    也可通过C:\AMP_DE\Apache24\bin中的ApacheMonitor.exe来启动/停止Apache服务。
    尽量以管理员身份运行各项程序和命令行。

  • 打开浏览器,地址栏输入http://localhost并回车,显示It works!,表明Apache配置成功。

PHP配置

  • 资源管理器进入C:\AMP_DE\php7.0.14,将php.ini-production复制一份,并重命名为php.ini
  • 编辑php.ini
    • 723行; extension_dir = "ext"去掉分号
    • 881行;extension=php_gd2.dll去掉分号
    • 888行;extension=php_mbstring.dll去掉分 号
    • 890行;extension=php_mysqli.dll去掉分号
    • 894行;extension=php_pdo_mysql.dll去掉分号
  • 添加环境变量
    • 控制面板-所有控制面板项-系统-高级系统设置-高级-环境变量-系统变量-Path-编辑
    • 新建-C:\AMP_DE\php7.0.14
    • 新建-C:\AMP_DE\php7.0.14\ext
    • 确定
Paste_Image.png
  • 文件资源管理器进入本地服务器文件根目录(默认为C:\AMP_DE\Apache24\htdocs
  • 新建phpinfo.php文件,文本编辑器打开,输入
    <?php phpinfo(); ?>
    并保存
  • 浏览器地址栏输入http://localhost/phpinfo.php
  • 显示PHP信息,表明PHP配置成功,页面如下。


    Paste_Image.png

测试MySQL与Apache、PHP的连接

  • 运行MySQL 5.7 Command Line Client,输入ROOT密码
    Paste_Image.png
  • 新建数据库testDB CREATE DATABASE testDB;
  • 切换到数据库testDB USE testDB;
  • 新建数据表test_table
    CREATE TABLE test_table ( test_info varchar(30), test_time datetime );
  • 文件资源管理器进入本地服务器文件根目录(默认为C:\AMP_DE\Apache24\htdocs
  • 新建testDB.php文件,文本编辑器打开,输入
    <?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并回车
  • 切换到MySQL窗口,输入SELECT * FROM test_table;并回车
  • 结果显示数据表test_table中有新行,显示It works!及当前时间,表明MySQL与Apache、PHP的连接成功,如下。
    Paste_Image.png

经过Apache、MySQL和PHP的安装、配置与测试,WAMP环境已经成功搭建。

Reference:
http://bbs.qcloud.com/thread-12375-1-1.html
http://blog.csdn.net/tengdazhang770960436/article/details/51374423
MySQL安装程序停止运行

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,012评论 4 359
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,589评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 106,819评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,652评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 51,954评论 3 285
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,381评论 1 210
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,687评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,404评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,082评论 1 238
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,355评论 2 241
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,880评论 1 255
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,249评论 2 250
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,864评论 3 232
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,007评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,760评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,394评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,281评论 2 259

推荐阅读更多精彩内容