跳到主要內容

Install Apach,Php,MySQL On Windows


Install Apache 2


  1. Go to www.apache.org and download "Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi" to your desktop.
  2. Double click "apache_2.2.4-win32-x86-no_ssl.msi", and if prompted, click "run".
  3. An installation wizard will appear:
    Click "Next".
  4. The next page contains the terms of agreement. Select "I accept", and click "Next".
  5. Read about the Apache Server, and click "Next"
  6. The next screen will ask you for specific server information. Enter the values seen below:
    Click "Next".
  7. On the next screen, select "Typical Installation" and click "Next".
  8. Click "Next".
  9. Click "Install".
  10. Open up Internet Explorer and type inhttp://localhost. If you see a page that says "It works!" then the Apache server has been installed successfully. 

A few notes on your Apache Server Configuration:
  • Apache is installed by default in your "C:\Program Files\Apache Software Foundation\Apache2.2" directory.
  • Inside that directory there is a folder called "htdocs" (the equivilant of your \www\ or \public_html\ directory). You can develop your applications inside this folder and access them by going tohttp://localhost/your_file_name.php
  • The Apache Configuration settings are defined in a file named "httpd.conf" located in the "conf" directory.

Install PHP

Next we will be installing PHP version 5. Follow the steps carefully.
  1. Go to php.net and download the "PHP 5.2.0 zip package" to your desktop. (Be patient while it downloads, the ZIP file is over 9MB!)
  2. Create a new folder called "php" in your C Drive. Copy the "php-5.2.0-Win32.zip" file to there ("C:\php") and extract it using WinZIP or a similiar program.
  3. Your "C:\php" directory should now look like:
  4. Next copy the "php.ini-dist" file from "C:/php/" to "C:/WINDOWS" and rename it to "php.ini". This is your PHP configuration file. We'll come back to this later.
  5. Now it's time to tell Apache that PHP exists. Open up your Apache configuration file ("C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf") in notepad and add these four lines to the bottom of the "LoadModule" section:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddHandler application/x-httpd-php .php
    # configure the path to php.ini
    PHPIniDir "c:/windows"
  6. In your "htdocs" directory, create a file called "info.php". Open it in notepad and add this line of code to it:<?php phpinfo(); ?>
  7. Restart your Apache Server for the changes to take effect: Start > All Programs > Apache HTTP Server 4.2.4 > Control Apache Server > Restart
  8. Open up Internet Explorer and type in:http://localhost/info.php. If your browser takes you to a page that looks like this, then PHP has been installed successfully!
Modify your PHP Configuration File:
  • Your PHP configuration (php.ini) file is located in "C:/WINDOWS/php.ini". You can modify it with notepad or a similiar text editor.
  • Open it up and find the line that says:extension_dir = "./"and change it toextension_dir = "C:\php\ext"
  • Find the line that says:;session.save_path = "/tmp"and change it tosession.save_path = "C:\WINDOWS\temp"

Install MYSQL

