Installation on Windows


Windows users have a plethora of options for installing the required applications. Microsoft has produced two different Web serversIIS (Internet Information Services) and PWS (Personal Web Server)and you can also use the freeware Xitami, among others. For consistency's sake, and because it's arguably the best Web server available, I'll show how to install Apache.

As for MySQL, it will run on most Windows operating systems (specifically those that are 32-bit, such as Windows 95, 98, ME, NT, 2000, and XP). For my example here, I'll be installing the latest release of MySQL, along with Apache and PHP, on Windows 2000, but the installation process should be similar for most versions of Windows. But first, two quick notes….

You should be aware that MySQL often makes significant changes to its software and installers with each major or minor new release. If the installation process differs from that in the book, see the MySQL manual for the latest, corresponding instructions. This may also be an issue with PHP, but those changes are normally less frequent or dramatic.

Second, while you can follow these instructions and manually install all the requisite software, there is another alternative. You can find online several different free all-in-one packages that will install Apache, PHP, MySQLand sometimes extras like phpMyAdminin one fell swoop. The downside is that if an installation problem occurs, it may be harder to debug.

To install MySQL on Windows

1.

Download the recommended Generally Available (GA) release of the MySQL database server from http://dev.mysql.com/downloads/.

MySQL will indicate the recommended version of their software, which will be a stable version of the latest release. As of the time of this writing, this is version 4.1.11.

On the downloads page, you'll want to download the Windows Essentials version (Figure A.1).

Figure A.1. From MySQL's Web site, grab the Windows Essentials installer for the latest recommended version of MySQL.


2.

On your computer, double-click the downloaded file in order to begin the installation process.

The file downloaded from MySQL's Web site will be of the type MSI, a common Windows installer.

3.

Select the installation type: Typical, Complete, or Custom (Figure A.2).

Figure A.2. Select an installation type.


Naturally, the Typical installation should be fine for most users.

4.

Click your way through the installation process and, if you want, sign up for a MySQL.com account (Figure A.3).

Figure A.3. Sign up for a MySQL.com account to use some of MySQL's support options.


You don't have to sign up, but doing so has its benefits. For starters, an account lets you post at forums.mysql.com (a support forum), subscribe to MySQL newsletters, and the like.

5.

Opt for configuring the MySQL Server now when prompted (Figure A.4) and click Finish.

Figure A.4. After finishing the installation, you can be taken directly to the configuration wizard.


The installation process is now complete, which means you should set up how the MySQL server runs. The installer will take you over to the configuration wizard for this purpose.

6.

Select whether you want to perform a Detailed or Standard configuration (Figure A.5).

Figure A.5. Select what type of configuration to perform: Detailed or Standard.


Most users will probably want to go with Standard here (although Detailed is the default).

7.

Set the basic MySQL settings (Figure A.6).

Figure A.6. Configure MySQL so that it always runs.


With the Standard configuration, there are just a few choices. You should opt for installing MySQL as a Windows service, and have it launch the server automatically so that it's always running. You should also choose to include MySQL's bin directory in the Windows PATH, which will make it easier to run MySQL applications from the command line.

8.

Define the security settings (Figure A.7).

Figure A.7. The security settings are the most critical part of the configuration process.


The choices you make here are very important. For starters, enter a good root user's password. The root user has unlimited access to MySQL, so this password should be secure and one you won't forget.

Besides that, I would recommend that you not enable root access from remote machines or create an anonymous account. Both are security risks.

9.

Click your way through the rest of the configuration process.

Tips

  • Once you've created the root MySQL user, you can create other, day-to-day users, with the information provided later in this chapter.

  • The MySQL configuration wizard can be used to configure a new installation or to reconfigure an existing MySQL installation.


To install Apache with PHP

1.

Download the latest version of Apache from http://httpd.apache.org.

