安装64位最新版服务软件
PHP7下载链接
mysql-5.7下载链接
apache-httpd-2.4
记得新版php跟apache需要VC14平台,mysql需要.NET4平台的支持,要先安装好这两个平台才能开始安装我们的主角。
新装系统的电脑先等杀毒软件将各路补丁打全,再操作,不然安装.NET4平台会出现安装阻塞,不能正常安装,等补丁安装好了就可以了
安装好后,我们开始配置apache
- 将apache软件安装路径下的conf/里头的httpd.conf文件内的ServerRoot修改为当前apache的安装路径
ServerRoot "D:/apache-httpd-2.4.17-win64-VC14/Apache24"
- 将DocumentRoot还有Directory的路径修改为你想要放网站的路径,默认是apache路径下的htdocs这个文件夹,DirectoryIndex这个是路径索引,我们要添加index.php作为默认索引文件,这样访问网站路径的时候,apache自动导航请求到目录下的index.php文件
DocumentRoot "D:/apache-httpd-2.4.17-win64-VC14/Apache24/htdocs"
<Directory "D:/apache-httpd-2.4.17-win64-VC14/Apache24/htdocs">
文件配置完成,接下来我们要测试下httpd.exe是否能正常工作,打开cmd进入bin/路径,打出httpd然后回车,到浏览器上输入localhost回车访问测试下,正常工作的话,会显示it works,没有问题的话,接下来就是将其加入系统服务,httpd -k install -n "ApacheServer"
这里的ApacheServer名字可以自己命名
接下来我们配置php
将php解压路径下的php.ini-development拷贝一份,并重命名为php.ini,然后去刚刚那个apache的配置文件末尾添加php的支持,记得路径要修改成你们存放的路径
# php7 support
LoadModule php7_module "D:/php-7.1.4-Win32-VC14-x64/php7apache2_4.dll"
LoadModule php7_module "D:/php-7.1.4-Win32-VC14-x64/php7phpdbg.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "D:/php-7.1.4-Win32-VC14-x64"
接下来 按win菜单按钮
- 计算机
- 右键【管理】
- 服务和应用程序
- 服务
- 选择刚刚我添加进系统服务的
ApacheServer
,重启
然后到DocumentRoot
路径下添加index.php文件,内容如下
<?php
phpinfo();
?>
// 切换到浏览器,访问localhost/index.php正常的话会输出php的详细配置信息
最后我们配置mysql
我们先到刚刚php.ini的配置文件里修改下配置
...
extension_dir = "D:/php-7.1.4-Win32-VC14-x64/ext"
...
...
extension=php_pdo_mysql.dll //# 将;去掉
我们安装mysql,记得我们如果没有特别需要,直接选择安装server版本就可以,反正客户端,我们待会可以使用phpmyadmin
这个利器代劳!没必要安装那么多的东西,设置好mysql的账户密码,我们去下载个phpmyadmin
的zip包,解压到DocumentRoot
路径下,修改主路径下的config.inc.php
文件
// 写入账户名密码
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '********';
// 切换到浏览器,访问localhost/phpmyadmin正常的话会出现mysql数据库的管理界面,里面的功能绝对满足日常需求
然后这边有一个小坑,就是我之前使用的是旧版的php,使用mysql_开头的函数要修改成mysqli_,不然会提醒undefine function,然后默认mysql的数据存放位置为同一驱动盘盘下的隐藏目录:\ProgramData
路径下,例如
C:\ProgramData\MySQL\MySQL Server 5.7\Data
如果想要直接访问旧数据库的文件,可以直接将其拷贝进该路径即可。