Next we will be installing MySQL version 5. Follow the steps carefully.
  1. Go to www.mysql.com and download the "Windows (x86) ZIP/Setup.EXE (version 5.0.27)" to your desktop. (To do this you'll need to register an account with MySQL.)
  2. Once "mysql-5.0.27-win32.zip" has finished downloading, you can extract it using WinZIP or a similiar program.
  3. Once extracted, double click on the "Setup.exe" file. An installation wizard will appear. Click "Next".
  4. Select "Typical" Installation and click "Next".
  5. Click "Install". (Be patient, this can take up to several minutes).
  6. The next screen will ask you to "Sign Up". Select "Skip Sign-Up" for now.
  7. The next screen will tell you that the installation wizard is complete. Make sure that the "Configure the MySQL Server now" field is checked before clicking "Finish".
  8. The MySQL Server Instance Configuration Wizard should appear. Click "Next".
  9. Select "Detailed Configuration" and click "Next".
  10. Select "Developer Machine" and click "Next".
  11. Select "Multifunctional Database" and click "Next".
  12. Click "Next".
  13. Select "Decision Support (DSS)/OLAP" and click "Next".
  14. Select "Multifunctional Database" and click "Next".
  15. Make sure "Enable TCP/IP Networking" is checked, the Port Number is set to "3306", and "Enable Strict Mode" is checked. Click "Next".
  16. Select "Standard Character Set" and click "Next".
  17. Check "Install As Windows Service", set the Service Name to "MySQL", and check "Launch the MySQL Server automatically". Make sure that the "Include Bin Directory in Windows Path" is NOT checked. Click "Next".
  18. On the next screen, check the box that says "Modify Security Settings". Enter a password for the default "root" account, and confirm the password in the box below. Do NOT check the boxes "Enable root access from remote machines" or "Create An Anonymous Account". Click "Next".
  19. Click "Execute". (This may take a few minutes. Be patient).
  20. Click "Finish".
  21. To test if MySQL was installed correct, go to: Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Command Line Client. The MySQL Command Line Client will appear:
  22. It will ask you for a password. Enter the password you created in step 18. (If you enter an incorrect password MySQL will automatically close the command line)
  23. Next, type in the commands shown below: (shown in blue)
    If you don't get any errors, and it returns the information shown above, then MySQL has been successfully installed! Next we will need to configure PHP to work with MySQL.

Configure PHP to work with MySQL

Now that both PHP and MySQL are installed, we have to configure them to work together.
  1. Open up your php.ini file (C:/WINDOWS/php.ini) and find the line:;extension=php_mysql.dllTo enable the MySQL extension, delete the semi-colon at the beginning of that line.
  2. Next we must add the PHP directory to the Windows PATH. To do this, click: Start > My Computer > Properties > Advanced > Environment Variables. Under the second list (System Variables), there will be a variable called "Path". Select it and click "Edit". Add ";C:\php" to the very end of the string and click "OK".
  3. Restart your computer for the changes to take effect.
  4. Create a new file in your "htdocs" directory called "mysql_test.php".
  5. Copy the following code into "mysql_test.php" and click save. (Make sure to replace the MYSQL_PASS constant with the MySQL Password you specified during the MySQL installation. Also, make sure the name of the database inSELECT * FROM nameis the same name as the one used during the MySQL installation in the CREATE TABLE name line in the command prompt, otherwise you will get a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\mywww\php_mysql.php on line 15" error).
    <?php # Define MySQL Settings
    define("MYSQL_HOST", "localhost");
    define("MYSQL_USER", "root");
    define("MYSQL_PASS", "password");
    define("MYSQL_DB", "test"); $conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
    mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error()); $sql = "SELECT * FROM name";
    $res = mysql_query($sql); while ($field = mysql_fetch_array($res))
    {
    $id = $field['id'];
    $name = $field['name']; echo 'ID: ' . $field['id'] . '<br />';
    echo 'Name: ' . $field['name'] . '<br /><br />';
    } ?>
  6. Open up Internet Explorer and type inhttp://localhost/mysql_test.php. If the "mysql_test.php" page returns something similiar to:ID: 1
    Name: John
    Then PHP & MySQL have been successfully configured to work together. Congratulations! The next and final step is to install phpMyAdmin.
  7. Possible errors and their solutions:
    • Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\doctorswithoutborders.org\php_mysql.php on line 15
    • Solution:

Install phpMyAdmin

Now that both Apache, PHP and MySQL are installed, we can install phpMyAdmin, a tool that allows you to easily manage your MySQL databases.
  1. Go to www.phpMyAdmin.net and download "english.zip" under the phpMyAdmin 2.9.2 section to your desktop (I assume that since you are reading this article that you understand English).
  2. Create a new folder called "phpmyadmin" in your "htdocs" directory. Extract the contents of the "phpMyAdmin-2.9.2-english.zip" ZIP file here. Your C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmyadmin" directory should now look like:
  3. Create a new file in the "phpMyAdmin" directory (above) called "config.inc.php". Place this code inside it and be sure to replace "YOUR_PASSWORD_HERE" (in both places below) with your MySQL Password:
    <?php /* $Id: config.sample.inc.php 9675 2006-11-03 09:06:06Z nijel $ */
    // vim: expandtab sw=4 ts=4 sts=4: /**
    * phpMyAdmin sample configuration, you can use it as base for
    * manual configuration. For easier setup you can use scripts/setup.php
    *
    * All directives are explained in Documentation.html and on phpMyAdmin
    * wiki <http://wiki.cihar.com>.
    */ /*
    * This is needed for cookie based authentication to encrypt password in
    * cookie
    */
    $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ /*
    * Servers configuration
    */
    $i = 0; /*
    * First server
    */
    $i++; $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'YOUR_PASSWORD_HERE'; // Your MySQL Password
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'config';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysql';
    /* User for advanced features */
    $cfg['Servers'][$i]['controluser'] = 'root';
    $cfg['Servers'][$i]['controlpass'] = 'YOUR_PASSWORD_HERE'; // Your MySQL Password
    /* Advanced phpMyAdmin features */
    $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma_relation';
    $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    $cfg['Servers'][$i]['history'] = 'pma_history'; /*
    * End of servers configuration
    */ /*
    * Directories for saving/loading files from server
    */
    $cfg['UploadDir'] = '';
    $cfg['SaveDir'] = ''; ?>
  4. phpMyAdmin has now been successfully installed! To use it, open up Internet Explorer and type inhttp://localhost/phpmyadmin. This will bring you to the main phpMyAdmin page. If you have any questions, refer to the phpMyAdmin website or the "Documentation.html" file in the /phpMyAdmin/ directory.
  5. Enjoy using Apache, PHP, MySQL, and phpMyAdmin!
phpMyAdmin: No activity within 1800 seconds; please log in again
1800 seconds is 30 minutes. Want to stay logged in to phpMyAdmin? By increasing the timeout, it's like never being logged out or having phpMyAdmin remember your password. Just Increase the cookie authentication lifetime by editing the file /phpmyadmin/config.inc.php and adding the following line:
$cfg['LoginCookieValidity'] = 32400; // in seconds
To set the "Browse" view default number of records listed 30 to 100, adding the following to the same file:
$cfg['MaxRows'] = 100;


這個網誌中的熱門文章

正確設置404頁面及其他.505,500....

正確設置404頁面 404頁面的設置是否正確直接關係到網站粘性,而現在很多網站的錯誤頁面返回碼都是200和302,只要蜘蛛爬行錯誤頁面不是404,那麼你的404頁 面設置就是錯誤的了,這裡跟大家介紹如何正確設置404頁面。 怎麼正確設置404頁面?很多人看到這個話題可能覺得下文不屑一顧,其實你是否知道自己的404頁面有沒有設置正確呢?很多開源的cms系統和博客 系統都會帶有404頁面,你是不是覺得這樣已經ok了?不用設置了?這些想法是錯誤的,我們做優化的時候,應該測試404頁面時候生效,設置是否正 確等。下面我們詳細說明怎麼設置404頁面。 這先說一下怎麼樣的404頁面才是有效的404頁面。大家應該都知道搜索引擎是通過http狀態碼來識別網頁狀態的,那麼當蜘蛛檢索到一個錯誤鏈 接時,就需要返回404狀態碼來告訴搜索引擎,這個頁面是錯誤頁面,以後不用索取了。而如果返回200,則告訴搜索引擎這個頁面是正常頁面。 所以我們要查看網站錯誤頁面的返回碼是200還是404,而現在很多網站的404頁面返回碼是200而不是404.    那怎麼正確設置404頁面?

Mac OS X Server 架設兩個網站、兩個郵件伺服器

from:http://www.bnw.com.tw/conference/viewtopic.php?t=208 我的需求要更簡單。  朋友的工作室就兩三人而已,另外一個工作室也是兩三人。  希望有屬於自己的網站及網域名稱郵件  www.123.com   abc@123.com  

Mac mini server(2012 年末和 2011 年中):如何將 OS X Server 安裝到軟體 RAID

重要事項 這些步驟會清除 Mac mini Server 中兩個磁碟機上的所有資料。雖然您可以重新安裝 OS X Server,但是請務必確認這些磁碟機上的任何其他資料都已完成備份,然後再繼續。 您無法在 RAID 卷宗上建立恢復分割區。如果沒有恢復分割區, 將無法支援 OS X 的某些功能 ,因此您應該考慮使用 恢復磁碟輔助程式 建立外接恢復磁碟,然後才建立 RAID 卷宗。 本文所提供的步驟需要使用透過 WiFi 或乙太網路的寬頻 Internet 連線。您的網路連線必須符合 這篇連結文章 的「重新安裝 OS X 的需求」一節中,針對 Internet 回復功能所述的需求。 安裝步驟 按住 Command、Option 和 R 鍵的同時啟動 Mac mini Server,以便啟動進入 Internet 回復模式。這可能要花數分鐘的時間。看到旋轉地球和“正在從網路啟動回復程序”訊息時,放開這些按鍵。