首先下载所需软件:
Vc2015:
Vc2012:
Apache2.4:
PHP: (下载线程安全版的,即 Thread Safe)
Mysql:https://www.mysql.com/downloads
安装并配置 Apache
Apache 版本:Apache2.4.16
解压目录:D:\PHP\Apache24
安装 Apache2.4.16,vc14 版本的, 需要先安装 Visual C++ Redistributable for Visual Studio 2015 运行库; vc11 版本的, 需要先安装 Visual C++ Redistributable for Visual Studio 2012 运行库
(1). 下载回来的是解压文件,解压好放到要安装的位置。
(2). 打开 Apache24\conf 下 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 PHP\Apache24\bin 调到 Apache24 中 bin 目录下
httpd 回车 如果没有任何提示表示启动成功
如果想在服务中添加 Apache24,则以管理员身份 运行 cmd, 并输入以下命令
d: 回车
cd PHP\Apache24\bin 回车
httpd.exe -k install 回车
(4). 打开浏览器输入 "http://localhost/" 进行测试,显示 "It works!" 证明配置成功。
安装并配置 PHP
PHP 版本:php5.6.14
安装目录:D:\PHP\php56
安装 php5.6.14 需要先安装 Visual C++ Redistributable for Visual Studio 2012 运行库
(1). 下载回来的是解压文件,解压好放到要安装的位置;
(2). 复制份 php.ini-development,并改名为 php.ini
(3). 让 Apache24 加载 PHP 模块,打开 Apache24\conf\httpd.conf,在最后加上
LoadModule php5_module "D:/PHP/php56/php5apache2_4.dll"
AddType application/x-httpd-php .php .html .htm
PHPIniDir "D:/PHP/php56" (告诉 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
点击文件直接安装即可。
来源: