Home Backend Development PHP Tutorial 在Windows2000下以Apache模块方式安装PHP4.1.1_PHP

在Windows2000下以Apache模块方式安装PHP4.1.1_PHP

Jun 01, 2016 pm 12:35 PM
apache php Install document Way module

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 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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

See all articles