第一部分:安裝Apache2.4.4
1.下載文件:httpd-2.4.4-win32-ssl_0.9.8.zip
2.解壓安裝:將Apache24文件夾拷到C盤根目錄
3.打開C:\Apache24\conf文件夾下面的httpd.conf文件,用記事本打開即可
4.第213行ServerName前面的“#”號去掉;
5.第237行DocumentRoot "c:/Apache24/htdocs"改為"E:/WorkSpace/WWW"
6.第238行<Directory "c:/Apache24/htdocs">改為"E:/WorkSpace/WWW">
note:WWW文件夾為網站的根目錄,需要自己創建,否則會報錯。
7.第271行DirectoryIndex index.html改為DirectoryIndex index.php index.html index.htm
第二部分:安裝PHP5.4.15
1.下載文件:php-5.4.15-Win32-VC9-x86.zip
2.解壓安裝:解壓文件,拷到C盤根目錄,改名為PHP54
3.復制份php.ini-development,並改名為PHP.ini
4.打開C:\Apache24\conf文件夾下面的httpd.conf文件,在#LoadModule xml2enc_module modules/mod_xml2enc.so下面添加如下信息
LoadModule php5_module "C:/PHP54/php5apache2_4.dll" PHPIniDir "C:\PHP54" AddType application/x-httpd-php .php .html .htm
5.在WWW文件夾中創建index.php,文件內容如下
<html> <head> <title>Test PHP5</title> </head> <body> <center> <h1>This is test information</h1> </center> <hr> <?php phpinfo(); ?> </body> </html>
6.啟動Apache服務器:在cmd窗口中啟動(測試過程中窗口不能關閉,否則服務停止)
7.在瀏覽器中輸入http://localhost/如果出現以下信息,則表明配置成功
NOTE:
1.讓php支持MySQL:
將第730行 ; extension_dir = "C:\PHP54\ext" 改為 extension_dir = "C:\PHP54\ext" 將第880、881行 ; extension=php_mysql.dll ; extension=php_mysqli.dll 改為 extension=php_mysql.dll extension=php_mysqli.dll
2.將Apache添加到系統服務:
添加服務:
"C:\Apache24\bin\httpd.exe" -k install -n "Apache 2.4.4" -f "C:\Apache24\conf\httpd.conf"
刪除服務:
"C:\Apache24\bin\httpd.exe" -k uninstall -n "Apache 2.4.4"
開始服務:
"C:\Apache24\bin\httpd.exe" -k start -n "Apache 2.4.4"
停止服務:
"C:\Apache24\bin\httpd.exe" -k stop -n "Apache 2.4.4" or "C:\Apache24\bin\httpd.exe" -k shutdown -n "Apache 2.4.4"
重啟服務:
"C:\Apache24\bin\httpd.exe" -k restart -n "Apache 2.4.4"
Help
C:\>"C:\Apache24\bin\httpd.exe" .help Usage: C:\\Apache24\\bin\\httpd.exe [-D name] [-d directory] [-f file] [-C "directive"] [-c "directive"] [-w] [-k start|restart|stop|shutdown] [-n service_name] [-k install|config|uninstall] [-n service_name] [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X] Options: -D name : define a name for use in <IfDefine name> directives -d directory : specify an alternate initial ServerRoot -f file : specify an alternate ServerConfigFile -C "directive" : process directive before reading config files -c "directive" : process directive after reading config files -n name : set service name and use its ServerConfigFile and ServerRoot -k start : tell Apache to start -k restart : tell running Apache to do a graceful restart -k stop|shutdown : tell running Apache to shutdown -k install : install an Apache service -k config : change startup Options of an Apache service -k uninstall : uninstall an Apache service -w : hold open the console window on error -e level : show startup errors of level (see LogLevel) -E file : log startup errors to file -v : show version number -V : show compile settings -h : list available command line options (this page) -l : list compiled in modules -L : list available configuration directives -t -D DUMP_VHOSTS : show parsed vhost settings -t -D DUMP_RUN_CFG : show parsed run settings -S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG -t -D DUMP_MODULES : show all loaded modules -M : a synonym for -t -D DUMP_MODULES -t : run syntax check for config files -T : start without DocumentRoot(s) check -X : debug mode (only one worker, do not detach) C:\>