search
HomeBackend DevelopmentPHP Tutorial在Windows2000下以Apache模块方式安装PHP4.1.1_PHP

Windows2000Apache

FONT style="FONT: 12px 宋体">

在 Windows 2000 下以 Apache 模块方式安装 PHP 4.1.1

 

□ 文/Platinum www.soulogic.com

 

  文章原地址 http://www.soulogic.com/platinum/doc/apachemodule/, 如果你按照本文安装后出现什么问题,请将软件版本,进行到哪一步、所出现的错误提示或者现象告诉我,我的 E-mail 为 platinum@soulogic.com,或者在我的留言版留言,地址为 http://www.soulogic.com/guestbook/

 

本文可以任意转载,但请尊重作者署名权

 

 

 

--------------------------------------------------------------------------------

本文作者所使用的软件版本为:
Windows 2000 Server build 2195
PHP 4.1.1
Apache 1.3.22


--------------------------------------------------------------------------------

 

 

 

   如果你是第一次安装 PHP,希望你能先完全按照下面的说明(包括路径名等)安装一次,如果你已经以 CGI 方式成功安装了 PHP,想试一试 Apache 模块方式,请点击这里直接看第四步。

 

第一步:下载软件

 

有一个很必要的习惯就是只在官方站点下载所需要的软件。
Apache 官方下载页面:http://www.apache.org/dist/httpd/binaries/win32/
PHP 官方下载页面:http://www.php.net/downloads.php
※ 注意:PHP 必须下载 zip 压缩包而不是那个 .exe 文件,否则将无法以模块方式安装。

 

第二步:安装 Apache 和 PHP

 

  整个安装过程很简单,运行 Apache 安装文件,中途需要你填写主机名和管理员信箱等,如果是单机则不必理会这些,随便写点什么就可以了。反正以后还可以修改。
  下图为 Apache 安装过程中的界面

 

 

 

  至于 PHP,直接将 PHP 包解压缩到一个目录即可。
  这里推荐一下我的习惯,一般人们将 Apache 安装到 C:\Program Files 里,而将 PHP 解压缩到 C:\PHP——我认为除非你的硬盘只有一个区时才需要这么做。我习惯上将他们统统放到 E:\Server 目录,以后所有和 Web Server 有关的东西都放到那里,比方说 MySQL。这样当你以后重装系统的后恢复整个 Web Server 变的非常轻松。
  注意下图的安装路径。

 

 

 

  当 Apache 安装结束后,它就已经开始运行了,以后你可以通过开始菜单的 程序 → Apache HTTP Server → Control Apache Server 来启动(Start)、重启(Restart)或者停止(Stop) Apache。当然,通过“管理工具”中的“服务”也可以对 Apache 进行相同的操作。

 

第三步:配置 Apache 的 httpd.conf 文件

 

  修改 Apache 的选项都是通过编辑 Apache 的 conf 目录下的 httpd.conf 文件完成的,用一个文本编辑器打开他。这个文件很大,缺省有一千多行。
  开头为 # 号的表示注释内容,不起任何作用。
  首先将 DocumentRoot "E:/Server/Apache/htdocs" 中的 E:/Server/Apache/htdocs 更改为你存放网页的目录,如 E:/www,注意是斜杠“/”而不是通常的反斜杠“\”(下同)。
  ※ 注意:每次更改了 http.conf 以后必须通过菜单中的重启(Restart)来使之生效。这是刚开始使用时非常容易忘记的问题。
  现在将一个 HTML 文件比方说 index.html 拷贝到 E:\www 目录,然后打开浏览器,在地址栏中敲入 http://localhost/index.html,如果你能看到该文件说明 Apache 已经正常工作。

 

第四步:以模块方式安装 PHP

 

  首先将 PHP 目录(E:\Server\PHP)下的 php.ini-recommended 文件改名为 php.ini 并拷贝到 Apache 目录下,如“E:\Server\Apache”。和 httpd.conf 的功能一样,所有 PHP 的配置选项都记录在 php.ini 里。这里有几个需要改动的地方:
  extension_dir = ./ 改为 extension_dir = "E:\Server\PHP\extensions"
  doc_root = 改为 doc_root = "E:\www"
  session.save_path = /tmp 改为 session.save_path = "C:\WINNT\Temp"
  ;upload_tmp_dir = 改为 upload_tmp_dir = "C:\WINNT\Temp"。注意 ; 号要去掉,下同。
  ;default_charset = "iso-8859-1" 改为 default_charset = "gb2312"
  有一排 ;extension=php_xxx.dll 根据需要将开头的 ; 号去掉,如 php_gd.dll 可以使用 GD 库做图、php_mssql.dll 用来连接 Microsoft SQL Server 等。当你确实需要该功能的时候再去掉 ; 号,否则只能浪费系统资源。

--------------------------------------------------------------------------------

  改完 PHP.ini 之后将 PHP 目录下的 php4ts.dll 文件拷贝到 C:\WINNT\system32 目录。


--------------------------------------------------------------------------------

  最后修改 Apache 的 httpd.conf 文件。在文件的末尾添加如下三行:
  LoadModule php4_module E:/Server/PHP/sapi/php4apache.dll
  AddModule mod_php4.c
  AddType application/x-httpd-php .php
  第三行为设定后缀,如果你愿意,可以继续加
  AddType application/x-httpd-php .php3
  AddType application/x-httpd-php .phtml
  等等,这样服务器上的所有该后缀的文件都将作为 PHP 脚本来运行。
  查找 DirectoryIndex index.html 这行,将在 index.html 的前面加上一个“index.php”,二者之间要有空格。   


--------------------------------------------------------------------------------

  所有这些都完成后,重起 Apache。在 E:\www 新建一个名为 ver.php 的文件,该文件的内容只有三行:
    phpinfo()
  ?>
  保存之后打开浏览器,在地址栏中敲入 http://localhost/ver.php,如果能看到一个很长的表单说明(如下图所示)安装成功。

  其中第三行 Server API 表示目前为 Apache 模块方式。
  现在打开管理工具 → 服务,也可以看到 Apache 的描述有了变化。

如果在你的机器上也看到了相同的画面,那么,恭喜你,你已经完成 PHP 模块方式的安装。

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
How can you check if a PHP session has already started?How can you check if a PHP session has already started?Apr 30, 2025 am 12:20 AM

In PHP, you can use session_status() or session_id() to check whether the session has started. 1) Use the session_status() function. If PHP_SESSION_ACTIVE is returned, the session has been started. 2) Use the session_id() function, if a non-empty string is returned, the session has been started. Both methods can effectively check the session state, and choosing which method to use depends on the PHP version and personal preferences.

Describe a scenario where using sessions is essential in a web application.Describe a scenario where using sessions is essential in a web application.Apr 30, 2025 am 12:16 AM

Sessionsarevitalinwebapplications,especiallyfore-commerceplatforms.Theymaintainuserdataacrossrequests,crucialforshoppingcarts,authentication,andpersonalization.InFlask,sessionscanbeimplementedusingsimplecodetomanageuserloginsanddatapersistence.

How can you manage concurrent session access in PHP?How can you manage concurrent session access in PHP?Apr 30, 2025 am 12:11 AM

Managing concurrent session access in PHP can be done by the following methods: 1. Use the database to store session data, 2. Use Redis or Memcached, 3. Implement a session locking strategy. These methods help ensure data consistency and improve concurrency performance.

What are the limitations of using PHP sessions?What are the limitations of using PHP sessions?Apr 30, 2025 am 12:04 AM

PHPsessionshaveseverallimitations:1)Storageconstraintscanleadtoperformanceissues;2)Securityvulnerabilitieslikesessionfixationattacksexist;3)Scalabilityischallengingduetoserver-specificstorage;4)Sessionexpirationmanagementcanbeproblematic;5)Datapersis

Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function