Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows Server 系統教學 >> Server 2003

Windows Server 2003 手動部署 Apache + PHP 5 + MySQL 4 + phpMyAdmin 完整圖文教學

編輯:Server 2003

軟體版本與路徑規劃

元件版本安裝路徑
Apache2.0.50D:\Apache2
PHP5.0.0D:\PHP
MySQL4.0.20D:\MySQL
phpMyAdmin2.5.7D:\Website\phpmyadmin

系統盤:D:,Web 根目錄:D:\Website

第一步:安裝 Apache 並配置 PHP 支援

  1. 執行 apache_2.0.50-win32-x86-no_ssl.msi 安裝至 D:\Apache2。
  2. 解壓 php-5.0.0-Win32.zip 至 D:\PHP。
  3. 將 D:\PHP\php.ini-dist 重命名為 php.ini 複製至 D:\Windows(或 WinNT)。
  4. 將 D:\PHP\php5ts.dll、libmysql.dll 複製至 D:\Windows\System32(或 System)。
  5. 編輯 D:\Apache2\conf\httpd.conf:

httpd.conf 關鍵修改點

# 預設編碼改為簡體中文
AddDefaultCharset GB2312

# Web 根目錄(可不改)
DocumentRoot "D:/Website"

# 預設文件加入 index.php
DirectoryIndex index.html index.html.var index.htm index.php

選擇一種 PHP 整合模式

模組模式

# 在 LoadModule 區塊後加入
LoadModule php5_module d:/php/php5apache2.dll

# 在 AddType 區塊後加入
AddType application/x-httpd-php .php

CGI 模式

ScriptAlias /php/ "d:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"

驗證 PHP

在 D:\Website 建立 test.php:

<?php echo phpinfo(); ?>

重啟 Apache,瀏覽 https://localhost/test.php 應顯示 PHP 資訊頁。

第二步:安裝 MySQL

  1. 安裝/解壓至 D:\MySQL。
  2. 執行 D:\MySQL\bin\winmysqladmin.exe,輸入任意使用者/密碼(此為管理工具登入用)。
  3. 工作列圖示 → 右鍵 → WinNT → Install the service → Start the service。
  4. 修改 root 密碼:
cd D:\MySQL\bin
mysqladmin -u root -p password 123456
# 提示 Enter password: 直接 Enter(預設無密碼)

第三步:配置 php.ini 並測試 MySQL 連線

extension_dir = "d:/php/ext"
extension=php_mysql.dll
session.save_path = "D:/php/session_temp"

重啟 Apache。建立 testdb.php:

<?php
$link = mysql_connect('localhost','root','123456');
if(!$link) echo "fail"; else echo "success";
mysql_close();
?>

瀏覽 https://localhost/testdb.php 應顯示 success。

第四步:安裝 phpMyAdmin

  1. 解壓 phpMyAdmin-2.5.7.zip 至 D:\Website\phpmyadmin。
  2. 編輯 config.inc.php:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '123456';

非本機使用建議啟用驗證模式(auth_type = 'cookie' 或 'http')。

Copyright © Windows教程網 All Rights Reserved