RSS

Neil Crookes

Learnings and Teachings on Web Application Development & CakePHP

Oct

30

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 windows\system32 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://localhost in 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:\php\php.ini-recommended” to “C:\php\php.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:\sites\phpinfo.php” containing:
    <?php phpinfo(); ?>
  9. Test the installation by going to http://localhost/phpinfo.php in 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

  9. 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

  10. 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:\sites\phpMyAdmin“.
  4. Open the httpd-vhosts.conf file located in the “conf\extra” 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:\WINDOWS\system32\drivers\etc\hosts” 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.localhost in 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);
Share and Enjoy:

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

Be the first to rate this post
Loading ... Loading ...

4 Responses so far

What I do is simply install Xampp. No setup is really necessary other than setting up the virtual hosts that I’m going to use:

C:\xampp\apache\conf\extra\httpd-vhosts.conf

I usually create a c:\www directory for all of my development and point my virtual hosts there using my hosts file.

I’ve built Lamp systems in the past and I’ve found this to be the least complicated way.

I tend not to use packages like XAMPP as they initially enforce their own locations for config files and the webroot folder.

Some of these can be changed without much hassle, but if you get stuck on a major malfunction, you may find yourself querying Google with the likes of “where is the php.ini for xampp” or “http error 500 *on xampp*”.

The problem with this, I find, is that some problems you encounter may be specific to the packaged stack you chose, and therefore, the “community” (amount of helpful results) is diminished somewhat and you can lose a considerable amount of time trying to source a solution.

I tend to install my stack very similarly to the way Neil has outlined above. It may take a bit longer to install, but I feel that you can save time later by knowing exactly where everything is.

I house everything under “C:\server\” (on Windows), and make a shortcut to here which I can use for my development woes. There are two main approaches I take depending on the particular server “component” (php/mysql/etc) I am installing, which I will coin as “straight” and “versioned” for the purposes of this comment.

With the straight setup, PHP would be installed in C:\server\php\, but, in the versioned setup, PHP might be installed in C:\server\php\5.2.5\. The advantage of the latter is that you can install multiple versions of a particular “component” and switch between them fairly quickly (by editing the correct configuration file [eg. http.conf]).

The “versioned” method is not without the obvious added layer of complexity that comes with longer file paths, but I would only really be recommending it for those seasoned developers who feel they have the need to switch between different versions of server components, otherwise, the “straight” version is more suited for those who simply need a stack! (You can always change it around later)

Here is a quick example of how one might lay out the directory structure of a “straight stack” on Windows:

C:\server\php\
C:\server\mysql\
C:\server\apache\
C:\server\www\ <- set this as webroot
C:\server\www\app1 (a cake app)
C:\server\www\app2 (another cake app)
C:\server\svn\ (svn binaries)
C:\server\cake\1.2-nightly\ (svn checkout)
C:\server\cake\1.2-rc2\ (svn checkout)
C:\server\cake\1.2-rc3\ (svn checkout)
C:\server\etc..

The above can easily be adapted to your tastes, or can be used as the basis for a “versioned” stack by giving certain components subfolders with their corresponding version numbers.

Notice that I have chosen to keep CakePHP outside of my webroot (ie. C:\server\cake\{version}). I can then tell a cake app (ie. C:\server\www\app1\) to use a certain version of CakePHP by adapting the CAKE_CORE_INCLUDE_PATH constant found in {app}\webroot\index.php.

For this, I find it easiest to base this constant from the previously defined ROOT constant in the same file. This is because I use a very similar setup on my live server, where the “cake” directory (which contains the same “versioned” struture) is located in the directory above my webroot.

define(‘CAKE_CORE_INCLUDE_PATH’, dirname(ROOT) . DS . ‘cake’ . DS . ’1.2-nightly’);

This tells my app, that after going three levels up from C:\server\www\app1\webroot\ to define ROOT as C:\server\www\, that it must go up one more level (dirname()) before it will find the cake/1.2-nightly directories.

I will spare you guys any more details, apart from the only shortcuts I tend to use for developing with this setup are:

server: C:\server\
sites: C:\server\www\
ide: {insert ide here}

Ok so how can I go about installing PHP v7 from PHP-Fusion??? or cant that be done??

This happen about thirty days after her workspace was redesigned eliminating Cubicle Level Protection. ,

Leave a comment