Nameconfigure-apache.pl - A configuration program for the Apache web server for MS Windows. SynopsisIf you wish to install Apache or Perl on a drive other than the default C:, then this program can help. All of these instructions use D:\, rather than the default C:\, to more clearly indicate what needs to be done to install Perl and Apache on a drive other than C:.
Auto-backup of patched filesThis program can safely be run repeatedly, since:
This means you always have a copy of the original files, and it is the output from the first run which gets patched on the second run, and so on. Versions
URIsA pre-compiled, self-extracting, binary of Perl + Apache + mod_perl + mod_ssl is at ftp://theoryx5.uwinnipeg.ca/pub/other/perl-win32-bin-0.8.exe and is of size 23,181,824 bytes. configure-apache.pl is in http://savage.net.au/Perl/configure-apache.zip This document can be extracted from configure-apache.pl and is at http://savage.net.au/Perl/html/configure-apache.html The GNU utils for DOS can be installed using these instructions: http://savage.net.au/Ron/html/GNU-Utils.html Environment variablesYou'll find it convenient to patch and create some environment variables. Under WinNT, use Start/Settings/Control Panel/System/Environment Variables to patch env vars. Under Win2K, use Start/Settings/Control Panel/System/Advanced/Environment Variables to do the same thing. Edit DOMAIN, HOME, NAME, PATH and TERM thus: MS Windows 9X/ME: You patch autoexec.bat to make these changes. Now you must reboot to have MS Windows recognize the changes. MS Windows NT/2K: You need to reboot. Open DOS windows will not recognize the changes. Opening a DOS window from a shortcut will not make the changes visible, either. You must open a new DOS window via Start/Programs/Command Prompt or via the Microsoft Office toolbar (often at the top of the screen) to make the changes visible. I've tried stopping/starting Apache after editing system environment variables, and the changes were not passed thru to CGI scripts. I've also tried stopping/uninstalling and installing/starting Apache, and that did not work either. Lastly, I've tried stopping/uninstalling/logging off as Admin and logging on/installing/starting Apache, and that did not work either. Hint: Reboot all versions of MS Windows. MySQLI found that when using Win2K as a non-administrator, a CGI script can display the path including C:\MySQL\bin, but a CGI script which uses MySQL cannot find LibMySQL.dll. The simple solution is to copy LibMySQL.dll to the directory D:\Perl\site\lib\auto\DBD\mysql. Also, in this non-administrator situation, I use MySQL like this:
However, I do not recommend this non-admin approach. I always install Apache and MySQL as admin, and patch all environment variables as admin. That way, I can install Apache and MySQL as services and have them available to all users, and have them restarted automatically whenever the system is rebooted. DocumentationYou can extract this documentation with pod2html, which is shipped with Perl. Even better, perl-win32-bin-0.8.exe ships with Pod::POM, and a pod2html and pod2text replacement called pom2. POM = POD Object Model. The name is modelled after DOM = Document Object Model. Best though, is to download fancy-pom2.pl from my web site, and run it: shell>perl fancy-pom2.pl html css configure-apache2.pl > configure-apache2.html or: shell>perl fancy-pom2.pl html -css configure-apache2.pl > configure-apache2.html Installation
Optionsconfigure-apache.pl uses case-sensitive command line options. Here are the options and their defaults:
-man only works if Perl is on C:\ or you have patched X:\perl\lib\config.pm, since it invokes X:\perl\bin\perldoc. SecurityAs shipped, Apache responds to anyone who submits request to your web server, due to these 2 lines, which appear at various places in httpd.conf: Order allow,deny Allow from all configure-apache2.pl now automatically converts almost all these to: # Order allow,deny # Allow from all Order deny,allow Deny from all Allow from 127.0.0.1 When you feel comfortable with the amount of access you're allowing people to have, revert this limitation. I said 'almost all'. Exceptions are where httpd.conf already says 'Deny from all'. PassEnv, ImageMagick and other Special CasesTo get Apache to pass application-specific environment variables to CGI scripts, it is necessary to use Apache's PassEnv command. ImageMagick, prior to V 5.4.8, is an application which relies on an environment variable called MAGICK_HOME. Note: Pre-compiled versions of ImageMagick under MS Windows, from V 5.4.8 on, does not use MAGICK_HOME. You can get configure-apache2.pl to patch httpd.conf so that CGI scripts have access to the value of MAGICK_HOME by using the following option: shell>perl configure-apache2.pl -PassEnv MAGICK_HOME This would have the effect of putting: PassEnv MAGICK_HOME at the end of httpd.conf. As always after patching httpd.conf, you must stop and restart Apache. You may want to do this, since ImageMagick uses TMPDIR, not TEMP and not TMP: shell>perl configure-apache2.pl -PassEnv MAGICK_HOME,TMPDIR This would have the effect of putting: PassEnv MAGICK_HOME PassEnv TMPDIR at the end of httpd.conf. Consider doing the same with PERL5LIB. Starting Apache from the command lineYou did edit Embperl out of httpd.conf as explained right at the start of this doc, didn't you? Start and stop Apache from the command line, ie not as a service: In one DOS window: D:\>cd Apache D:\Apache>apache -k start You'll get this message: Apache/1.3.26 (Win32) AxKit/1.6 mod_ssl/2.8.10 OpenSSL/0.9.6d mod_perl/1.27_01-dev PHP/4.2.1 running... Control will not return to the command line. Then, in another DOS window: D:\>cd Apache D:\Apache>apache -k stop Starting Apache as a serviceYou can install Apache as a service, but not start it, with: D:\>cd Apache D:\Apache>apache -i This installation is permanent. Ie after a reboot you will not need to reinstall Apache. You can remove Apache as a service, with: D:\Apache>apache -u Enough practice. Now, try installing but not starting Apache. Then go to Start/Settings/Control Panel/Services. Click on Apache. Click on Start. Also, Matt Wilkins tells me there is another way (which I have not tried): Create a separate logon account just for Apache with restricted permissions (cannot install software etc) and tell the services manager (which is software, not a person) to use that account to start the Apache service instead of using the local system account. Virtual hosts and a crude DNSDSN stands for Domain Name Service. In some versions of MS Windows (95/98/ME), the file C:\Windows\Hosts provides a conversion from an IP address to a domain name and visa versa. The file Hosts.sam is a sample, and is not read by Windows. In MS Windows NT/2K/XP, the C:\WinNT\Hosts file's a fake: Use C:\WinNT\System32\Drivers\Etc\Hosts. Not only that, but Windows Explorer will lie to you about the attributes of the latter file. You must log off as a user and log on to NT as an administrator before you can save edits into this file. MS Windows does search in other places too, including the LMHOSTS file. See also Start/Settings/Control Panel/Network/Protocols/(TCP/IP Protocol)/Properties/DNS. I'm ignoring this other search process here. Now, put 1 non-comment line in C:\WinNT\System32\Drivers\Etc\Hosts (or in C:\Windows\Hosts if you're not using MS WinNT): 127.0.0.2 ronnie.net.au Start Apache again. Then in your web client, eg web browser, try both of these: http://127.0.0.1 http://localhost In both cases you will see a page which starts off: Forbidden You don't have permission to access / on this server. Recall this is interacting with the 'Allow from localhost' discussed above. Change the Hosts file to: 127.0.0.1 ronnie.net.au Stop and start Apache. Edit line 1 of D:\apache\cgi-bin\printenv to be #!/perl/bin/perl. We can use /perl here since Apache and Perl are both on D:. Now try these: http://127.0.0.1/cgi-bin/printenv http://localhost/cgi-bin/printenv They fail! If they appear to work, this will be cached output from a previous attempt: Click Refresh. The first fails because Apache is now using the Hosts file, but on line 656 of httpd.conf, it says: Allow from localhost but 127.0.0.1 is not 'Allow'ed, whereas the second fails because localhost is 'Allow'ed, but not mentioned in the Hosts file! So, edit line 656 of httpd.conf to say: Allow from localhost 127.0.0.1 Stop and start Apache. Now they both work. Frankly, I think the second: http://localhost/cgi-bin/printenv should not work because localhost is not mentioned in the Hosts file. However, as soon as I try http://ronnie.net.au/cgi-bin/printenv Apache insists on connecting to the internet, by dialling out. I dial, and then Apache displays the same page that http://127.0.0.1/cgi-bin/printenv produced. Further, if I put another line in C:\WinNT\System32\Drivers\Etc\Hosts: 127.0.0.2 zoe.ronnie.net.au then both http://127.0.0.2/cgi-bin/printenv and http://zoe.ronnie.net.au/cgi-bin/printenv return nothing unless and until Apache has forced me to dial my ISP. Even then, I get this: Forbidden You don't have permission to access /cgi-bin/printenv on this server. until I put: Allow from localhost ronnie.net.au in httpd.conf at line 656, and restart Apache. Ideally, I would change 'Allow from localhost' to 'Allow from localhost ronnie.net.au' everywhere, not just on line 656. One last patch. I find putting: 127.0.0.1 localhost in the Hosts file makes life easy. For example, the demo clickable_image.cgi will not display the image until you patch Hosts like this, and make the other changes described in the next section. Confused? Join the WWW (World Wide Worried). Your Hosts file is the key to getting virtual hosts to work in Apache. Patching the demos
Re the other demos: Some work, some require the Netscape browser, and some require Unix. Required modulesOnly modules which are shipped with this version of Perl. Author
Home page: http://savage.net.au/index.html CopyrightAustralian copyright © 2001, 2002, Ron Savage. All rights reserved. This POD was converted to HTML by http://savage.net.au/Perl.html#fancy-pom2.pl All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html |
| Top of page |