0% found this document useful (0 votes)
85 views

Apache PHP Reference Guide

If you have a working version of Apache on your Windows machine, you can skip this section. If you're on Windows NT and you want to run Apache as a service: run httpd.conf. On Windows xp, run httpd.

Uploaded by

Smith Steve
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Apache PHP Reference Guide

If you have a working version of Apache on your Windows machine, you can skip this section. If you're on Windows NT and you want to run Apache as a service: run httpd.conf. On Windows xp, run httpd.

Uploaded by

Smith Steve
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Setup and Install Apache + PHP4 on Windows

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

Change it to real values, such as:


ServerAdmin joe@schmo.com

Find this line:


#ServerName new.host.name

Change it to something like:


ServerName localhost

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.

1 2000 thickbook.com. Please ask before reprinting. No steal, no sue. Thanks!

Setup and Install Apache + PHP4 on Windows (contd)


If you're not on NT and need to start Apache on your own: 1. Select "Start Apache" or "Start Apache as a Console App" from the Apache folder in the Start menu. A console window will open and Apache will run. Keep this window open! 2. Yes, that's really it. After starting Apache, open your Web browser and type: http://127.0.0.1/ or http://localhost/ to see the default installation page, containing links to the Apache web site and the Apache manual. If your installation fails at any point, read the Apache documentation and the Apache FAQ to attempt to pinpoint your problem, then try again. Now let's get PHP4 hooked in there... 1. Go to http://www.php.net/, go to the "Downloads" area, and select the link for the Windows binaries. This is a zip file, containing pre-compiled binaries, ready to install. If you want to build from source, then you don't need me or this tutorial to tell you what to do. 2. Once you have the file on your hard drive, use your favorite un-zipping tool to extract the contents to say, C:\php4\ (If you put the files in some other directory, substitute that directory where appropriate, later in this process.). 3. Take the file called "php.ini-dist", rename it to "php.ini" and move it to C:\WINDOWS\ or wherever you usually put your *.ini files. 4. Forget about that file for a moment. 5. Take the two files "Msvcrt.dll" and "php4ts.dll", and put them in C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files. If your system tells you that you already have "Msvcrt.dll" or it's currently in use, that's fine. As long as you have it. 6. Forget about the other *.dll files for now. Let's go make a few modifications to the Apache configuration files, and run a vanilla version of Apache + PHP4. Then we'll go back and tweak on PHP a little bit. Using a text editor, open the httpd.conf file again. The goal of these changes configuration is to tell Apache what to do with files ending with .phtml, .php or anything else you use to indicate a PHP file. Basically, you'll be telling Apache to execute an application in order to do something with those files; in this case, run the php.exe program to parse the PHP code. Find a section that looks like this:
# # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the realname directory are treated as applications and # run by the server when requested rather than as documents sent to the client. # The same rules about trailing "/" apply to ScriptAlias directives as to # Alias. # ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/"

You need to add another ScriptAlias line:


ScriptAlias /php4/ "C:/php4/"

2 2000 thickbook.com. Please ask before reprinting. No steal, no sue. Thanks!

Setup and Install Apache + PHP4 on Windows (contd)


Now find a section that looks like this:
# # AddType allows you to tweak mime.types without actually editing it, or to # make certain files to be certain types. # # For example, the PHP3 module (not part of the Apache distribution) # will typically use: # #AddType application/x-httpd-php3 .phtml #AddType application/x-httpd-php3-source .phps

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

3 2000 thickbook.com. Please ask before reprinting. No steal, no sue. Thanks!

Setup and Install Apache + PHP4 on Windows (contd)


Fire up your Web browser and go to http://localhost/phpinfo.php -- you should see a page that starts out like this:

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

4 2000 thickbook.com. Please ask before reprinting. No steal, no sue. Thanks!

Setup and Install Apache + PHP4 on Windows (contd)


Change these to something useful, like:
SMTP = mail.yourdomain.com you@yourdomain.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.

5 2000 thickbook.com. Please ask before reprinting. No steal, no sue. Thanks!

You might also like