A walkthrough for installation of PWS, Perl, and PHP4 on a Win98 SE machine. Copyright (c) 2000 - 2003 David J. Fischer - fischer@shoutingman.com ***** Preface **************************************************** This was written for myself, in case I ever have to reinstall all of this stuff. But I also like to give something to the community that provides such wonderful, free software. Like the little drummer boy, I don't have much, but I will offer what I can. This, then, is my gift to all the other newbies who, like me, don't know jack about server side processing, Perl or PHP. This is quite long, but I think it is very clear and direct. This information is accurate to the best of my knowledge, but I cannot guarantee that it won't destroy your computer and all your files, especially since you will be modifying the registry. As I say later, backup your registry before starting. You may also want to do a backup of your files too, since registry editing can be a dangerous thing. That said, the first time I tried to install PHP4, I screwed things up and my computer crashed on boot until I booted in safe mode, which completed properly. Then I restarted, and that fixed things. After that, not real problems. But, your mileage may vary. If you find this helpful please email and let me know. If you find any errors, please notify me so I can correct them. If you find something confusing, tell me and I'll try and clarify it. Sincerely, Dave Fischer ***** System Configuration *************************************** Windows 98 SE (Win98 SE), x86, Win32 Microsoft Personal Web Server (PWS) Perl, CGI (Build 616) PHP (PHP4) ***** Preparation ************************************************ Time required: 3 - 5 hours General recommendations: Do one at a time, as described here. After uninstalling and reinstalling PWS after Perl & PHP were isntalled, they stopped working. It required a fresh install of all three to restore full functionality. First, back up your registry Start->Run->regedit Registry->Export Registry File Export range = All Save as type Registration Files (*.reg) Now, uninstall PWS, Perl, PHP if you previously installed any of them and are having problems. This is to avoid possible weird conflicts. After uninstalling and rebooting as needed, search and remove from the registry all references to php, pl, cgi, perl that relate to file types, program behavior; don't worry about shortcuts, favorites, and file menu defaults. Searching the registry can be slow. Restart in DOS mode. Run scanreg /fix to make sure everything is in order; this will take several minutes. Reboot, and back up the registry again, under a different name. If you're really paranoid, copy both registry backups onto a physically different harddrive, CD, Zip disk, etc. ***** PWS Installation ******************************************* Download mtssetup.exe from Microsoft. Copy all files from D:\add-ons\pws, where D: is your Win98 CD, to a temp file on your hard-drive. Run mtssetup.exe to extract the Mtssetup.dll file into the pws temp directory; confirm that you want to overwrite the former Mtssetup.dll file. Run setup.exe Choose your configuration; I did custom, and added the ASP docs, and removed the Frontpage extensions. Set your root publishing directory. PWS makes this the Home virtual directory. It places the scripts, iissamples, and I think webpub folders one level above the Home directory. Example: on my computer, I renamed My Documents to Fischer, and my web design directory looks like: C:\ Fischer\ WebDesign\ fischer_dj\ WC-Javascript\ WC-Perl\ WC-PHP\ I set fischer_dj as the root publishing directory. the scripts etc files were placed in the WebDesign folder. After installation and subsequent reboot, bring up the Personal Web Server Setup program (from your Start menu or the icon tray). *DO NOT* go to Advanced yet! Choose either the Publish or Web Site options, it doesn't matter at this point, and go through the default web page install. The page may not display correctly or the browser may report errors. This seems to be associated with not using the default install root publish directory. It's not a problem Now you can go to the Advanced options. It's time for a bit of advance planning. Create directories on your hard-drive for the Perl and PHP installations. I prefer my programs to be in the Program Files folder, so I create C:\Program Files\Perl C:\Program Files\PHP In the PWS Advanced Options, select Home, then click Add. Set the alias to Perl, and set the directory to be the Perl folder you created. All three access settings must be checked: Read, Execute, Scripts. Click Home again, and make a PHP virtual directory, again with all three access privileges enabled. Finally, since fischer_dj, my site prototype, is home, which is under Web Design, I'd like a way to access all my web design stuff. So I edit the WEBPUB virtual folder and set the directory to C:\Fischer\WebDesign Check the "Allow Directory Browsing" option. I prefer un-checking "Enable Default Document", but it's a preference thing. When checked, if any of the listed files are found, they are automatically loaded. That's handy for a web-site, but it prevents you from seeing the directory directly, which can be a bother for testing and prototyping. Exit PWS (don't worry, it just hides it) Now, we'll make our DNS substitute: Load C:\Windows\HOSTS.SAM into a text editor, and save it as "HOSTS"--make sure there is no .txt or other suffix. This has the default entry for localhost, which references the Home virtual directory. You can add other Domain Name entries, if you wish, which also will reference Home. I am running an internal server. It's not connected to the 'net, but it is networked with my apt-mate's computer, so I added the following entries: 169.254.0.1 tacogato # my computer name; use internal-only IP address 169.254.0.1 shoutingman.com # I can alias multiple names to the same IP address 169.254.0.2 ryan # alias my roomie's computer These are necessary for him to see me; localhost always references your computer, from his computer localhost would be his system, not mine. Now, he can go to http://tacogato and see my web stuff. Place a copy of this file in C:\WINDOWS on every computer on your intranet that will access your server. Let's test it now. Load a browser, and go to the URL http://localhost If it can't find it, reboot. I'm not sure if the HOSTS file is read dynamically or at boot. After a reboot, localhost and any other aliases to your computer should work fine. If you're on an intranet, you should also be able to use your aliases to see your server directory. Another simple way to see if your server is really serving, is with dynamic frames. This is a method of passing information between pages using the URL followed by a "?" with the information following. It looks like this http://www.mydomain.com?a=doc1.html?b=doc2.html?name=fischer This is processed server side, and won't work on a PC without server access. An example is at: http://developer.netscape.com/docs/examples/javascript/frames/examples.html You can download the code for example 1 (view and save as index.html and then view source on the frames and save as document_a.html, document_b.html, document_c.html, document_d.html. Place them all in your Home folder, and then open the URL http://localhost/index.html then change it to http://localhost/index.html?a=document_d.html&b=document_c.html&c=document_b.html?d=document_a.html All four frames should change. If you get an error, either you're trying to load the file from a folder instead of through the server, e.g. C:\mywebstuff\index.html?... instead of http://localhost/index.html?...; or your server is not running properly. Once you've seen that it works, reboot (you can't go wrong with a reboot). ***** Perl Installation ****************************************** This is how I installed ActivePerl, Build 616. Download InstMsi.exe ActivePerl-5.6.0.616-MSWin32-x86-multi-thread.msi (or the current version) Run InstMsi.exe to create the MSI installer. Then you can run the ActivePerl msi file. Choose Custom install. Set the install directory to be the Perl directory you made earlier. Then click every install option and choose the "Entire feature will be installed on local hard-drive" option in the pop-up menu. Do this for all six options. Installation takes several minutes. Select Finish when complete. The readme file has never appeared after my installations, but it's not a problem. Reboot Open a DOS window. Enter "path" to check the path variable. There should be at least one line for the bin directory of the Perl install. If not, then run sysedit to modify the autoexec.bat. Start->Run->sysedit At the end of the SET PATH= statement, add the location of your Perl bin folder, e.g. (I also added the lib folder too, as recommended by the Perl docs. ;c:\progra~1\perl\bin;c:\progra~1\perl\lib Reboot (sigh) Open a DOS window. Go to Perl/eg/ and enter perl example.pl It should output Hello from ActivePerl! Congratulations! You've got the basic interpreter running. Time for the server big guns. From the documentation, it seemed best to use the ISAPI dll for processing perl/cgi scripts via the web server. That's what I describe here. You need to tell the server how to execute a perl code. It's really simple. Just create a file named "Perl.reg" and enter the following text exactly, except for the start & end designators: ***** start file: Perl.reg ***** REGEDIT4 [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Script Map] ".pl"="C:\\Program Files\\Perl\\bin\\PerlIS.dll" ".cgi"="C:\\Program Files\\Perl\\bin\\PerlIS.dll" ***** end file: Perl.reg ***** Change the extensions according to your needs, and the directory to suit your installation. You can have more or less extensions, one per line. Just don't add extra returns or spaces between the lines and be sure to keep the double back-slashes (\\). Save the Perl.reg file, then run it. Confirm that you want to modify your registry. Now those extensions will be associated with the scripts for the server. To test this, bring up a browser and go to URL http://localhost/perl/eg/IE3Samples/index.htm If you set up the Perl virtual directory during PWS installation, it will load the PerlScript Samples Library page. Otherwise, first make a Perl virtual directory as described in the PWS directions. Follow the links to test the perl script processing. It worked for me without a reboot. If nothing happens or an error is given, try a reboot. The Registry is voodoo and may not be fully reread until a reboot. Then go to http://localhost/perl/eg/Core/cgi/index.html This is the examples of CGI files. Try these out. This will test the association of .cgi with the Perl ISAPI module. If none of them work, especially the first couple, and you haven't rebooted since adding the Perl registry keys, reboot now. (I had to reboot here to get this to work.) If you have rebooted since modifying the registry, then something is not right. Check the keys to make sure they have the right path for the dll; make sure you typed the file extensions correctly; make sure you are running the cgi's through the server and not via a file load, i.e. C:\Perl\eg\.. bad, http://localhost/perl/eg... good. If all that is working, then Perl is installed! ***** PHP Installation ******************************************* This is the install process for PHP4. I used php-4.0.1pl2-Win32.zip. The documentation claims that you need the updated dcom95.exe from microsoft. On win 98, dcom95.exe won't run, so don't bother getting it. There is a dcom98.exe, but PHP4 runs both with and without it, in my experience (Win 98SE). Unzip the file and copy all the files to your PHP directory. Rename: php.ini-dist to php.ini Open it in a text editor. Search for the string doc_root and make sure it is not set to any value. Search for extension_dir and set its value to "c:\progra~1\PHP", or whatever your PHP directory is. Use the quotes. I've read that you don't need the quotes, but others have told me that you need the quotes. I recommend using them. I'm also not sure if long filenames (even within quotes) work, so I recommend using the truncated DOS equivalent. Search for brows_cap and delete the semi-colon (;) before it to uncomment it. The various lines should now look like (with the quotes): doc_root = ; the root of the php pages, used only if nonempty extension_dir = "c:\progra~1\PHP" ; directory in which the loadable extensions (modules) reside browscap = "c:\windows\system\inetsrv\browscap.ini" Move the php.ini file to C:\WINDOWS\ Move the php4ts.dll & msvcrt.dll files to C:\WINDOWS\SYSTEM\. If there is already a msvcrt.dll, you don't need to replace it. Now you need to tell the server what file extensions to associate with PHP. Create a file PHP.reg, enter the following text (except the start/end designations), save, and run it to add the keys to the Registry, as in the Perl installation. ***** start file: PHP.reg ***** REGEDIT4 [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters\Script Map] ".php"="C:\\Program Files\\PHP\\php4isapi.dll" ".phtml"="C:\\Program Files\\PHP\\php4isapi.dll" ***** end file: PHP.reg ***** Note: if you choose to directly edit the registry key values, enter C:\Program Files\PHP\php4isapi.dll without quotes; it then appears as "C:\Program Files\PHP\php4isapi.dll" in the key display. Likewise, you can use the alternate method "C:\Php\php.exe" "%s %s" using the quotes; it appears as ""C:\Php\php.exe" "%s %s"" in the key. Of course, you can accomplish either using the PHP.reg file, which I what I recommend. I've found it is easier to do right. Reboot (PHP might work without the reboot, but I doubt it.) Time for a test. Enter the following code into a text editor and save it as test.html test.php test.phtml (or whatever other file extensions you associated with PHP). ***** start file: test.html, .php, .phtml *****