Home  >  Article  >  Backend Development  >  "Learning and Teaching PHP" (02.Apache+PHP Environment Configuration - Part 1)_PHP Tutorial

"Learning and Teaching PHP" (02.Apache+PHP Environment Configuration - Part 1)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:59:13843browse

小提示:如果你还没有下载相关软件的话,请先去看开篇教程哦!

必 看:如果你已经装了IIS服务器,请到:“开始—> 程序 —> 管理工具 —> Internet 信息服务(IIS)管理器 —> 网站”将所有网站停止。否则将导致Apache无法启动。

上篇:安装Apache服务器


找到下载好的apache_2.2.3-win32-x86-no_ssl.msi文件,双击进行安装。

•Apache的安装界面•


(偷下懒,从网上找了几幅现成的图片用,呵呵)


第一步:不用说大家也知道,当然是点“Next”按钮咯。
第二步:点“I accept the terms…(同意协议)”然后再点“Next”按钮。
第三步:这时你会看到Apache服务器的说明,再点一次“Next”按钮。
第四步:终于看到一个需要输入东东的界面了,如下图:

上面三个输入筐依次为:域名、服务器名、管理员邮箱。因为我们是本地安装,所以这个爱填什么随你自己的口味去填咯。如果是真枪实弹的配服务器,那就要多注意下咯。第一个筐“Network Domain”域名信息,在这里填入你的服务器的域名,如果你已经申请到域名的话填入你申请的域名,(注意这里要填的是域名,只是你申请到的完整域名的后半部分,不包括"www"。如果你申请的是二级域名的话,就是第一个"."之后的部分)如果还没有的话,把本机的IP填上去就行了。下一个筐是服务器名,填入完整的域名或IP地址。再下一个筐是管理员Email地址。这三项在安装是就必须填写,但是在安装完成后你还可以随时进行修改,所以你不必担心填错了会出问题。最后的选项代表使用80端口还是8080端口,一般不需要改(我们用默认的80端口好了)。好了,说太多废话了,不理它,填完再点“Next”按钮。

第五步:到了这里有两个选项Typical(典型安装)和Custom(自定义安装),为节省时间,我们选择Typical,点“Next”按钮。

第六步:你将看到一个“Change…”按钮,你可以用它来更改Apache的安装目录,默认的安装目录是C:\Program Files\Apache Group 这个就随你喜欢了,默认也好,自己改个目录装也好,影响不大。为了讲解方便,我们这里用默认目录。点“Next”按钮。

第七步:准备安装,直接点“Install”按钮安装就可以了。
•Apache安装过程•


装完了点“Finish”按钮,完成安装。
OK,现在到你的开始菜单里点击:Apache HTTP Server 2.2.3—> Control Apache Server —> Start
这个步骤就是启动服务器了。

上天保佑,现在我们要开始测试安装是否成功了。打开浏览器,在地址里输入:http://localhost或者是http://127.0.0.1如果能看到下面的界面,那就表示安装成功了。否则……重新来过吧。祝你好运哦。

如果你安装成功了,那么就接着干吧。现在我们需要简单的配置一下Apache服务器,定位好PHP文件。一般放PHP的文件夹目录为C:\Program Files\Apache Group\Apache2\htdocs 我们来做个测试吧,写一个HTML文件,输入如下代码:
程序代码 程序代码



Hello World

Hello World





Save the file as "hello.htm" and copy it to the C:Program FilesApache GroupApache2htdocs directory. Open the browser and enter http://localhost/hello.htm to see the output. In other words, the htdocs folder is specially used to store website files. Of course, we can also modify it. In order to facilitate the management of website files, please join me in modifying it.

Let’s assume that we want to place all website files in the D:PHProot directory, then go to the D drive to create the PHProot folder, and then open httpd in the C:Program FilesApache GroupApache2conf directory in Notepad. conf file, find:
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
Replace the upline with the downline:
DocumentRoot "D:/PHProot"

Note: The diagonal bar "/" is used here instead of "" to avoid confusion. Otherwise something may go wrong.

Write another HTML file with the following code:
程序代码 Program code



Oh Yeah

Oh Yeah





Save the file as "yeah.htm" and copy it to the D:PHProot directory and open it In the browser, enter http://localhost/yeah.htm to see the output. If the web page displays "Oh Yeah", the configuration is successful, so I wish everyone good luck.

Finally the installation of Apache is finished. In "Apache+PHP Environment Configuration - Part 2", I will introduce the installation method and configuration method of PHP in detail. I hope you all learned something from this tutorial. Don’t forget to follow www.hetty.cn for the latest tutorials.

——Haiting (Hetty)


下载文件 Click to download the world document of this tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317438.htmlTechArticleTips: If you haven’t downloaded the relevant software yet, please read the opening tutorial first! Must read: If you have installed IIS server, please go to: "Start - Programs - Management Tools - In...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn