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

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

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

    下面文章内容将讲述 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 的配置大功告成:



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 尊渡假赌尊渡假赌尊渡假赌

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
1664
14
PHP Tutorial
1268
29
C# Tutorial
1248
24
Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

NGINX and Apache: Understanding the Key Differences NGINX and Apache: Understanding the Key Differences Apr 26, 2025 am 12:01 AM

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

MySQL: The Database, phpMyAdmin: The Management Interface MySQL: The Database, phpMyAdmin: The Management Interface Apr 29, 2025 am 12:44 AM

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

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.

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.

See all articles