下载网址:
PHP:http://windows.php.net/download 版本: php-5.6.31-Win32-VC11-x64.zip
Apache:https://www.apachehaus.com/cgi-bin/download.plx 版本: httpd-2.4.27-x64-vc11.zip
MySQL:http://dev.mysql.com/downloads/mysql/5.7.html 版本: mysql-5.7.19-winx64.zip
phpmyadmin:https://www.phpmyadmin.net/downloads/ 版本:phpMyAdmin-4.7.4-all-languages.zip
1.Apache配置
将下载的apache压缩包解压到E:\ampServer,在E:\ampServer\Apache\conf文件夹中找到httpd.conf,打开
(1)找到Define SRVROOT 修改为Apache解压存放的路径,例如:Define SRVROOT "E:/ampServer/Apache"
(2)将DocumentRoot的值改为你的网站根目录(网站根目录需自己创建),将<Directory "c:/XXX">这个目录也要改为网站根目录
DocumentRoot "E:/www" <Directory "E:/www">
(3)将ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"改为apache根目录下的cgi-bin文件夹,紧随ScriptAlias的几行中有个<Directory "c:/Apache24/cgi-bin">,将其也改为apache根目录下的cgi-bin文件夹
ScriptAlias /cgi-bin/ "E:/ampServer/Apache/cgi-bin/" <Directory "E:/ampServer/Apache/cgi-bin">
(4)在E:\ampServer\Apache\bin下,按住Shift键,点击右键,选择在此处打开命令窗口,输入:httpd.exe -k install -n apache 然后回车,服务安装成功。
(5)打开E:\ampServer\Apache\bin\ApacheMonitor.exe,启动apache服务
2.PHP配置和Apache整合
将下载的php压缩包解压到E:\ampServer\Php5.6下
(1)找到E:\ampServer\Php5.6\php.ini-development文件,复制一份后重命名为php.ini,打开后找到extension_dir = “ext”,如下修改。
extension_dir = "E:/ampServer/Php5.6/ext"
(2)找到E:\ampServer\Apache\conf\httpd.conf文件,打开后在最后加入代码:
LoadModule php5_module "E:/ampServer/Php5.6/php5apache2_4.dll" AddHandler application/x-httpd-php .php # configure the path to php.ini PHPIniDir "E:/ampServer/Php5.6"
(3)在E:\www目录下,新建test.php文件内容如下:
<?php phpinfo(); ?>
然后,在浏览器访问http://localhost/test.php 若如图显示即为php安装整合成功。
3.PHP和MYSQL的整合
MYSQL的安装教程请浏览之前写的博客教程 https://www.cnblogs.com/liuzhenping/p/7441564.html
(1)找到E:\ampServer\Php5.6\php.ini文件,打开后去掉下面几句前面的” ; “支持mysql
extension=php_fileinfo.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll extension=php_curl.dll extension=php_gd2.dll extension=php_pdo_odbc.dll
(2)在E:\www目录下,新建conn.php文件内容如下:
<?php $con = mysqli_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); }else{ echo "success"; } ?>
然后,在浏览器访问http://localhost/conn.php 若显示“success”即为mysql安装整合成功。
4.phpMyAdmin的安装和配置
将下载的phpMyAdmin压缩包解压到之前设置的网站根目录下E:\www
(1)找到E:\www\phpMyAdmin\libraries\config.default.php文件,打开后配置$cfg['Servers'][$i]['password'] = '新密码'
(2)在浏览器访问http://localhost/phpMyAdmin/index.php进入登录页面输入用户名:root密码:设置的新密码(数据库密码)登录即可。