2020-04-20

#一、apache的搭建

####1、下载apache到本地

下载地址:https://www.apachelounge.com/download/

![](https://upload-images.jianshu.io/upload_images/9897143-14a840c272d25a89.JPG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![](https://upload-images.jianshu.io/upload_images/9897143-925785c31c199b2b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

####2、配置apache的文件

用记事本打开config文件夹下的httpd.conf文件

![](https://upload-images.jianshu.io/upload_images/9897143-db7a7a05fce6ccf7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

找到Define SRVROOT 这个词把后面引号里的路径改成你apache文件的安装路径

![image.png](https://upload-images.jianshu.io/upload_images/9897143-6cb72435d89c56c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

####3、cmd注册apache服务

以管理员身份打开cmd,并cd到你的apache目录下的bin,之后输入 httpd -k install

![](https://upload-images.jianshu.io/upload_images/9897143-2928fc3d61501409.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

####4、运行apache

![](https://upload-images.jianshu.io/upload_images/9897143-e4e948eb44dcb8b1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

变绿色就说明成功了,红色是失败

![](https://upload-images.jianshu.io/upload_images/9897143-b3807ebbeee747d8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

现在apache已经启动成功了(如果重新配置端口号了就在地址栏后面加上端口号)

![image.png](https://upload-images.jianshu.io/upload_images/9897143-8afcd0fd4dbac1dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

##$\color{#FF0000}{失败原因}$

1.端口号被占用,可以看看是否IIS服务器没关闭,或者在httpd.conf更改端口号

![image.png](https://upload-images.jianshu.io/upload_images/9897143-73f5f0ddc425f34a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

2.重新注册apache服务

以管理员身份打开cmd,并cd到你的apache目录下的bin,先输入 httpd -k uninstall,之后输入 httpd -k install,然后再启动apache,查看是否成功。

![](https://upload-images.jianshu.io/upload_images/9897143-2928fc3d61501409.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

#二、php的安装

下载地址:https://windows.php.net/download#php-7.3

1.文件夹里这个文件的名字改成php.ini

![](https://upload-images.jianshu.io/upload_images/9897143-fbf283b030d4c39c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

2.连接apache

打开apache下的这个文件

![](https://upload-images.jianshu.io/upload_images/9897143-0a98f0e578929c14.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![](https://upload-images.jianshu.io/upload_images/9897143-4e857e235bd9bf74.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

现在apache和php已经连接成功了

你可能感兴趣的:(2020-04-20)