The root of this rant is an epic journey of installing A and P from the LAMP fraternity, for the sole purpose of testing mod_rewrites.
I downloaded Apache 1.3, already had PHP 4.3.9 installed (and running under IIS6), and went to set it all up. To correctly do that, it took me more than 48h full of anger, cursing and despair. This stuff is so bloody complicated and unfriendly that it’s no wonder MS kicks ass each fiscal quarter.
Now, installing Apache may seem like a breeze, but to actually get it working an inch beyond most basic stuff is voodoo. So, I ran the installer, confirmed that web server is on and went to add support for PHP.
There are hundreeds of tutorials on how to do this (I think I read half of them), but most of them tell you to do several steps.
Installing PHP on Apache
-
Put this line into httpd.conf, at appropriate place:
LoadModule php4_module "c:/php/php4apache.dll" -
Little further below, add this line:
AddModule mod_php4.c -
Finally, make sure to add this:
AddType application/x-httpd-php .php
Some more detailed tutorials tell you to make sure you put the php4ts.dll in the same directory as php4apache.dll or into windows/system(32) directory. Well, for starters, I did not even had the php4apache.dll. Anywhere. When adding PHP support to IIS6, I took the installer file for Win32. After more reading hours, I learned that I took the incomplete build – there is another, complete, 5x bigger.
Thus, after downloading the .zip, I copied the php4apache.dll where needed, added the line, started the Apache and got:
Cannot load c:/php/sapi/php4apache.dll into server: (127) The specified procedure could not be found.
I’m not even gonna start to list all the things I tried. All the pages I read. All the searches. Despair when I read (on several different forums) that some versions of Apache does not work with some versions of PHP. Hours of waisted time. In the end, it was a case that I needed to copy all the .dll from the dlls directory in the .ziped PHP binaries to windows/system32 and then it finally worked. Maybe some other step too, since I did many things trying to solve the problem. There’s a load of unanswered questions about this error message, all over the web. Hopefully they will find their way here and read this.
Setting up Apache virtual hosts
To create virtual host under Apache that allows .htaccess files to be executed, took me “only” two hours of reading docs, web tutorials and trying things out. Same thing under IIS took me 10 minutes (first time I tried it, now 10s). This is the virtual host setup I use now:
<virtualhost *:80>
ServerAdmin aleck@apache
DocumentRoot d:devprojectsaplussite-wp1.2
ServerName apluswp
ErrorLog logs/aplus-error_log
CustomLog logs/aplus-access_log common
# RewriteLog c:rewrite.log
# RewriteLogLevel 9
<directory "d:/dev/projects/aplus/site-wp1.2">
Options All MultiViews
AllowOverride All
# or AllowOverride AuthConfig
Order allow,deny
Allow from all
</directory>
</virtualhost>
Directory part is responsible for allowing .htaccess to work. Even though this is done for default Apache host, it is not propagated to virtual hosts. You need to re-enable it, for each one. Logic tells me that when you do something for default host, it should be replicated to all hosts, unless overridden in the virtual host setup. Not here.
Aftewards, I finally got my rewrite.log, and I was able to recreate the rules I had from ISAPI_Rewrite (IIS friendly mod_rewrite implementation). So, 1h for ISAPI_rewrite rules, two hours for rewriting into different syntax that mod_rewrite understands and 2 days in between just to get a working environment. Not a very good use of weekend time.
As my friend often says – there’s no such thing as free lunch. This software is free, but certainly not cheap.





