Installing Apache (with PHP) on Windows XP

Last updated June 25, 2008. Created by m1mic on October 14, 2001.
Edited by skiquel, puregin, Kjartan. Log in to edit this page.

As of this writing, the current version of Apache is 2.2.4 and PHP is 5.2.2.

  1. Download the Apache Windows MSI Installer from Apache.org
  2. Download the PHP Windows Zip Package from PHP.net.

The first step to getting Drupal running on your Windows machine is to set up the Apache web server by running the Apache MSI installer. The following steps will walk you through the installation:

  1. Select Next
  2. Select “I accept the terms in the license agreement”
  3. Select Next
  4. Fill in your server information if it is known. A typical setup will use the “for All Users, on Port 80, as a Service” option. If this is being setup as a test machine, you may use localhost as the Network Domain and the Server Name. Select Next.
  5. Select the Typical Setup
  6. Choose a Destination Folder for the Installer to place the program files into. Note: the default Apache Installer location is C:Program FilesApache Software FoundationApache2.2. Because of the spaces in the directory name, using this folder may cause cgi and php scripts to not find the paths correctly.
  7. Select Finish
  8. If a Firewall is enabled, make sure that port 80 and port 8080 are unblocked and open.
  9. To test if the Apache server is running, open up http:localhost in a browser. A plain black and white page should come up that reads “It Works!”

Configuring Apache:

  1. Using a text editor such as Notepad, open the httpd.conf file. This file is found in the /conf sub-directory under the directory that was set up during installation. Alternatively, a shortcut may be found in the start menu under the Apache HTTP Server folder.
  2. Note: Windows based systems uses backslashes and Unix based systems use slashes / for paths. In the Apache configuration files, slashes / should be used in path names.
  3. Change the DocumentRoot to point to the location of the root document folder. In the default httpd.conf file, this is found on line 149 and if the defaults were used during the installation, it would point to “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs”.
    Note: Wrapping the path name in quotes will escape out any spaces that are used.
  4. Change the Directory path to match the one used in the previous step. This is found on line 177 of the default httpd.conf file.
  5. Add to index.php to the DirectoryIndex. This is found on line 212 of the default httpd.conf file.
  6. Append the following lines to the end of the httpd.conf file:
           LoadModule php5_module "c:/php/php5apache2_2.dll"
           AddType application/x-httpd-php .php
           PHPIniDir "C:/php"
  7. Save and Close

