com site to your local drive. Do the same for Apache and PHP (the appropriate download sites here are http://www.apache.org/dist and http://
www.php.net/download). The names of the files will be something like the following (they may be slightly different, depending on the version you are using):
◆ mysql-3.23.22-beta-win.zip
◆ apache_1_3_9_win32.exe
◆ php-4.0.1pl2-Win32.zip
Start by unzipping the mysql file and php files with your favorite unzip tool. (If you don’t have one, we recommend Winzip, at http://www.winzip.com/.) Unzip them into a directory you find convenient. We prefer using a separate directory for each.
Start with MySQL. In the directory where you unzipped the file, you will have a file named setup.exe. Execute that file. Choose a directory (e.g. d:\mysqlinstall) where you want it installed, and then in the next screen select a Typical installation.
(You may wish to examine the custom options, but with the Windows install there are very few real options.)
413
3537-4 AppB.f.qc 12/15/00 15:26 Page 414
414
Part V: Appendixes
At this point your MySQL installation is complete. To test it, go to the DOS
prompt and move to the directory you specified for your MySQL installation. Then move to the subcategory named \bin. If you then type mysqld, the mysql daemon should start. To test if your daemon is working, start up the mysql command-line client by typing mysql. If the monitor starts up and looks like Figure B-1, MySQL is working properly.
Figure B-1: MySQL monitor running on Windows
Next, you should install Apache.
This requires little more than double-clicking on the executable you copied from the CD or the apache.org site. The installation is pretty easy: all you really need to do is select a directory where you would like Apache to be installed. When it’s completed, an Apache Group item will be added to the Start menu.
NOTE
Don’t start up Apache just yet. A little more configuration information will follow.
3537-4 AppB.f.qc 12/15/00 15:26 Page 415
Appendix B: Brief Guide to PHP/MySQL Installation and Configuration 415
Now on to PHP. You should have a folder into which you unzipped all the PHP
files. In that folder copy MSVCRT.DLL and PHP4TS.DLL to c:\windows\system. Then rename php.ini-dist to php.ini and keep it in the same directory were you have the php.exe file.
All you need to do at this point is make sure that Apache is aware of PHP and that PHP is aware of MySQL.
First go to the directory where you installed Apache, find the httpd.conf file within the \conf directory, and open it in a text editor. Add these three lines to the file: ScriptAlias /php4/ “d:/php4/”
AddType application/x-httpd-php4 .php
Action application/x-httpd-php4 “/php4/php.exe”
Note that we indicated the d: drive because that’s how we set up our own system.
The c: drive will work just as well.
The first line indicates the path where PHP resides. The second tells Apache what file extensions must be parsed as PHP, and the third gives the path to the php executable file. Note using this type of installation, PHP will run as an executable, not an Apache server module.
If you would like other file extensions to by parsed by PHP, simply add another AddType line to the conf file; for example:
AddType application/x-httpd-php4 .phtml
There are a couple of other alterations you may have to make to your httpd.conf file. If the server refuses to start, you may need to add something to the Server Name directive. If you are using TCP/IP in your local area network, you may need to add the IP address of your machine, for instance:
ServerName 192.168.1.2
Or if your machine is not networked, you may want to user the following ServerName
ServerName 127.0.0.1
If you also have Personal Web Server running on your machine, you may wish to change the port on which Apache runs. By default, Web servers listen on Port 80, but you can change that by altering the Port line in the httpd.conf to something else — perhaps 8080.
And that should do it. Start Apache through the Start Menu. Add a file to your
\htdocs folder that contains the phpinfo() function. When you call that function you should see that everything is working properly, and that there is an entry for MySQL. Figure B-2 shows the results of phpinfo().
3537-4 AppB.f.qc 12/15/00 15:26 Page 416
416
Part V: Appendixes
Figure B-2: phpinfo() on Windows
Note that you don’t need to make any alterations in the php.ini file to make PHP
work with MySQL. MySQL support is, in fact, built into PHP for Windows.
If you uncomment the directive extension=php_mysql.dll, you will have all kinds of problems getting a PHP page to load.
Caution
These are the basics you need to get going with PHP and MySQL on Windows.
Note that you can also install PHP as an ISAPI filter for Internet Information Server (IIS) and PWS. The instructions for doing so are included in the readme.txt file included in the PHP zip file. As of this writing, running PHP as an IIS filter is not recommended in a production environment.
Installation on Unix
On Unix, there are far more options you may wish to avail yourself of. You may wish to install by compiling the source code yourself or (on Linux) by using rpm files. This appendix will only cover compiling from source. We strongly recommend
3537-4 AppB.f.qc 12/15/00 15:26 Page 417
Appendix B: Brief Guide to PHP/MySQL Installation and Configuration 417
|