一、下载搭建环境所需软件,安装顺序也要按照列表顺序安装
1.Vc2015(根据需要安装Vc2012或者Vc2015)
Vc2015:https://www.microsoft.com/zh-CN/download/details.aspx?id=48145
Vc2012:http://www.microsoft.com/zh-CN/download/details.aspx?id=30679
2. Apache2.4:http://www.apachelounge.com/download
3. PHP:http://windows.php.net/download (下载线程安全版的,即Thread Safe)
4. Mysql:https://www.mysql.com/downloads
二、安装Vc2012或者Vc2015
安装Vc2012(2015)只需要双击软件,按照提示向下执行即可。
Apache为vc14版本的,需要先安装Visual C++ Redistributable for Visual Studio 2015运行库;
Apache为vc11版本的,需要先安装Visual C++ Redistributable for Visual Studio 2012运行库
三、安装并配置Apache
Apache版本:Apache2.4.16
解压目录:D:PHPApache24
1.下载回来的是压缩文件,解压好放到要安装的位置D:PHPApache24。
2.打开Apache24conf下httpd.conf 文件,修改以下关键位置:
ServerRoot “D:/PHP/Apache24”(即Apache的安装位置);
DocumentRoot “D:/PHP/Apache24/htdocs” (Apache默认的网站根目录,可根据自己的 喜好调整)
修改根目录的选项:
修改前
<Directory "c:/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride null
Require all granted
</Directory>
修改后
<Directory "D:/PHP/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#ServerName www.example.com:80 => ServerName 127.0.0.1:80 (去掉前面的#)
DirectoryIndex index.html => DirectoryIndex index.html index.php index.htm (我们添加了 index.php index.htm)
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"=>ScriptAlias /cgi-bin/ "d:/PHP/Apache24/cgi-bin/"
<Directory "c:/Apache24/cgi-bin"> => <Directory "d:/PHP/Apache24/cgi-bin">
3.打开cmd,并输入以下命令行
d: 回车
cd PHPApache24in 回车 调到Apache24中bin目录下
httpd 回车 如果没有任何提示表示启动成功
如果想在服务中添加Apache24,则以管理员身份 运行cmd,并输入以下命令
d: 回车
cd PHPApache24in 回车
httpd.exe -k install 回车
4.打开浏览器输入“http://localhost/”进行测试,显示”It works!”证明配置成功。
四、安装并配置PHP
PHP版本:php5.6.14
安装目录:D:PHPphp56
安装php5.6.14需要先安装Visual C++ Redistributable for Visual Studio 2012运行库
1.下载回来的是解压文件,解压好放到要安装的位置D:PHPphp7;
2.复制份php.ini-development,并改名为php.ini
3.让Apache24加载PHP模块,打开Apache24confhttpd.conf,在最后加上
LoadModule php7_module "D:/PHP/php7/php5apache2_4.dll"
AddType application/x-httpd-php .php .html .htm
PHPIniDir "D:/PHP/php7"
(告诉apache php.ini的位置)
4.开启几个常用php扩展(根据需求自行选择),打开php.ini文件,修改以下内容:
;extension_dir = "ext" => extension_dir = "D:/PHP/php56/ext"(去掉分号)
;extension=php_mbstring.dll => extension=php_mbstring.dll
;extension=php_mysql.dll => extension=php_mysql.dll
;extension=php_mysqli.dll => extension=php_mysqli.dll
注意:win下要开启curl扩展,libeay32.dll和ssleay32.dll必须放到PATH环境变量包含的目录下
5.重启Apache服务器
五、安装Mysql
Mysql版本:mysql5.6.27
点击文件直接安装即可。