Installing PHP:

  1. Unzip the PHP files to C:php
  2. Copy c:phpphp-ini-recommended.ini and rename itc:phpphp.ini
  3. Uncomment the Windows include_path on line 506
    Note: In the PHP.ini file, semicolons are used to denote that something is commented out. To uncomment a line, simply remove the semicolon.
  4. Update the doc_root to match the one that was set up in the httpd.conf file on line 513.
    Note: The PHP INI files uses the Windows style backslash for path names.
  5. Update the extension_dir on line 520 to “C:phpext”
  6. Uncomment php_gd2.dll extension on line 637.
  7. Uncomment mysql.dll extension on line 651.
  8. Update the sessions.save_path to the Windows temporary files directory (i.e. C:Temp).
  9. The PHP directory needs to be added to the Path Environment Variables
    1. Open the Control Panel
    2. Open System > Advanced > Environment Variables
    3. Append ;C:php to the end of the Path System Variables list and Click OK.
  10. Restart Apache
  11. To test PHP on Apache, go to the root directory (i.e. C:Program FilesApache Software FoundationApache2.2#92;htdocs) and create a new php file in it. In this file, use PHP’s phpinfo() function to see the server’s configuration information. For example:
    <html>
    <body>
    <?php phpinfo() ?>
    </body>
    </html>

    Open this file in a browser (i.e. http:localhostfilename.php).

Installing Apache (with PHP) on Windows XP

Last updated June 25, 2008. Created by m1mic on October 14, 2001.
Edited by skiquel, puregin, Kjartan. Log in to edit this page.

As of this writing, the current version of Apache is 2.2.4 and PHP is 5.2.2.

  1. Download the Apache Windows MSI Installer from Apache.org
  2. Download the PHP Windows Zip Package from PHP.net.

The first step to getting Drupal running on your Windows machine is to set up the Apache web server by running the Apache MSI installer. The following steps will walk you through the installation:

  1. Select Next
  2. Select “I accept the terms in the license agreement”
  3. Select Next
  4. Fill in your server information if it is known. A typical setup will use the “for All Users, on Port 80, as a Service” option. If this is being setup as a test machine, you may use localhost as the Network Domain and the Server Name. Select Next.
  5. Select the Typical Setup
  6. Choose a Destination Folder for the Installer to place the program files into. Note: the default Apache Installer location is C:Program FilesApache Software FoundationApache2.2. Because of the spaces in the directory name, using this folder may cause cgi and php scripts to not find the paths correctly.
  7. Select Finish
  8. If a Firewall is enabled, make sure that port 80 and port 8080 are unblocked and open.
  9. To test if the Apache server is running, open up http:\localhost in a browser. A plain black and white page should come up that reads “It Works!”

Configuring Apache:

  1. Using a text editor such as Notepad, open the httpd.conf file. This file is found in the /conf sub-directory under the directory that was set up during installation. Alternatively, a shortcut may be found in the start menu under the Apache HTTP Server folder.
  2. Note: Windows based systems uses backslashes and Unix based systems use slashes / for paths. In the Apache configuration files, slashes / should be used in path names.
  3. Change the DocumentRoot to point to the location of the root document folder. In the default httpd.conf file, this is found on line 149 and if the defaults were used during the installation, it would point to “C:/Program Files/Apache Software Foundation/Apache2.2/htdocs”.
    Note: Wrapping the path name in quotes will escape out any spaces that are used.
  4. Change the Directory path to match the one used in the previous step. This is found on line 177 of the default httpd.conf file.
  5. Add to index.php to the DirectoryIndex. This is found on line 212 of the default httpd.conf file.
  6. Append the following lines to the end of the httpd.conf file:
           LoadModule php5_module "c:/php/php5apache2_2.dll"
           AddType application/x-httpd-php .php
           PHPIniDir "C:/php"
  7. Save and Close

Installing PHP:

  1. Unzip the PHP files to C:php
  2. Copy c:phpphp-ini-recommended.ini and rename itc:phpphp.ini
  3. Uncomment the Windows include_path on line 506
    Note: In the PHP.ini file, semicolons are used to denote that something is commented out. To uncomment a line, simply remove the semicolon.
  4. Update the doc_root to match the one that was set up in the httpd.conf file on line 513.
    Note: The PHP INI files uses the Windows style backslash for path names.
  5. Update the extension_dir on line 520 to “C:phpext”
  6. Uncomment php_gd2.dll extension on line 637.
  7. Uncomment mysql.dll extension on line 651.
  8. Update the sessions.save_path to the Windows temporary files directory (i.e. C:Temp).
  9. The PHP directory needs to be added to the Path Environment Variables
    1. Open the Control Panel
    2. Open System > Advanced > Environment Variables
    3. Append ;C:php to the end of the Path System Variables list and Click OK.
  10. Restart Apache
  11. To test PHP on Apache, go to the root directory (i.e. C:Program FilesApache Software FoundationApache2.2#92;htdocs) and create a new php file in it. In this file, use PHP’s phpinfo() function to see the server’s configuration information. For example:
    <html>
    <body>
    <?php phpinfo() ?>
    </body>
    </html>

    Open this file in a browser (i.e. http:\localhostfilename.php).

 

http://www.neilcrookes.com/2008/10/30/installing-apache-php-mysql-and-phpmyadmin-on-windows-xp-the-right-way/ 에서 참조

 

Installing Apache, PHP, MySQL and phpMyAdmin on Windows XP… the right way

The best step-by-step guide to the recommended way of installing and configuring Apache, PHP, MySQL and phpMyAdmin on Windows XP… ever! 😉

There is no need to copy files to your windowssystem32 folder. All files stay where they are supposed to. Upgrading is easy. Configuration is minimal.

Share and Enjoy:

  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Slashdot

Apache

  1. Go to http://httpd.apache.org/download.cgi and under the section titled “Apache HTTP Server x.x.xx is the best available version” click on the link labelled “apache_x.x.xx-win32-x86-openssl-0.9.8i.msi” next to the text “Win32 Binary including OpenSSL 0.9.8i (MSI Installer)”. Save the file to your computer and when it has finished downloading double click the icon and run the installer.
  2. Select the following options:
    – Network Domain: localhost
    – Server Domain: localhost
    – Administrator’s Email Address: <your email address>
    – Install Apache for all Users, on port 80 as a service
    Apache conf

    Apache server information

    Select the Custom setup type:

    Apache installation

    Apache setup type

    No need for the Build Headers and Libraries or the Apache docs (these are available online) at http://httpd.apache.org/docs/2.2/.

    Apache installation

    Select Apache features to be installed

  3. Test the installation by going to http://localhostin your browser, you should see the text “It works!”:
    Apache setup

    Apache installed successfully

  4. Pick a folder where you are going to store all the files for all the sites you are going to develop, then, if it doesn’t already exist, create it. I use the folder “C:sites“.
  5. Click on Start > All Programs > Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache http.conf Configuration File.
  6. Search for the text “DocumentRoot” and replace the default value, which is something like “C:/Program Files/Apache…/htdocs” with the folder where you are storing all your sites, e.g. “C:/sites”, noting the forward slash this time. Just below this is a “Directory” directive containing an attribute for the default DocumentRoot value too. Also change this to “C:/sites”.
    Apache config DocumentRoot

    Configure Apache DocumentRoot

  7. Search for the “DirectoryIndex” directive, and add “index.php” to the list of files to run if no file is specified in the request URI.
    Apache config Directoryindex

    Configure Apache DirectoryIndex

  8. If your sites use Apache’s mod_rewrite module, you’ll need to enable this. To do so, search for the text mod_rewrite and uncomment the line by removing the preceding hash symbol.
  9. Search for the “http-vhosts.conf” include line and remove the preceding “#” to uncomment it and include the file.
    Look in http-vhosts.conf

    Include the http-vhosts.conf file

  10. Add following to the bottom, then save and close the file:
    LoadModule php5_module "c:/php/php5apache2_2.dll"
    AddType application/x-httpd-php .php
    PHPIniDir "C:/php"

PHP

This installation method unzips the PHP files rather than using an installer. This is the method of installation recommended on php.net as it means you don’t have to move files into the windows/system32 directory, which means upgrading is easier and it gives you more insight into the configuration process, empowering you to modify the configuration as and when you need to.

  1. Go to http://www.php.net/downloads.php under the section titled ”Windows Binaries” click on the link labelled “PHP x.x.x zip package“. Save the file to your computer and when it has finished downloading extract to “C:php”.
  2. Add “C:php” to system path by right clicking on My Computer, select “Properties” option, click on the “Advanced” tab, click on the “Environment Variables” button, select the “Path” option in the list of “System Variables” fieldset then click the “Edit” button. Add “C:php” to the end of the existing list, note that values are separated by a semi-colon. Restart your computer.
    Path environment variables

    Add path to PHP installation directory to Windows Path environment variable

  3. Copy “C:phpphp.ini-recommended” to “C:phpphp.ini“.
  4. Open php.ini and search for “extension_dir“. Replace the default with the path to your php ext directory, “C:/php/ext/”.
    extension_dir

    Setup the extension_dir “C:/php/ext/”

  5. Locate the long list of extensions and enable the ones you want by removing the preceding semi-colon at the start of each line, e.g. extension=php_mysql.dll.These are likely to be gd2, soap, mysqli and maybe some others.
  6. As this is a development installation, you will want to set display_errors = On. Otherwise, you wouldn’t be able to see the errors in your code ;-).
  7. Restart Apache by clicking on the Apache Service Monitor icon in the System Tray and clicking “Apache2″ > “Restart”.
  8. Create the file “C:sitesphpinfo.php” containing:
    <?php phpinfo(); ?>
  9. Test the installation by going to http://localhost/phpinfo.phpin your browser, you should see this:
    phpinfo

    PHP installed successfully phpinfo()

MySQL

  1. Go to http://dev.mysql.com/downloads/mysql/5.0.html#win32
  2. Under the section titled “Windows downloads” click the link labelled “Pick a mirror” next to the text “Windows ZIP/Setup.EXE (x86)”.
  3. Under the forms click the link labelled “No thanks, just take me to the downloads!“.
  4. Click on a link labelled “HTTP” from a mirror close to you.
  5. Save the file to your computer and when it has finished downloading extract the Setup.exe file, then run it.
  6. If you prefer using the online help, choose the “Custom” installation type and do not install the documentation.
  7. Keep the “Configure the MySQL Server now” check box checked and click the “Finish” button.
  8. Choose the following settings:
    MySQL settings

    MySQL Configuration type

MySQL settings

What will this server be used for?

MySQL default engine settings

MySQL database usage

MySQL storage settings

InnoDB settings

MySQL Server optimisation settings

MySQL number of connection settings

MySQL port

MySQL networking options

MySQL language setting

MySQL language settings

path

Install MySQL as a service and Windows PATH

mysql user

MySQL security settings

  1. Press the “Execute” button.

phpMyAdmin

  1. Go to http://www.phpmyadmin.net/home_page/downloads.php
  2. Under the section titled “Downloads” click on the link labelled “english.zip” for the latest version of phpMyAdmin.
  3. When the file has finished downloading, extract it to “C:sitesphpMyAdmin“.
  4. Open the httpd-vhosts.conf file located in the “confextra” directory where Apache was installed and replace the dummy host VirtualHost directives with the following:
    <VirtualHost *:80>
    DocumentRoot "C:/sites/phpmyadmin/phpMyAdmin-3.0.1-english"
    ServerName phpmyadmin.localhost
    ErrorLog "logs/phpmyadmin.localhost-error.log"
    CustomLog "logs/phpmyadmin.localhost-access.log" common
    </VirtualHost>

    then save the file and restart apache.
  5. Open the file “C:WINDOWSsystem32driversetchosts” with Notepad and add the line
    127.0.0.1 phpmyadmin.localhost
  6. Copy the config.sample.inc.php file to config.inc.php and open it.
  7. Amend the lines as follows:
    $cfg['Servers'][$i]['auth_type'] = 'config';
    ...
    $cfg['Servers'][$i]['extension'] = 'mysqli';
  8. You can use phpMyAdmin installed locally to administer remote databases servers too. To do this, add the following to your config.inc.php file in the Servers configuration section:
    $i++;
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['host'] = 'other_host';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['user'] = 'your_user';
    $cfg['Servers'][$i]['password'] = 'your_pass';
  9. Go to phpmyadmin.localhostin your browser, you should see this:
    phpMyAdmin

    phpMyAdmin

  10. Note, you can disable the warning about using a root account with no password by commenting the line in main.php as follows:
    //trigger_error($strInsecureMySQL, E_USER_WARNING);