Apache is available is two versions: 1 and 2. Although 2 is the latest, there are issues when it comes to using it with PHP (it's complicated), and Apache 1 is still an excellent product. In short, I would advise that you go with the latest version of Apache 1. This is 1.3.33 at the time of this writing.

Apache for Windows is available as a simple executable file.

2.

On your computer, double-click the installer that you downloaded to begin the download process.

3.

Follow through the wizard.

The installer will go through several steps, including agreeing to the license. When it comes time to entire the server information (Figure A.8), you can enter pretty much whatever (assuming you won't actually be hosting live Web sites). You should, though, opt to run Apache as a service for all users.

Figure A.8. If you are developing sites on your own computer, you can enter whatever values you want here.


4.

Select the Complete installation type (Figure A.9).

Figure A.9. Select a Complete installation of Apache.


5.

Finish the Apache installation.

To complete the setup, select the destination folder (the default is C:\Program Files\Apache Group, which should be fine) and click Next. Then click Install to complete the actual installation process.

6.

Click Finish once the installer is done.

7.

Download the latest version of PHP from www.php.net.

You should download the Windows Zip package. At the time of this writing, the latest version was 5.0.4.

8.

On your computer, extract the downloaded file to a permanent directory.

You'll need to unzip the downloaded files. You can put its contents pretty much anywhere, but C:\php makes sense. Do not use spaces in the directory path, as that can cause some servers to crash.

9.

Copy the php5ts.dll file to Apache's bin directory.

In order for Apache to use PHP, it needs access to this DLL file. You can copy (or move) it from the PHP directory to Apache's bin directory, which is C:\Program Files\Apache Group\bin by default.

10.

Copy php.ini-dist to the Window's directory and rename it php.ini.

The php.ini file controls how PHP behaves. The Zip package comes with a couple of examples of this file, php.ini-dist being one of them. You should copy or move this to your Windows directory, which may be C:\WINNT or C:\Windows or the like, depending upon your specific operating system. Rename the file php.ini.

11.

From the Start menu, select Programs > Apache HTTP Server > Configure Apache Server > Edit the Apache httpd.conf Configuration File.

Now you'll need to tell Apache to use PHP for certain files. To do so, you'll need to edit Apache's configuration file (httpd.conf). Fortunately, the Apache installer creates a Start menu shortcut for this purpose, which should open the file in Notepad or another text editor.

12.

At the end of the LoadModule section, add (Figure A.10)

 LoadModule php5_module "c:/php/php5apache.dll" 

Figure A.10. Manually edit Apache's configuration file in order to enable PHP.


This step and the next one tell Apache to load the PHP module.

13.

At the end of the AddModule section add

 AddModule mod_php5.c 

14.

Find where it says <IfModule mod_mime.c> and add (Figure A.11)

 AddType application/x-httpd-php .php AddType application/x-httpd-php- source .phps 

Figure A.11. Don't forget to add the two new MIME types to Apache's configuration.


The first line tells Apache to handle files with a .php extension as a PHP file. The second says that .phps files are PHP source code.

15.

Add index.php as a directory index.

Find the line that begins with DirectoryIndex and change it to read

 DirectoryIndex index.html index.php 

This lets index.php be a main file in a directory (so that Apache will serve up www.sitename.com/index.php if the user just types in www.sitename.com).

16.

Restart Apache (Figure A.12).

Figure A.12. You have to restart Apache for any configuration changes to take effect.


To restart Apache you must:

A. Select Start > Run.

B. Enter cmd at the Run prompt to bring up the command prompt.

C. Type NET STOP APACHE to stop the currently running Apache.

D. Type NET START Apache to start Apache again.

17.

See the instructions later in the chapter for testing your installation.

Tips

  • See the configuration section at the end of this chapter to learn how to configure PHP by editing the php.ini file.

  • If you have problems with the installation, refer to the PHP manual, specifically checking out the user-submitted comments.




    PHP and MySQL for Dynamic Web Sites. Visual QuickPro Guide
    PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    ISBN: 0321336577
    EAN: 2147483647
    Year: 2005
    Pages: 166
    Authors: Larry Ullman

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net