Apache下载:https://www.apachelounge.com/download/
PHP下载(Thread Safe):https://windows.php.net/download#php-7.4
MySQL下载(ZIP Archive):https://dev.mysql.com/downloads/mysql/
- Apache配置
下载后,将压缩包解压至C盘下
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片.png)
进入“conf”文件夹修改“httpd.conf”配置文件
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-1.png)
修改默认网站位置(可选,若不修改网站位置则为“C:\Apache24\htdocs”)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-2.png)
增加ServerName(可选,修改后需要在hosts文件中增加“127.0.0.1 www.myweb.com”)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-6.png)
以管理员身份启动cmd,并进入“C:/Apache24/bin”目录内,输入“httpd.exe -k install”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-3.png)
再输入“httpd.exe -k start”启动apache服务
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-5.png)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-4.png)
- PHP配置
下载后,将压缩包解压至C盘下
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-7.png)
进入“php7”文件夹后,复制“php.ini-development”粘贴并重命名为“php.ini”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-8.png)
在apache网站目录内创建“test.php”文件,并输入以下内容测试是否安装成功
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-9.png)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-10.png)
最后修改以下内容
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-30.png)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-29.png)
- Apache加载PHP
打开Apache配置文件“httpd.conf”添加以下内容
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-11.png)
打开浏览器进入localhost查看是否加载成功
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-12.png)
修改“php.ini”以下内容,更改PHP时区
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-13.png)
- 配置MySQL
下载后,将压缩包解压至C盘下
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-14.png)
在系统变量里点击“编辑”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-15.png)
添加环境变量
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-16.png)
在mysql8文件夹下创建“mysql.ini”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-17.png)
[mysqld]
port=3306
basedir=C:\\mysql-8.0.21-x64
datadir=C:\\mysql-8.0.21-x64\\data
max_connections=200
max_connect_errors=10
character-set-server=UTF8MB4
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=UTF8MB4
[client]
port=3306
default-character-set=UTF8MB4
以管理员身份启动cmd,并进入“C:/mysql8/bin”目录内,输入“mysqld.exe -install”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-18.png)
输入“mysqld –initialize –console”初始化,此时会生成用户名及密码
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-19.png)
输入“net start mysql”自动启动
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-20.png)
登录测试是否安装成功
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-23.png)
- 安装虚拟主机
在“httpd.conf”文件中将“Include conf/extra/httpd-vhosts.conf”行注释关闭
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-24.png)
进入extra文件夹修改“httpd-vhosts.conf”
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-25.png)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-26.png)
![](https://blog.xzsawq.top/wp-content/uploads/2021/01/图片-28.png)