1、(1)查找hosts文件: C:\Windows\System32\drivers\etc
新增如下 127.0.0.1 www.test.com
(2)找Apache下的httpd-vhosts.conf文件,新增如下
<VirtualHost *:80>
DocumentRoot "C:\myphp_www\PHPTutorial\WWW\qiye\public"
ServerName www.test.com
ServerAlias test.com
<Directory "C:\myphp_www\PHPTutorial\WWW\qiye\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
(3)
2、添加环境变量,用分号隔开:
mysql D:\wamp\bin\mysql\mysql8.0.18\bin;
php D:\wamp\bin\php\php7.0.33;
3、(1)图标变红或变黄时,在wampserver图标上右键点击,选择Tools,点击“测试80端口”:
查看80端口被哪个进程占用,根据PID 从任务管理器里结束掉这个进程,重启wampserver.
(2)数据库默认是MariaDB(3306),需要切换为MySQL(3308):右下角图标上-右键-tools:点击Invert default DABMS。切换为MySQL后,查看项目中 数据库连接端口 'hostport' 是否为3306,需要将MySQL默认端口号改为为3306(点击右下角图标--MySQL--my.ini文件中的端口号都改为3306)。
4、Apache 已经停止, 问题排查:
cmd 然后 cd C:\myphp_www\PHPTutorial\Apache\bin 然后 htttpd.exe -t
根据上图中报错提示,用notepad++打开 vhosts.conf文件,注释掉第二行的内容(之前自己随意设置的端口号,问题应该就出在这里)。
重启服务,apache运行正常了。