引述

手工安裝PHP5 + MYSQL5 + IIS
手工安裝PHP5 + MYSQL5 + IIS 
#2007/01/19#
 
2007/6/24
更新下載網址。
 
STEP1:下載PHP
下載PHP 5.2.3
http://tw.php.net/distributions/php-5.2.3-Win32.zip

PHP官方網站下載網址:
http://www.php.net/downloads.php

STEP2:選則存放PHP引擎的位置
將php-5.2.3-Win32.zip解壓到C:\Inetpub\php之下。

檢視C:\Inetpub\php資料夾目錄結構如下(檔案未列出):
├─dev
├─ext
├─extras
│  ├─mibs
│  ├─openssl
│  └─pdf-related
└─PEAR

STEP3:將php5isapi.dll模組加入IIS
Control Panel (控制台) -> Performance and Maintenance (效能及維護) -> Administrative Tools (系統管理工具) -> Internet Information Services [開啟IIS管理界面]-> default Web Site [左窗格預設的網站]-> Proterties (內容)-> Home Directory (主目錄)-> Configuration (設定) -> Add [在對應籤頁面按新增按鈕] -> excutable [執行檔欄位填入PHP引擎位置【C:\Inetpub\php\php5isapi.dll】]  ; Extension [副檔名欄位填入【.php】 -> OK (確定) -> OK (確定)
AddPHPtoIIS

STEP4:設定php.ini
在C:\Inetpub\php底下有個php.ini-recommended檔案,將其改名為php.ini,改好後用文字編輯器打開。

編輯下兩行成如下:
doc_root = C:\Inetpub\wwwroot
extension_dir = C:\Inetpub\php\ext

將底下三行前面的分號刪除:
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_mysql.dll

存檔後關閉編輯器。

STEP5:加入環境變數
有兩個環境變數要加入,一個是編輯Path變數,在原有的設定值尾端加入C:\Inetpub\php;
另一個是新增的變數,變數名為PHPRC,設定值為C:\Inetpub\php。
加入環境變數的目的是為了方便管理,不用將php.ini和.dll(動態連結檔)複製檔案到C:\Windows之下。
AddPath

底下是官方的設定步驟:
14.       How do I add my PHP directory to the PATH on Windows?     
      On Windows NT, 2000, XP and 2003:
    •  Go to Control Panel and open the System icon (Start -> Settings        -> Control Panel -> System, or just Start -> Control Panel        -> System for Windows XP/2003)      
    • Go to the Advanced tab      
    • Click on the 'Environment Variables' button      
    • Look into the 'System Variables' pane      
    • Find the Path entry (you may need to scroll to find it)      
    • Double click on the Path entry      
    • Enter your PHP directory at the end, including ';' before (e.g.;C:\php)      
    • Press OK and restart your computer      
15.       How do I make the php.ini file available to PHP on windows?     
      There are several ways of doing this. If you are using Apache, read      their installation specific instructions (Apache 1, Apache 2), otherwise you must      set the PHPRC environment variable:     
      On Windows NT, 2000, XP and 2003:      
    • Go to Control Panel and open the System icon (Start -> Settings        -> Control Panel -> System, or just Start -> Control Panel        -> System for Windows XP/2003)      
    • Go to the Advanced tab      
    • Click on the 'Environment Variables' button      
    • Look into the 'System variables' pane      
    • Click on 'New' and enter 'PHPRC' as the variable name and the         directory where php.ini is located as the variable value (e.g.         C:\php)      
    • Press OK and restart your computer  

官方FAQ網址:http://tw2.php.net/manual/en/faq.installation.php#faq.installation.addtopath

STEP6:重新開機。

STEP7:測試PHP是否有正常啟用。
在網頁根目錄中建立一個phpinfo.php的檔案,其內容如下:
<?php phpinfo() ?>
然後打開瀏灠器輸http://localhost/phpinfo.php,若有跑出很多資訊即正常。

STEP8:下載MySQL
下載MySQL 5.0.41Without installer (unzip in C:\)
http://mysql.ntu.edu.tw/Downloads/MySQL-5.0/mysql-noinstall-5.0.41-win32.zip

MYSQL官方網站下載網址:
http://dev.mysql.com/downloads/mysql/5.0.html#win32

STEP10:安裝程序表列
官方的程序如下:
  1. Extract the archive to the desired install directory         
  2. Create an option file         
  3. Choose a MySQL server type         
  4. Start the MySQL server         
  5. Secure the default user accounts

STEP11:選則MySQL Server安裝路徑
將mysql-noinstall-5.0.41-win32.zip解壓到C:\Inetpub,並改名為資料夾名改為mysql。
檢視C:\Inetpub\mysql資料夾目錄結構如下(子目錄及檔案未列出):
├─bin
├─data
├─Docs
├─Embedded
├─examples
├─include
├─lib
├─mysql-test
├─scripts
├─share
└─sql-bench

STEP12:建立設定檔
在C:\Inetpub\mysql中已有設計好的設定檔,檔案如下:
my-huge.ini , my-innodb-heavy-4G.ini , my-large.ini , my-medium.ini , my-small.ini
除非電腦的記憶體有限,否則一般選用my-medium.ini 或 my-large.ini,
將其改名為my.ini,用純文字編輯器打開,並做如下編輯:
在[mysqld]的最後空行處加入:
basedir=C:/Inetpub/mysql
datadir=C:/Inetpub/mysql/data

編輯完成後存檔離開。

*用反斜線是正確的。

將MySQL編碼改成UTF8:
在[mysqld]的最後空行處加入:
character-set-server=utf8
collation-server=utf8_unicode_ci
init-c

在[client]的最後空行處加入:
default-character-set=utf8

編輯完成後存檔離開。

*參考網址:
http://dev.mysql.com/doc/refman/5.0/en/charset-server.html


STEP13:選則使用MySQL Server的種類。
Windows作業系統有兩種可以使用,mysqld-nt & mysqld-max-nt,此處選用mysqld-nt。

STEP14:環境變數及啟動設定。
將路徑C:\Inetpub\mysql\bin加入Windows的環境變數Path之中。

將MySQL加入Windows的服務,方法如下:
C:\>cd c:\Inetpub\mysql\bin
C:\Inetpub\mysql\bin>mysqld-nt --install MySQL --defaults-file=C:\Inetpub\mysql\my.ini
Service successfully installed.
 
加入之後,檢視服務裡是否有名稱為MySQL的服務(尚未啟動)。

若要將MySQL從服務中移除,方法如下:
C:\>cd c:\Inetpub\mysql\bin
C:\Inetpub\mysql\bin>mysqld-nt --remove
Service successfully removed.
 
STEP15:重新開機

STEP16:測試MySQL
重新開機後,MySQL會自動啟動,測試MySQL是否正常啟動的方法如下:
C:\Inetpub\mysql\bin>mysqlshow.exe -u root mysql
Database: mysql  +---------------------------+  |          Tables           |  +---------------------------+  | columns_priv              |  | db                        |  | func                      |  | help_category             |  | help_keyword              |  | help_relation             |  | help_topic                |  | host                      |  | proc                      |  | procs_priv                |  | tables_priv               |  | time_zone                 |  | time_zone_leap_second     |  | time_zone_name            |  | time_zone_transition      |  | time_zone_transition_type |  | user                      |  +---------------------------+  

C:\Inetpub\mysql\bin>mysqladmin -u root version status proc
Copyright (C) 2000-2006 MySQL AB  This software comes with ABSOLUTELY NO WARRANTY. This is free software,  and you are welcome to modify and redistribute it under the GPL license    Server version          5.0.41-community-nt  Protocol version        10  Connection              localhost via TCP/IP  TCP port                3306  Uptime:                 21 hours 8 min 37 sec    Threads: 1  Questions: 4  Slow queries: 0  Opens: 12  Flush tables: 1  Open tabl  es: 0  Queries per second avg: 0.000  Uptime: 76117  Threads: 1  Questions: 4  Slow queries: 0  Opens: 12  Flush table  s: 1  Open tables: 0  Queries per second avg: 0.000  +----+------+----------------+----+---------+------+-------+------------------+  | Id | User | Host           | db | Command | Time | State | Info             |  +----+------+----------------+----+---------+------+-------+------------------+  | 2  | root | localhost:1562 |    | Query   | 0    |       | show processlist |  +----+------+----------------+----+---------+------+-------+------------------+  

使用底下的指令可以顯示MySQL Server的系統設定:
C:\Inetpub\mysql\bin>mysqladmin -u root variables
 
 
arrow
arrow
    全站熱搜

    yoonow 發表在 痞客邦 留言(0) 人氣()