Apache PHP Reference Guide
Apache PHP Reference Guide
Well, PHP4 is available, so it's time to run through the amazingly simple method of installing Apache and PHP4 on your Windows machine. If you have a working version of Apache on your Windows machine, you can skip this section. Otherwise, time to get yourself a Web server: 1. Go to http://www.apache.org/dist/binaries/win32/ and download the latest version of the Windows binary file (with the *.exe extension). Currently, it's version 1.3.12. This file is pre-compiled and ready to install. 2. Once you have the file on your hard drive, run the executable file by double-clicking it or typing its location in the Run dialog box under the Start menu. 3. The installation wizard will start. Read and accept all the licencing stuff. 4. The installation wizard will ask for: a) The Apache installation directory. Default is "C:\Program Files\Apache Group\Apache" but you can change this to "C:\Apache\" or anything else you wish. b) The name that will appear in the Start menu; default is "Apache Web Server". c) The installation type: typical, minimum or custom. I usually pick "typical". 5. Sit back and watch the pretty colors as the installation sequence runs through its paces. The wizard will tell you when it's finished, and ask if you want to read the README. If you want to, do so. If not, just Finish the install. During the installation process, a default set of configuration files will be placed in the "conf" directory, under the installation directory (i.e. "C:\Program Files\Apache Group\Apache\conf\"). Using a text editor, open the httpd.conf file, located in your Apache configuration (conf) directory. In httpd.conf, find this line:
ServerAdmin you@your.address
For now, at least. If you have a real machine name, like gambit.yourdomain.com, go ahead and use it. Now you'll try to start Apache. If you're on Windows NT and you want to run Apache as a service: 1. Select "Install Apache as Service (NT only)" from your Start menu. 2. Start the service named "Apache" by opening the Services window in the Control Panel, selecting "Apache" and clicking the "Start" button. 3. Apache will now continue to run in the background, and will automatically start whenever your machine starts.
Although the example is now out-of-date, since you'll be using PHP4, you get the idea. This is the area where you say "for all files ending with [whatever], consider them to be of [whatever] type." Add these lines:
AddType application/x-httpd-php .phtml .php AddType application/x-httpd-php-source .phps
If you want to create your own file extension for PHP files, like .joe (really, you can...), add .joe after the .phtml and .php in the first AddType line. One more modification...find a section like this:
# # Action lets you define media types that will execute a script whenever # a matching file is called. This eliminates the need for repeated URL # pathnames for oft-used CGI file processors. # Format: Action media/type /cgi-script/location # Format: Action handler-name /cgi-script/location #
You need to add an Action line for your new file types, so that they get sent through the PHP parser. Add this:
Action application/x-httpd-php /php4/php.exe
I know it looks weird, without the drive letter, the slashes are backwards, there aren't any quotation marks, but this is how you do it. That /php4/ comes from the ScriptAlias line at the beginning of the file, so Apache knows that /php4/ really equals C:\php4\ ("C:/php4/" == "C:\php4\" in Apache world). Alrighty then, let's try to start Apache again (shut down and restart Apache if it's still running). Provided there are no issues on startup, open a text editor and type this:
<? phpinfo() ?>
Save this file as phpinfo.php, and put it in the document root of Apache (in the htdocs directory within your installation directory.).
If you don't, then something has gone awry, and let me know. So what is all this stuff? It's "info"...and a ton of it! The phpinfo() function produces this page that shows you what sorts of things are installed, your environment, your settings, and so on. The following list shows you the basic, compiled-in stuff: Regular Expressions Dynamic Library Support Internal Sendmail Support PCRE Support ODBC Support Session Support XML Support MySQL Support BCMath WDDX This means that for the elements in the list above, you do not need to go out and find additional *.dll files. However, if you need Image Creation functions, Crypt functions, other database connectivity support functions, you need to go off and find the *.dlls for those things. A quick search of the mailing list archives should prove useful...what you'll probably find is a link to http://www.php4win.de/, where some PHP developer have donated time and energy to maintain up-to-date compilations of *.dlls for you to use. If you have any problems with the *.dll files you get from that site, remember to take that up with them, not me.... Alright, time to go back and tweak on the php.ini file. Use a text editor to open the php.ini file in C:\WINDOWS\ or wherever you placed it. The following changes are optional or just FYI. For sending mail, find these two lines:
SMTP = localhost ;for win32 only ;for win32 only
sendmail_from =
me@localhost.com
sendmail_from =
If your outgoing mail server is mail.yourdomain.com and your e-mail address is you@yourdomain.com, that is. To use additional *.dlls, put them in C:\php4\ and uncomment their entry in this block:
;Windows Extensions ;extension=php_mysql.dll ;extension=php_nsmail.dll ;extension=php_calendar.dll ;extension=php_dbase.dll ;extension=php_filepro.dll ;extension=php_gd.dll ...
"Uncomment" means to take away that ";" at the beginning of the line. Notice that there's a line for the php_mysql.dll file, but remember, that's already compiled in for you. Don't think you need another one, because you don't. That's really all there is to it; if anything blows up in your face or doesn't match what I've said, just let me know -- this has all worked for me about a zillion times now, but everybody's machine is different. Don't forget about the php-windows mailing list - it's a good place to ask questions.