Home Database Mysql Tutorial Windows 配置 Apache2 + PHP5 + MySQL5_MySQL

Windows 配置 Apache2 + PHP5 + MySQL5_MySQL

Jun 01, 2016 pm 01:51 PM
windows download link Install software download

Apache

1:相关软件下载:

Apache HTTP Server (httpd) 2.X :下载地址 (Win32 Binary)

PHP 5.X VC6 x86 Thread Safe :下载地址(选择VC6压缩版,VC9版用于跟IIS集成)

MySQL Community Server 5.X :下载地址(选择安装版)

2:安装软件:

Apache:默认安装,下一步,直到完成

php:解压即可

MySQL:默认安装,注意选择数据库编码

3:端口问题:

Apache HTTP Server 安装完成后会自动启动服务,默认端口是80,如果IIS服务已启动,则无法启动httpd

4:解决办法:

停止IIS服务:控制面板->管理工具->Internet 信息服务(IIS)管理器->网站->默认网站->停止(右侧)

更改IIS端口:网站->默认网站->编辑绑定(右键)->编辑->更改端口->重新启动

更改httpd端口:安装目录->conf->httpd.conf->搜索 Listen 80 –>更改端口(如8888)->重新启动服务

5:配置Apache+PHP:

浏览:http://localhost:8888/ ,如果显示:It works! 则Apache HTTP Server已安装成功

设置环境变量:系统属性->高级系统设置->环境变量->系统变量->path后追加如:

%JAVA_HOME%/bin;D:/php/;D:/php/ext/

设置PHP目录:打开conf->http.conf,在该配置文件最后添加:

PHPIniDir "D:/php/"
LoadModule php5_module "D:/php/php5apache2_2.dll"

添加PHPMIME支持:搜索 AddType 或 –>追加:

AddType application/x-httpd-php .php

配置PHP:重命名 php.ini-development 为 php.ini

注意:修改配置需要重启Apache服务才能生效

7:测试是否配置成功:

进入htdocs目录,新建 test.php,代码如下:

   phpinfo();
?>

8:配置MySQL:

添加MySQL扩展:php.ini->;extension=php_mysql.dll->去掉分号,启用php_mysql.dll

指定MySQL库位置:php.ini->修改为:extension_dir = "D:/php/ext",即php_mysql.dll所在目录

9:测试是否配置成功:

进入htdocs目录,新建 db.php,代码如下:

<?php if (!$link = mysql_connect('localhost', 'root', 'root')) {     echo '数据库连接失败!';     exit; } if (!mysql_select_db('mysql', $link)) {     echo '此数据库不存在!';     exit; } $sql = 'show databases'; $result = mysql_query($sql, $link); if (!$result) {     echo 'MySQL Error: ' . mysql_error();     exit; } while ($row = mysql_fetch_assoc($result)) {     echo $row['database']; } mysql_free_result($result); ?>
Copy after login

浏览:http://localhost:8888/db.php ,成功页面见附图:

10 :设置缺省页面:

搜索 DirectoryIndex

追加 index.php:


    DirectoryIndex index.html index.php

10:添加虚拟目录:

找到:


    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

追加:

Alias /dwz "D:/dwz/"

    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

浏览方式:http://localhost:8888/dwz/

配置PHP成功页面

image

配置MySQL成功页面,内容为4个默认数据库

image

作者:zhanqi

出处:http://www.cnblogs.com/zhanqi/

本文版权归作者和博客园共有,转载请注明作者及出处.

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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

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)

What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files Jun 12, 2024 pm 02:46 PM

What should I do if I can't delete a Windows system dll file? Tips for completely deleting stubborn dll files

Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS Aug 26, 2024 am 10:07 AM

Lossless Scaling on Steam Deck OLED runs games at up to 2x FPS

How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated? How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated? Feb 21, 2025 pm 10:54 PM

How to update the latest version of Bybit Exchange? Will there be any impact if it is not updated?

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node?

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

Snapdragon X Elite CPU performance nearly identical on battery and plugged-in in Vivobook S15 benchmarks Snapdragon X Elite CPU performance nearly identical on battery and plugged-in in Vivobook S15 benchmarks Jun 20, 2024 pm 03:59 PM

Snapdragon X Elite CPU performance nearly identical on battery and plugged-in in Vivobook S15 benchmarks

Snapdragon X Elite CPU performance nearly identical on battery vs AC power in Vivobook S15 benchmarks Snapdragon X Elite CPU performance nearly identical on battery vs AC power in Vivobook S15 benchmarks Jun 21, 2024 am 06:50 AM

Snapdragon X Elite CPU performance nearly identical on battery vs AC power in Vivobook S15 benchmarks

See all articles