Windows 环境下的 PHP5+Apache+mysql 服务器的配置
下面文章内容将讲述 Windows2000/XP/2003(不建议在 windows 98 下建立 PHP 环境) 下 PHP 环境的配置,服务器选择 Apache 2.0.54,数据库选择 MySQL 4.1.14 版本。
需要下载几个软件包:
1. PHP 5.1.0RC1
2. Apache 2.0.54
3. MySQL 4.1.14
下载软件包:
1. PHP 5.1.0RC1
PHP 的下载地址为: http://www.php.net/downloads.php ,找到如下图位置,下载方框中的两个软件包。其中 PHP 5.1.0RC1 zip package 就是 PHP5 软件包,而 Collection of PECL modules for PHP 5.1.0RC1 则是 PHP5 的 PECL 扩展模块集合包。
下载完成后放于 C 盘备用。
2. Apache 2.0.54
Apache 官方下载地址为: http://httpd.apache.org/download.cgi ,找到如下图位置,下载 For Windows 的 MSI 安装包,保存于 C 盘备用。
3. MySQL 4.1.14
MySQL 官方下载地址为: http://dev.mysql.com/downloads/mysql/4.1.html ,找到 Windows downloads 部分,下载 Without installer 包并保存于 C 盘,如下图所示:
安装 PHP5:
假设你的系统安装于 C 盘,否则下列目录均须改成相应的盘的目录。
将下载来的 PHP 5.1.0RC1 解压缩到 C:\PHP5\ 目录下。将 PECL 扩展模块集合包里的所有文件解压缩到 C:\PHP5\ext\ 目录下。
复制 C:\PHP5\ 目录下的 php5ts.dll 文件到 C:\windows\(如果是 windows 2000 操作系统,则为 C:\WINNT\ 目录,下同,不再重复说明) 目录下。
复制 C:\PHP5\ 目录下的下列 dll 文件于 C:\windows\system32\ 目录下:
fdftk.dll
fribidi.dll
gds32.dll
libeay32.dll
libintl-1.dll
libmhash.dll
libmysql.dll
libmysqli.dll
ntwdblib.dll
ntwdblib.dll
yaz.dll
其中 libmysql.dll 为 MySQL 4.1 之前版本的扩展支持,libmysqli.dll 为 MySQL 4.1 之后版本的扩展支持。
复制 C:\PHP5\ 目录下的 php.ini-dist 文件到 C:\windows\ 目录下,并改名为 php.ini ,并用记事本打开编辑:
定位到下面两行:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"
修改下面一行使它指向 C:\PHP5\ext\ 目录,修改后如下:
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP5\ext\"
定位到下面两行:
可以看到下面列出了所有可支持扩展,我们可以去掉前面的分号来使 PHP 支持相应的扩展。我测试了下,支持下列扩展,也可以根据选择是否配置。
extension=php_bz2.dll
extension=php_cpdf.dll
extension=php_curl.dll
extension=php_dba.dll
;extension=php_dbase.dll
extension=php_dbx.dll
;extension=php_exif.dll
extension=php_fdf.dll
extension=php_filepro.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
extension=php_iisfunc.dll
extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_mcrypt.dll
extension=php_mhash.dll
extension=php_mime_magic.dll
extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
;extension=php_oci8.dll
extension=php_openssl.dll
;extension=php_oracle.dll
extension=php_pdf.dll
;extension=php_pgsql.dll
extension=php_shmop.dll
extension=php_snmp.dll
extension=php_sockets.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
;extension=php_w32api.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
;extension=php_yaz.dll
extension=php_zip.dll
保存文件退出并退出。
安装 Apache 2.0.54
准备好下载下来的 apache_2.x.x-win32-x86-no_ssl.msi 。双击后开始安装。一步 Next 下来,同意许可协议后会有填写服务器信息的页面,本地调试,前面两个输入 localhost 即可。如下:
一路 Next 下来,均按照默认路径安装――当然你也可以选择你自己需要的路径。Apache 会自动安装并启动相关服务。并在任务栏右下角运行着一个 Apache 监控器:
如果安装完成后在Apache里没有找到service,还需要在cmd中输入apache -k install;
我们可以从这个监控器来重起、停止、启动 Apache 服务。双击小图标打开控制界面:
接下来对 Apache 的配置文件进行配置,用记事本打开 C:\Program Files\Apache Group\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,定位到下面这行:
DirectoryIndex index.html index.html.var
在其后面添加一个 PHP 默认页,通常是 index.php ,如下:
DirectoryIndex index.html index.html.var index.php
为了使 Apache 识别 PHP 的相关扩展名,搜索并定位到下面这个部分:
AllowOverride None
Options None
Order allow,deny
Allow from all
在后面添加如下两行:
AddType application/x-httpd-php .php .phtml .php3 .php4
AddType application/x-httpd-php-source .phps
指定 php 模块,找到并定位到如下这行:
#LoadModule ssl_module modules/mod_ssl.so
在下面添加一行:
LoadModule php5_module c:\php5\php5apache2.dll
使它指向 PHP5 目录下的 php5apache2.dll 文件,路径一定要准确。
另外,如果要禁止目录浏览,查找并定位到下面这几行:
#……
#一些注释
#……
Options Indexes FollowSymLinks
去掉几行注释下面紧跟着的一行的 Indexes 即可,修改后:
#……
#一些注释
#……
Options FollowSymLinks
找到 DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs" 将其改为你的WEB目录(可不改)如我的为 DocumentRoot "D:/website"
OK,保存 httpd.conf 文件后重起 Apache 服务器。
MySQL 4.1.14 的安装
运行setup.exe文件进行安装,完成后会弹出窗口提示你进行实例安装
进入之后的详细配置说明大家可以参考http://dev.mysql.com/tech-resources/articles/4.1/installer.html,这里就不一一说明了。
我们一路点击Next进行安装,如果安装顺利的话,打开“控制面板”,进入后打开“管理工具”,再打开“服务”,可以看到mysql的启动服务信息。
到这里 MySQL 的安装告一段落,非常简单。
如果连接时出现Client does not support authentication protocol错误,请参考本站别一篇文章http://www.smallrain.net/study_show.asp?id=579。
测试 PHP 是否配置成功
打开记事本,输入如下这行代码:
保存为 phpinfo.php 文件,存放于 D:/website(Apache中定义的web目录) 目录下,记得保存的时候选择保存类型为“所有文件”。
好了,打开浏览器,在地址栏中输入: http://localhost/phpinfo.php 并回车,如果一切顺利的话你将看到下面这个页面,到此 PHP5 的配置大功告成:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

CMS stands for Content Management System. It is a software application or platform that enables users to create, manage, and modify digital content without requiring advanced technical knowledge. CMS allows users to easily create and organize content

Arrays are linear data structures used to process data in programming. Sometimes when we are processing arrays we need to add new elements to the existing array. In this article, we will discuss several ways to add elements to the end of an array in PHP, with code examples, output, and time and space complexity analysis for each method. Here are the different ways to add elements to an array: Use square brackets [] In PHP, the way to add elements to the end of an array is to use square brackets []. This syntax only works in cases where we want to add only a single element. The following is the syntax: $array[] = value; Example
