Home php教程 php手册 Windows 环境下的 PHP5 与 Apache 服务器的配置

Windows 环境下的 PHP5 与 Apache 服务器的配置

Jun 21, 2016 am 08:58 AM
apache dll mysql php

apache|php5|window|服务器

需要下载几个软件包:
  1. PHP5 RC3
  2. Apache 2.0.49
  3. MySQL 4.0.20

下载软件包:
  1. PHP5 RC3
  PHP官方网站 的下载地址为: http://www.php.net/downloads.php ,找到如下图位置,下载方框中的两个软件包。其中 PHP 5.0.0RC3 zip package 就是 PHP5 软件包,而 Collection of PECL modules for PHP 5.0.0RC3 则是 PHP5 的 PECL 扩展模块集合包。

  下载完成后放于 C 盘备用。
  2. Apache 2.0.49
  Apache 官方下载地址为: http://httpd.apache.org/download.cgi ,找到如下图位置,下载 For Windows 的 MSI 安装包,保存于 C 盘备用。

  3. MySQL 4.0.20
  MySQL 官方下载地址为: http://dev.mysql.com/downloads/mysql/4.0.html ,找到 Windows downloads 部分,下载 Without installer 包并保存于 C 盘,如下图所示:

安装 PHP5:
  假设你的系统安装于 C 盘,否则下列目录均须改成相应的盘的目录。
  将下载来的 PHP5 RC3(php-5.0.0RC3-Win32.zip) 解压缩到 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 之后版本的扩展支持。因为我上面下载的是 MySQL 4.0.20 ,所以其实复制 libmysql.dll 即可。
  复制 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\"

  定位到下面两行:

;Windows Extensions

;Note that ODBC support is built in, so no dll is needed for it.

  可以看到下面列出了所有可支持扩展,我们可以去掉前面的分号来使 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.49

  准备好下载下来的 apache_2.x.x-win32-x86-no_ssl.msi 。双击后开始安装。一步 Next 下来,同意许可协议后会有填写服务器信息的页面,本地调试,前面两个输入 localhost 即可。如下:

  一路 Next 下来,均按照默认路径安装――当然你也可以选择你自己需要的路径。Apache 会自动安装并启动相关服务。并在任务栏右下角运行着一个 Apache 监控器:

  我们可以从这个监控器来重起、停止、启动 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 文件,路径一定要准确。
  为了指定 Apache 识别中文,我们指定 GB2312 为默认编码。应该找到并定位到下面这行

AddDefaultCharset ISO-8859-1

将其修改为:

AddDefaultCharset GB2312

另外,如果要禁止目录浏览,查找并定位到下面这几行:

#……

#一些注释

#……

Options Indexes FollowSymLinks

 

去掉几行注释下面进跟着的一行的 Indexes 即可,修改后:

 

 

#……

#一些注释

#……

Options FollowSymLinks


  OK,保存 httpd.conf 文件后重起 Apache 服务器。

MySQL 4.0.20 的安装

将 mysql-4.0.20-win-noinstall.zip 文件夹压缩到 C 盘根目录下(注意:使用该版本 MySQL 必须将解压缩后文件夹放于 C 盘根目录下),解压缩后可以在 C 盘根目录下找到名为 mysql-x.x.x 的文件夹。将其改名为 mysql 。
  进入 bin 目录,找到 winmysqladmin.exe 文件,打开它。第一次运行会提示输入一个新的用户名和密码。这里可以随意选择你需要的用户名和密码输入,作为 my.ini 的默认用户名和密码。如下图:

  点击 OK 确定后,WinMySQLadmin 将缩小到右下角的任务栏里:

  我们来看看 MySQL 服务是否启动。打开“控制面板”,进入后打开“管理工具”,再打开“服务”。如果一切顺利的话我们会看到 MySQL 已启动的信息,如下图:

  到这里 MySQL 的安装告一段落,非常简单。

测试 PHP 是否配置成功:

  打开记事本,输入如下这行代码:


保存为 phpinfo.php 文件,存放于 Apache2\htdocs\ 目录下,记得保存的时候选择保存类型为“所有文件”,如下图:

好了,打开浏览器,在地址栏中输入: http://localhost/phpinfo.php 并回车,如果一切顺利的话你将看到下面这个页面,到此 PHP5 的配置大功告成:

  注:本文未从安全性和性能上来讨论服务器的配置,相应的安全配置请参考其他手册,本文仅简单介绍了 PHP5 环境的配置,作为学习 PHP5 的前提,本文并不能作为服务器配置文章来阅读,比如,这里没有设置 MySQL 的 root 用户密码,将导致很大的安全隐患,所以请读者自行设置。



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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
Steps to add and delete fields to MySQL tables Steps to add and delete fields to MySQL tables Apr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

How to uninstall MySQL and clean residual files How to uninstall MySQL and clean residual files Apr 29, 2025 pm 04:03 PM

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

An efficient way to batch insert data in MySQL An efficient way to batch insert data in MySQL Apr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

How to use MySQL functions for data processing and calculation How to use MySQL functions for data processing and calculation Apr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

How to configure the character set and collation rules of MySQL How to configure the character set and collation rules of MySQL Apr 29, 2025 pm 04:06 PM

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT

Detailed explanation of the installation steps of MySQL on macOS system Detailed explanation of the installation steps of MySQL on macOS system Apr 29, 2025 pm 03:36 PM

Installing MySQL on macOS can be achieved through the following steps: 1. Install Homebrew, using the command /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". 2. Update Homebrew and use brewupdate. 3. Install MySQL and use brewinstallmysql. 4. Start MySQL service and use brewservicesstartmysql. After installation, you can use mysql-u

How to analyze the execution plan of MySQL query How to analyze the execution plan of MySQL query Apr 29, 2025 pm 04:12 PM

Use the EXPLAIN command to analyze the execution plan of MySQL queries. 1. The EXPLAIN command displays the execution plan of the query to help find performance bottlenecks. 2. The execution plan includes fields such as id, select_type, table, type, possible_keys, key, key_len, ref, rows and Extra. 3. According to the execution plan, you can optimize queries by adding indexes, avoiding full table scans, optimizing JOIN operations, and using overlay indexes.

See all articles