Win 7 配置Apache+PHP+MySQL环境
安装Apache 2.4
First download Apache 2.4 from http://www.apachelounge.com/download/ (httpd-2.4.1-win32.zip) Apache 2.4.1
首先从http://www.apachelounge.com/download/ 下载Apache 安装包 http-2.4.1-win32.zip
with IPv6 apr-1.4.6 apr-util-1.4.1 apr-iconv-1.2.1 pcre-8.21 lua-5.1 libxml2-2.7.8 openssl-1.0.0g zlib-1.2.6. This release is supported by the PHP 5.4 install from windows.php.net for Apache 2.4.
Extract the zip and copy it to the root of C:\. This will be C:\Apache24 when it is all done.
Update 01-17-2013: The version of the php5apache2_4.dll must match the version of PHP you are installing. The link that was reference before has been changed and moved to
http://www.apachelounge.com/download/additional/ for versions 5.4.9 and earlier. As of PHP 5.4.10 the module is now included in the Windows build.
PHP 5.4.9 and Earlier
Download PHP 5.4.9 VC9 x86 Thread Safe from
http://windows.php.net/download/releases/archives/php-5.4.9-Win32-VC9-x86.zip . Extract and rename folder to php and move to C:\
Also, download php5apache2_4.dll-php-5.4-win32.zip
Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10.
PHP 5.4.10 and higher
Download PHP 5.4 VC9 x86 Thread Safe from http://windows.php.net/download/ . Extract and rename folder to php and move to C:\.
Update 01-17-2013: This next edit seems to cause issues with php5apache2_4.dll not found errors, so I have added two options for PHP 5.4.9 and earlier and PHP 5.4.10 and above. I want to thank all those who have brought this to my attention and I hope this helps out. Also, due to the addition of the php5apache2_4.dll being included in PHP 5.4.10 and above builds you no longer need to download the module separately.
PHP 5.4.9 and earlier Option 1
Extract php5apache2_4.dll-php-5.4-win32.zip and copy php5apache2_4.dll to the c:\php\ directory. This is needed to allow Apache to use PHP. Edit Apache’s config file, c:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
DirectoryIndex index.html index.php
Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.
PHP 5.4.9 and earlier Option 2
Extract php5apache2_4.dll-php-5.4-win32.zip and copy php5apache2_4.dll to the c:\php\ext directory. This is needed to allow Apache to use PHP. Edit Apache’s config file, c:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.
LoadModule php5_module "c:/php/ext/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
DirectoryIndex index.html index.php
Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.
PHP 5.4.10 and newer
Edit Apache’s config file, c:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
DirectoryIndex index.html index.php
Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.
Register Apache Service
Now let’s register Apache as a service. Open a command prompt and type.
c:\apache24\bin\httpd -k install
If do not want Apache starting automatically at start-up/reboot:
GUI Way
START | RUN
Type in services.msc, hit Enter or click OK
Locate Apache2 service and double-click (or right-click for Properties)
Find the caption Startup type: (in the middle of the dialog box), use the pull-down and select Manual
Click OK
Command line
C:\> sc config Apache2.4 start= demand
Add
c:\Apache24; c:\Apache24\bin
to PATH in Environment variables. PATH ENVIRONMENT (System Properties | Advanced | Environment Variables | System variables | Path).
Example:
;c:\php;c:\apache24;c:\apache24\bin;
Now lets check Apache settings by issuing the command, c:\Apache24\bin\httpd -S
PHP Edits
Now we have to do a few edits to the php.ini file to tell it to load support for mysql and the location for the extensions. Since there is not a already set php.ini file we need to rename one of the two examples to php.ini.
Rename c:\php\php.ini-development to php.ini
Now let’s edit php.ini
Uncomment extension directory.
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"
Uncomment mysql modules
extension=php_mysql.dll
extension=php_mysqli.dll
Save the changes and open a command prompt. Check to make sure it shows loaded modules.
C:\> php -m
So now we have Apache running and configured to use php. Lets create a file called info.php, save it and see if Apache parses the info correctly to display the results.
Open Notepad or your favorite Windows editor and type and save the following.
<?php
phpinfo();
?>
Open your browser and type, localhost/info.php for the location and you should receive alot of information about PHP.
MySQL
Download and install mysql-5.5.21-win64.msi . Change installation directory to C:\MySQL\MySQL Server 5.5 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root.
PHPMyAdmin
PHPMyAdmin is a very nice tool to use for administering your MySQL installation.
Download and install phpmyadmin-3.4.10.1-english.zip .
Extract the file and move to c:\apache24\htdocs. Rename directory to phpmyadmin.
Create a config directory under phpmyadmin. Open a browser and type localhost/phpmyadmin/setup/index.php to complete the installation.
At this point you should have a working Apache / PHP / MySQL installation running and ready for you to start developing !!!
原文: How install Apache 2.4 PHP 5.4 and MySQL 5.5.21 on Windows 7
配置Apache,使之能支持PHP,在文件http.conf 中添加
PHPIniDir "D:\php"
LoadModule php5_module "D:/php/php5apache2_2.dll"
LoadFile "D:/php/php5ts.dll"
LoadFile "D:/php/libmysql.dll"
LoadFile "D:/php/libmcrypt.dll"
LoadFile "D:/php/libeay32.dll"
LoadFile "D:/php/ssleay32.dll"
AddType application/x-httpd-php .php .html .htm
update 2014.08.04
Apache+PHP+MySQL 环境安装
多记录多总结,好记性不如烂笔头
在重复的学习相同的东西,主要一个原因是自己在学习的过程中没有注意总结记录…… 记得当年在部队有这样一句话:成绩是需要总结出来滴…… 蛮干是没有用的!
还是在捣腾这网站的东东,换了电脑,换了系统,重新需要安装本地server……
然而,发现这个有些难,总是在配置PHP环境的时候出问题,以前配置过好些次也是这个问题,而至于Apache与MySQL这是傻瓜式安装。出问题的可能性较小……
捣鼓了好些时间,还是不成功,无奈,索性就回去再捣鼓吧…… 现在咖啡馆!
在重复的学习相同的东西,主要一个原因是自己在学习的过程中没有注意总结记录…… 记得当年在部队有这样一句话:成绩是需要总结出来滴…… 蛮干是没有用的!
看来之前在配置server的时候还是没有做好操作记录,害的我每次都得重新Google一下啊……
现在记录一下Apache+PHP+MySQL在WIN平台下的安装配置:
1、环境:操作系统windows 7;php5.2.5;Apache2.2;MySQL5.2
2、顺序:Installer安装Apache及MysQL; 而后下载PHP源码版解压到/PHP目录,从php.ini-recommaned新建为php.ini并配置其中的相关扩展目录及需引用的extension;
3、最后为系统添加环境变量(System Environment Path),添加:D:\php\;D:\php\ext\;
4、重启电脑…… 估计差不多就OK了……
原地址: http://blog.robinu.com/2010/03/note-better-your-memory/
published at 2010-03-20 112:10:11