Apache+PHP installation and configuration under Win9x/ME_PHP tutorial

WBOY
Release: 2016-07-21 16:09:00
Original
804 people have browsed it

  Apache Server是众多的WEB服务器软件中的一种,已经成为目前Internet上最流行的web服务器软件之一。比起其它web服务器软件(如PWS、IIS、UNIX),Apache有安装方便,配置简单,便于管理等优点。更重要的是它和PHP一样是完全免费的!所以受到了众多朋友的青睐,下面我就来讲讲如何安装及配置Apache和PHP,来吧,跟我STEP BY STEP!

  第一步:下载Apache Server。Apache Server的最新版在Apache的官方网站(http://www.apache.org)可以找到,其实我们不需要去国外下载,国内有好几个网站,如http://phpuser.com、http://www.php.com.cn、http://www.phpchina.com都有,下载速度相当快!下载后一般文件名为apache_1_3_x_win32_r2.exe的自解压安装文件。其中1_3_x是apache的版本号,我们这里使用的是目前最新1.3.14版。

  第二步:安装Apache Server。和一般的软件一样,安装过程非常简单,一路[next]下去,只是要将它的安装目录改为[C:\Apache](图1),安装完毕后在win98的[开始]-〉[程序]中就会多出[Apache Web Server]一个项目。这时候Apache Server安装成功,可以下一步了!!

Apache+PHP installation and configuration under Win9x/ME_PHP tutorial
图1

  第三步:配置Apache Server。Apache Server的配置稍稍有一点麻烦,因为Apache Server最初是运行于UNIX上的,还带有许多UNIX的特性,如它的配置就需要专门的配置文件(后缀名为conf)来完成。Apache Server较早的版本有三个文件:httpd.conf、srm.conf和access.conf需要用户自己配置。现在我们用的版本就不需要对这三个文件都进行配置了,只要配置httpd.conf就行了!下面就是最关键的配置了。用WIN98自带的[记事本]打开C盘根目录下[Apache]目录下[CONF]中的httpd.conf文件(C:\Apache\conf\httpd.conf)。这个文件很长,但我们需要改动的地方不是很多,而且仔细看看这个文件的结构也不复杂,它是由说明语句和项目配置语句组成的。前面有“#”是对此句的注释,是说明语句,不起作用,其它的就是配置语句。在配置语句中,要进行如下改动:

  1:找到ServerType(服务器类型),有两个为[standalone]和[inetd],[standalone]是用自己的进程来监听每一个连接,而[inetd]是在连接到达时启动Apache进程。一般都设为standalone,即此行改为:ServerType standalone

  2:找到ServerRoot(服务器根目录),ServerRoot也就是Apache Server的安装目录,此行改为:
ServerRoot "C:\Apache"

  3:找到port(服务器端口),一般默认情况下是80,如果你的pc上还装有其它的Web Server ,那必须将两者分开,如一个为80,一个为8080就可以了!!改为:port 80

  4:找到ServerAdmin(服务器管理),这是应该填的是服务器管理员的E-mail。如果服务器产生错误,则会自动在错误页面上加上这个地址,你可以向他求救!在这里也可以不改动。

  5:找到ServerName(服务器名),这个设置很重要,她也就是你的计算机的网络标识,一般为localhost。当然也可以自定,但一定要和你在win98的网络标识中写的一样(图2),这里改为:
ServerName localhost
Apache+PHP installation and configuration under Win9x/ME_PHP tutorial

图2

  6:找到DocumentRoot(文档根目录),这里填的是默认的主目录地址,即在IE浏览器的地址栏中输入http://localhost/时IE就会自动到此目录下面去找index.html文件。改为:

    DocumentRoot "C:/Apache/htdocs"(注意路径一定要加上引号)

  7:找到DirectoryIndex(默认页面),这个默认页面就是在IE浏览器的地址栏中输入localhost时出现的画面。可以设多个文件后缀名,如.htm、.html、.php、.ph3。这里改为:

    DirectoryIndex index.html index.htm index.php3 index.php(注意要用空格间隔),改完后在将C:\Apache\htdocs下的文件index.html.en改为index.html,让IE浏览器识别。

  8:找到ScriptAlias(脚本别名),这里是指定CGI程序的目录,改为:

    ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/"(注意路径一定要加上引号)

At this point, the configuration of Apache Server is basically completed. You can check whether the configuration is correct. First run Apache Server ([Start]-)[Program]-)[Apache Web Server]-)[Start Apache]). After successful operation, a dos window will pop up (Figure 3). If it disappears immediately after popping up or the content of the dos window is not as shown in Figure 3, then it is very likely that your item 5 (ServerName) is not set correctly. After running successfully, enter http://localhost/ in the address bar of the IE browser. If it is correct, the screen in Figure 4 should appear. This means that you have successfully configured the Apache server.
Apache+PHP installation and configuration under Win9x/ME_PHP tutorial
Figure 3

Apache+PHP installation and configuration under Win9x/ME_PHP tutorial
Figure 4

Step 4: Install and configure PHP. You can download the latest version of PHP from http://www.php.com.cn. We are using version 4.04 here. The downloaded file is php-4.0.4-Win32.zip and the size is 2.7MB. Unzip it to C:PHP4 and the installation is complete.

Step 5: Configure PHP. Rename the file php.ini-inst in the C:PHP4 directory to php.ini and make the following changes:

1: Find DOC_ROOT=. It is the root directory of the server, change it to:

  DOC_ROOT=C:Apachehtdocs

2: Find extension_dir=./ and change it to:

  extension_dir=C:php4

After saving and exiting, copy the file php.ini in the C:php4 directory to the C:windows directory. .

Step 6: Both Apache Server and php can work. The last step is to make them work at the same time. Open the configuration file httpd.conf in the C:apacheconf directory and make the following changes:

1: Find the first occurrence of [DocumentRoot "C:/Apache/htdocs"] below [ <Directory >]...</Directory>], change it to:

 <Directory "c:/php4">
  Options FollowSymLinks
 AllowOverride None
 </Directory>

 2: Add a few sentences at the end of this file, which mean that Apache Server can recognize php applications. Add the following:
ScriptAlias ​​/php3/ "c:/php4/" AddType application/x-httpd-php .php3 .php .phtml .php4
Action application/x-httpd-php "/php4/php. exe"

OK, so far, all the configuration work is completed! It’s not too hard to look back. Isn't it? Finally check if it was successful!

Just write a php program as follows:

<?
print("I successfully configured Apache under win9X/me +php!!!");
?>

Name this program test.php and save it in the C:apachehtdocs directory, then open IE and click in the address bar Enter http://locahost/test. If the screen shown in Figure 5 appears, you are done! !
Apache+PHP installation and configuration under Win9x/ME_PHP tutorial
Figure 5

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314596.htmlTechArticleApache Server is one of many WEB server software and has become the most popular web server software on the Internet. one. Compared with other web server software (such as PWS, IIS, UNIX),...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!