How to Install Apache, PHP, MySQL & phpMyAdmin for Vista

January 15, 2009 · Filed Under PHP, Web & Internet 

There is no doubt that PHP is one of the most popular web programming language, at least in the sense of being heavily used. The fact that it is so easy to code and deploy besides the natural attitude of its programmers who tend to be more open and pragmatic contributed a lot in its propagation unlike other programming languages witch have been (and continue to be) massively marketed.

Even if you are not a properly educated software engineer, you can do some web programming by adding some simple PHP content to your HTML pages. My goal in this tutorial is not only to encourage you to start using PHP but also to show you how to start with a highly recommended practice in web programming: “Setting up a stable local development environment”.

This article covers the installation of a web server, database server, open source programming languages, and some other open source or freeware tools.

  • Web Server: Apache 2.0.61.
  • Database Server: MySQL-5.0.45.
  • Programming Languages: PHP 5.2.4.
  • Tools: Eclipse(PDT), phpMyAdmin 2.11.1.2

So let’s download your required list of stable Tools and applications (which may be released by the time you read this article) and get them saved in a directory named Tools.

NB: I will suggest that you use Apache 2.0.x, if you use Apache 2.2.x, the included DLL (php5apache2.dll) will not work for you as it’s specific to the Apache 2.0.x API. But you can check the following URL and download the appropriate DLL if you want to do so.

http://www.apachelounge.com/download/

In my case I will be working in the system directory (Local Disk C:) but its recommended to user another partition (D:) if you do have one.

Where all your tools and applications will be saved.

Install or extract all program files of your tools and application within this directory.

Holder for your scripts and projects files.

Now that we have our tools and directory structure ready we can move forward.

Install Apache Web Server:

I assume that you are installing Apache from a binary distribution (Knowing that you can always compile Apache yourself).

Run the Apache .msi file you downloaded above. This will prompt you for:

- Whether or not you want to run Apache for all users.

- Your Server name, Domain name and administrative email account. Set both of your Server name and Domain name to: “localhost” or (127.0.0.1).

- The directory to install Apache into (the default is C:\Program Files\Apache Group\Apache). Go ahead and change this path to “C:\Development\Apache”.

- The installation type. The “Complete” option installs everything, including the source code if you downloaded the -src.msi package. Choose the “Custom” install if you choose not to install the documentation, or the source code from that package.

At this point Apache is good to go. Open you favorite browser and check this link: http://localhost/ or http://127.0.0.1/. Here also I assume that you didn’t change the server port (Default is 80) within the installation. You should get positive response from the server like “It Works”

After installing Apache, you should edit the configuration files in the conf directory as required. These files will be configured during the install ready for Apache to be run from the directory where it was installed

Install PHP 5:

Installing PHP is also a very easy step, all you have to do is extracting your PHP files into this directory “C:\ Development\PHP”.

- Locate the “php.ini-recommened” file and rename it to “php.ini” then edit it with “Notepad”.

- Search for ‘doc_root’ until you find the line:

doc_root =

- Change it to:

doc_root = C:\Development\Apache\Apache2\htdocs

Or whatever the “htdocs” path is set to.

Enable Short Open Tags:

Search for the line that reads:

  1. short_open_tag = Off

short_open_tag is set to “off” by default, witch means that tags like “<?” will not be recognised as the start tag for a PHP script and php files will not be parse as php but display as plain text. In such a case, to begin a PHP script, you will need to code your script with the standard opening tag “<?php”. so go ahead and chage that to:

  1. short_open_tag = On

NB: It’s strongly discouraged to use the short tag because of their major drawback of conflicting with XML headers, However using them gives you the availability of the using short form <?=$variable ?> syntax

Magic Quotes: (If your PHP version is any version before 6)

Magic Quotes is a process that automatically escapes incoming data with backslashes to the PHP script. It was created to help protect newbie programmers from writing bad form processing code. That is, automatically escaping risky form data that might be used for SQL injection with a backslash \. The characters escaped by PHP include: quote ‘, double quote “, backslash \ and NULL characters. It’s preferred to code with magic quotes off and to instead escape the data at runtime, as needed. Go ahead and turn that on for now.

  1. magic_quotes_gpc = On

Register Globals: (If your PHP version is any version before 6)

When on, register_globals will automatically injects your scripts with all sorts of variables configuration. That is, all variables from the query string, posted forms, session store, cookies, and so on are available in what appear to be locally-named variables. Thus, if variables are not initialized before use, It means writing insecure code is that much easier. This is a big security risk http://us.php.net/register_globals, therefor you have to make sure this is off:

  1. register_globals = Off

Install MySQl Database:

As a Database server, we will install MySQL version 5.0.45 and finally we will install phpMyAdmin as our database administration Tool. So let’s start now:

Run the installation wizard and follow this step:

Choose “Custom setup” in order to change the setup directory to your our development path “C:\Development \MySQL”. So just skip up the “Sign up” step if there is any, unless you like to do so.

Wait until the installation wizard is done then check the “Configure the MySQL Server Now” box to start the configuration wizard.

Choose “Standard Configuration” in “MySQL Server Instance Configuration” .

Check these three options: “Install As Windows Service”, “Launch the MySQL Server automatically” and “Include Bin Directory in Windows PATH”.

In the “Security Options”, set your a password for your “root” user account and disable both anonymous account and remote access from remote machines options.

Finalize your setup as prompted by the installation wizard.

Oops, I new it!?. Unless your firewall is set “off”, you already did open a TCP port for MySQL or you don’t have one at all, you will be prompted again and asked to add the 3306 port to your Firewall exception list.

To be continued…

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Comments

Comments are closed.