使用XAMPP和Hbuilder搭建PHP环境(XAMPP中Apache启动失败解决方法)

版权声明:转载请标明出处 https://blog.csdn.net/Ms_yjk/article/details/84587560

首先安装XAMPP,安装网址:https://www.apachefriends.org/index.html#

安装Hbuilder  :http://www.dcloud.io/

根据自己的系统选择安装,下载完成之后一直点Next就安装完成了,非常简单。安装完成打开界面:

下一步点击config,进行配置设置(如图勾选所需功能):

点击Service and Port Settings:

其中Apache的默认Main Post是80(浏览器默认),SSL Post默认是443。

MySQL的默认Main Post是3306。

1.对于Apache的启动,你可能会遇到打不开的情况,错误如下:

22:36:54 [Apache] Attempting to start Apache app...
22:36:54 [Apache] Status change detected: running
22:36:55 [Apache] Status change detected: stopped
22:36:55 [Apache] Error: Apache shutdown unexpectedly.
22:36:55 [Apache] This may be due to a blocked port, missing dependencies, 
22:36:55 [Apache] improper privileges, a crash, or a shutdown by another method.
22:36:55 [Apache] Press the Logs button to view error logs and check
22:36:55 [Apache] the Windows Event Viewer for more clues
22:36:55 [Apache] If you need more help, copy and post this
22:36:55 [Apache] entire log window on the forums

点击Apache后面的Config,点击第一个:Apache(httpd.conf),进行更改:

2.监听端口443冲突,解决方法:

删除Listen:443或者进行注释,使用#

如果你第一次装Apache没有发现这个问题就说明默认端口没有被占用:如何查看端口占用?

win+r打开命令行:输入netstat -ano 查看自己的端口使用。

当配置好Apache:

然后在浏览器中输入localhost:8080(后面加上自己配置的端口):

然后在你的xampp根目录新建一个文件夹:里面写一个php代码。我的根目录在D://XAMPP/htdocs,创建FirstTest文件夹里面有一个test.php文件:

打开Hbuilder文件进行导入,选择常规->现有文件夹作为新项目。

然后你就能在左侧看见你的文件夹:

因为HBuilder不支持解析php代码,所以我们安装Aptana php插件(工具->插件安装->Apache php选择)。编辑一段简单的php代码(如图所示):

再进行Web服务器的配置:(运行->浏览器运行->设置web服务器)

如果出现以下图片,那么就重新设置Apache的Config里面的端口。

当在你的Hbuilder边看边改模式中出现以下页面就证明成功了

到这里XAMPP和Hbuilder搭建PHP环境就完成了。

猜你喜欢

转载自blog.csdn.net/Ms_yjk/article/details/84587560