It is possible to have only one single inside httpd.conf. You should put that one before any and outside it.
The catch is that that section needs to allow access to anything you might need (i.e. you might want to set it for “d:/” if you don’t care about security at all, or simply to the subdirectory where you keep all your virtual hosts). Of course, .htaccess would work in that case, unless it’s overriden in another with “AllowOverride none”.
As for DLL finding problem, I’d never question Microsoft’s ability to solve that better than whoever (lamely, if I may say so) packaged your Apache :-) FWIW, I never had a problem with “shared object” (dynamic library) being found on GNU/Linux system I use.
And finally, as for “free”, it’s not about price, it’s about freedom, at least for some of us “free software” geeks.
Another thing: Apache is built using “Unix philosophy” which goes something like: a smaller programs for single tasks, which you later combine. This is in high contrast to Windows practice, where you get big bundles of software with which you can do everything.
You can, of course, talk about you not wanting to switch philosophies because of software, which is correct stance to take (software is there to help you), but that’s actually the reason nothing is being changed in Apache configuration style: there’re many more (big) Apache users which would hate to re-learn the procedure of configuring their software.
On that note, you can get GUI Apache configurators separately. Try eg. http://www.apache-gui.com/apacheconf/index.html (I never tried it, I just heard about it).
Hope any of this helps in your enjoying the Apache :)
GUI configurators, yes. That’s what is needed.
I took regular Apache download from the official page, nothing custom. I did not expect much friendliness, but was still surprised at the amount of time I spent trying to setup few things. Much of my grudge is towards PHP setup, but…
You know, I’m far from afraid of getting my hands dirty in config files (I go and tweak things inside of IIS metabase if needed). But this is not the thing I want to do first time I install something, because it requires me to read docs (lots of them), when I only want to get the thing over with and do my job.
Give me GUI for common stuff, and I will find my way for advanced things. Majority of people are not interested in more than 5% of features in any software. This is the thing Microsoft realized long time ago. Hard core users will find what they need one way or another. (side note: see how Firefox is using the same philosophy with great success).
In this case, while full power of Apache is wanted only by hosting/network admins, the basic options (install, setup few hosts, add PHP, specify 404 page) are something most web designers need.
These things must be made easy to achieve. If I want to setup password protected dirs or rewrite directory paths then I will read the docs (as I did) — because I know that’s not the common thing to do.
In any case, thanks for the link Danilo, I will certainly check this out.
Aleksandar, as I said, it’s completely right position to take, and I agree with it. After all, one of core Gnome policies (in which I’m heavily involved) is having a system which Just Works.
I only mentioned that you should expect to find separate tools for such things with software that originated on Unix systems.
One of the problems in an educational environment is that we often cannot afford to purchase the likes of ISAPI_Rewrite.
I have a class of web developers that are using Apache / Xitami / IIS to serve pages. They have not looked at the mod_rewrite rules yet (something I want them to do) in X/I/A but the problem with IIS is that I’d need 20 licensed copies of the dll to be legal.
I’m personally using Apache as it gives me the flexibility of only making minor changes (the c:/ to something like /usr/…) when i move an environment from Windows to OS X to Linux to Unix :)
One of the things I use is the XAMPP system that installs Apache, mySQL, PHP, phpMyAdmin, and a few other items in one easy hit. The students love it, and it gives them a nice stable installation to start their testing, development and work on.
I am going to have to look at the GUI configuration systems for Apache though.
I would like to see if I can get educational licenses for the likes of ApacheConf (free?) and ISAPI_rewrite.
Likely — not very :(
Adrian, I wish I read this sooner. :) I found XAMPP through Google and it sure seems like good starting point.
As for ISAPI_Rewrite — I have used free version. From what I read, it is identical to pay version in basic functioning, except that you can’t use it per site. It works for all sites unconditionally.
This can create problems when you work on multiple sites (especially if one of those is .asp based), as httpd.ini is applied to all. I did not try, but with all the experience from last ew weeks, I believe that you can prevent this using
RewriteCondthat checks for proper site name.I just went through the same thing…the thing that resolved all the Cannot load c:/php/sapi/php4apache.dll problems was I was trying to install it as a service. All services default to a local service which do not have network rights. I needed to change the apache service to one that has the proper rights.
hi
i am running window 98 i wanna configure php4 with apache_1.3.33-win32-x86-no_src
this is my http.conf file :
#
# …
#
error is :
Syntax error on line 195 of c:/program files/apache group/apache/conf/httpd.conf
:
Cannot load c:/php/sapi/php4apache.dll into server: (1157) One of the library fi
les needed to run this application cannot be found:
Note the errors or messages above, and press the key to exit.
plz help me out
i’ll be greatful to you
thanxs
Sachin, please don’t post entire file contents like this.
If you have copied all the .dll like I wrote, then you need to check whether you have
c:/php/sapi/in the PATH (can’t recall how is that done in Win98). Other than that, I have no ideas.ok, I stumbled into this site the same way as the originator of this article stumbled in the zillions of other sites probably. I used to think of me as an experienced computer user, both as programmer as installer, so, like a few 1000 other ppl I probably made the same mistake as everybody that ran into the:
Cannot load c:/php/sapi/php4apache.dll
problem that has been covered in zillions of articles around the net, and that didn’t help me much further the last 3 days.
The mistake was quite simple:
RTFM —-> Read The &*(&@^(&*@ Manual(s)
everything that has to be done to get it working is addressed in the manual, buit as “experienced” user I (and with me many other maybe) tend to skip passages that (after reading them later) contain VERY important pieces of information.
So After 2 days of cursed failures and many attempts and reading a lot of pages I decided to:
Completely uninstall php and apache, remove the hand made copies of all conf,ini, dll files I placed in various windows directories (system32!!) deleted the two install directories completely, removed the downloaded apache/php containers and carefully removed everything that even by far smelled like php and apache from the registry.
Now I dressed up like a complete noob and did the following:
downloaded apache 1.3.33 from http://www.apache.org (I’m in a developers environment so I took the warning about not installing apache 2.x there serious)
installed the thing using the setup launcher and only changed the install path (in my case to d:\apache)
in the httpd.conf I changed the document root to:
D:\web.
I tested the installation by going to 127.0.0.1
and that popped up the everything is working page.
So that part was completed succesfully.
Now I downloaded the php4.3.10 ZIP package from:
http://www.php.net/downloads.php
and unzipped it to D:\php
I started to read the suggested install.txt file from point 1 (not skipping to the apache part like I used to, and skipping the most importantr sentence in THAT part also :
»» Note: You should read the manual installation steps first!
while reading the windows installer part I read the conclusion:
Warning
Be aware, that this setup of PHP is not secure. If you would like to have a secure PHP setup, you’d better go on the manual way, and set every option carefully. This automatically working setup gives you an instantly working PHP installation, but it is not meant to be used on online servers.
And being a NOOB this time that scared the &&&*(^ out of me, so I read on
while reading through the manual installation I suddenly stumbled upon the next sentence, a line I didn’t see b4 in all my trials:
Note: In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g. C:\php).
So I did just that.
After this I just followed the instructions, copied the php-recommended file to php.ini in windows. copied the php4ts.dll file to the d:\apache\bin changed the docroot to the same d:\web as in httpd.conf
I went on reading : Apache 1.3.x on Microsft Windows
and added the stuff as suggested for a (better)apache module to httpd.conf.
(changed the
LoadModule php4_module “c:/php/sapi/php4apache.dll“
to
LoadModule php4_module “c:/php/php4apache.dll“
obviously (I’m not THAT big a noob :) )
now i did a net stop apache and a net start apache and LOW AND BEHOLD, it didn;t give me errormessages anymore and I could go to 127.0.0.1 and deeper into some sample php directories I had placed under d:\web.
everything worked fine.
I have been fighting this problem for several hours under IIS 6 and Windows Server 2003, and I think I have it a little more nailed down. I am working with PHP version 4.3.11.
Microsoft’s article on this topic is at: http://support.microsoft.com/default.aspx?scid=kb;en-us;163166. It clarifies for us that the one and only problem going on here is that IIS cannot find php4isapi.dll. Now, be that correct or not, here are the factors that I tested in resolving this problem:
There is a space in the path to the .dll file, which is cautioned against in PHP’s install.txt. Did not matter.
php4ts.dll was not in my windows folder anywhere. Did not matter.
The contents of the dll and sapi directories need to be put in their parent, php-4.3.11-Win32/. This did matter. I cannot say if both directories need to be emptied, or just one, but both are safe. Just to be clear, I did a test while controlling for this variable explicitly. This isn’t just one of the several things I did — I tested this in particular.
NTFS permissions were by default unfriendly. In my case the IUSR account is part of Users, which has read ability. Did not matter.
IIS was not restarted _properly_. For a long time I tried clicking the stop & play buttons in the IIS Manager. This did not do the job. I had to run the “iisreset” command (no parameters) from the console. This did matter.
Web Service Extension has to be set up correctly. Remember to do this after you have dumped the dll/ and sapi/ folders into their parent. You should also make sure to set up the extension mapping without the sapi/ part of the path. This did matter.
The php.ini file was old. This did matter for correct operation, but a phpinfo() will still come back even if you are using an old config (it will just be misconfigured).
Also, I would personally discourage putting your dlls in the system32 directory. Although that may work, it will be hard to keep version control sane. The thing that weirds me out about this is that with PHP version 4.3.7, I didn’t need to move the contents of the dll + sapi folders. I don’t think this is the last word on the case, but I hope it helps someone.
To recap: move your dll + sapi contents up one, enable web service extensions + set your php4ispai.dll path right, then run iisreset (not the GUI restart).
It is obvious that this same problem can have many different causes thus I’m grateful to both Arthur and Peter for taking the time to write here. I hope they will help some poor soul going the same way we did.
As for IIS restart Peter — when you deal with .dlls you must fully restart IIS. Start/stop have no influence of dll locking — I develop daily on ASP/IIS and iisreset.bat is on my desktop. :)
I’ve returned to say that I was fooling myself in thinking I had this working, and as it turns out I now think it impossible to run 4 and 5 in parallel on IIS. I was close — there were actually two engines running, but they were sharing their config file, so it wasn’t the real mccoy.
The kicker is that PHP 4 has the same methodolgy to find its config as PHP 5 — they just didn’t document it until PHP 5. So there’s really no way to get them to use separate configs.
There is a suggestion on how to do it on bugs.php.net (http://bugs.php.net/bug.php?id=28448), but it doesn’t seem to actually work (see my comment there). If anyone gets this to work for real, congrats. Myself, I’ve bit the bullet upgraded everything to PHP 5.