Error starting Apache with PHP module on Windows: "Cannot load php5apache2_4.dll into server: Access is denied"

6,064

Facts and Observations

Let’s analyse the facts:

  1. It works with an extension other than typical executable/code extensions like .dll, .exe, etc.
  2. It does not work with a different filename
  3. It worked just fine with a previous version; only the latest version is having trouble
  4. It works just fine in safe-mode
  5. Safe-mode disables all non-essential drivers and service
  6. It shows no locks or open-handles
  7. It says access denied
  8. It cannot be moved, opened, copied, etc.

Analysis

Points 1-3 indicates that something about the contents of the file are triggering the problem. This sounds a lot like some sort of anti-virus program throwing a false-positive.

Points 4-6 point to some sort of service or driver that is causing the problem.

Technical

Security software, like anti-virus programs usually have to run at a low-level to avoid letting malware sneak in, so they use drivers and run under the System process. This prevents most programs from being able to detect that a file is locked by the security program (which is why Unlocker could not find any open handles), and even if they can, they only show that System has it open which isn’t very helpful.

Application and Explanation

You said that you had AVG installed at one point, but uninstalled it. Apparently AVG did not uninstall completely (missed a reboot?) and so its drivers was left behind.

So now, whenever you access a file, the driver locks it to scan, but because the rest of the program is gone, there is no way for it prompt you if it thinks the file is suspicious. If the program were still installed, it would show a prompt and ask you want to do (or more likely these days, automatically quarantine/delete the file to “protect” you). Since the program is gone, the driver component sits there waiting, while keeping the file locked.

Since you had uninstalled AVG a while ago, it probably doesn’t have the latest definitions (if any?), so it would not be able to leave the latest version of php5ts.dll alone, and threw a false-positive, thus locking the file with no way of telling it knock it off.

AVG

I don’t know if AVG ever complained about this specific version of php5ts.dll when it first came out, but it doesn’t now.

Also, I don’t know if AVG is known for having a lot of false-positives, though I’m sure I’ve read that about some AV vender; but a cursory check seems to indicate that searching for false positive has at least 33% more hits for AVG than other AV vendors.

Advice for the Future

This problem occurred because AVG did not uninstall completely and left remnants behind. Unfortunately this is an all–too-common problem. In the future, when uninstalling any software be it anti-virus programs, printer drivers/software, etc. always check if the vendor has provided some sort of removal/cleanup tool/utility (try different combinations of words to make sure you find it).

Most security software and printer vendors, as well as some other software firms and hardware manufacturers will have a (usually small) program that you can download and run to wipe out all traces of their software. Unfortunately, this is usually not built into the uninstaller and must be downloaded manually from their site. Sometimes it will be in the normal parts of their site, sometimes it will be buried somewhere in their support forums. (These are usually compiled from bug-reports from people who found left-over files, registry entries, services, etc. that are left behind by the uninstaller, which is why they are separate.)

In your case, you could have (and still should), use the AVG “remover”.

NB: when searching for a cleanup utility for security software, be careful not to mix it up with a virus-removal tool.

Share:
6,064

Related videos on Youtube

MichaelRushton
Author by

MichaelRushton

Updated on September 18, 2022

Comments

  • MichaelRushton
    MichaelRushton over 1 year

    I'm having some difficulty installing Apache 2.4.7 with PHP 5.5.7 on Windows Vista Service Pack 2.

    When trying to start Apache, I'm getting the error:

    Syntax error on line 176 of C:/Program Files/Apache/conf/httpd.conf: Cannot load C:/Program Files/PHP/php5apache2_4.dll into server: Access is denied.

    I've looked at related topics, both on here and other sites, but the only issues I can find are where the error is "The specified procedure could not be found" or "The specified module could not be found", neither of which are relevant to my problem.

    As you can see by the download links, I'm using Win32 versions of both Apache and PHP and the thread safe version of PHP. I've made sure that the C:/Program Files/PHP/php5apache2_4.dll file exists and reinstalled the Visual C++ Redistributable (http://www.microsoft.com/en-gb/download/details.aspx?id=30679; VSU_4\vcredist_x86.exe). I've also tried moving both the Apache and the PHP folders outside of the Program Files but this didn't resolve the issue.

    As the error I'm getting is "Access is denied", I assume the issue is one of file permissions, but I'm not sure what permissions to change and what to change them to. So any assistance I can get will be much appreciated.

    Edit

    After some testing it seems that this problem only arises from PHP 5.5.4 onwards. Rolling back to 5.5.3 resolves the issue.

    Edit 2

    The issue seems to be that php5ts.dll cannot be read despite showing readable permissions. Even when programs are "run as administrator", the file cannot be opened (but can be deleted and renamed). The file can be opened if the extension is changed to something other than dll or exe, and other files in the same folder can be opened even if renamed to php5ts.dll (replacing the original).

    • Lawrence
      Lawrence over 10 years
      Do you have UAC turned on ? Tried turning it off ?
    • MichaelRushton
      MichaelRushton over 10 years
      Yes. Access is still denied. Also, if it's relevant, Apache is being run as a service.
    • Synetech
      Synetech over 10 years
      I just downloaded and installed those two files and after downloading a copy of msvcr110.dll and compensating for 2.4’s new permissions change, I was able to load a test PHP script without issue. The problem is likely in your configuration files (most likely your Apache httpd.conf file). Back when I was trying to “portablize” a my own WAMP stack, I fixed the problems by using Process Monitor to see what files and paths were being accessed during Apache’s startup to check for errors.
    • MichaelRushton
      MichaelRushton over 10 years
      After following some suggestions by harrymc (comments in the answer below) the problem seems to be with the php5ts.dll file which my system doesn't seem able to access by any means. I just download the zip from the link in my question to my Downloads folder, extract the files, and find that php5ts.dll is unreadable despite being shown to have the right permissions to be read.
    • Synetech
      Synetech over 10 years
      I would say that it is some anti-virus program or something that is locking the file, but I really don’t see why it would be locking that one, specific file. Just forget your current installation for a moment and extract the files from the archives to another location altogether (e.g., the desktop). Can you access php5ts.dll there? Shut Apache down and see if you can get it to work as a daemon instead of a service: i.e., httpd.exe directly. )You’ll have to make three or four modifications to the default httpd.conf file; I can specify which if needed.)
    • MichaelRushton
      MichaelRushton over 10 years
      I've tried in C:\, in C:\Program Files, in C:\Users\User\Downloads, and on the Desktop. File access to php5ts.dll is always denied. Apache runs fine when it doesn't try to load php5apache2_4.dll (which tries to load php5ts.dll). I've tried both as a service and by opening httpd.exe directly, as well as with ApacheMonitor.exe (where I'm given the error "The requested operation has failed!" when selecting "Start").
    • Synetech
      Synetech over 10 years
      That is very odd. So you can’t even open it in Notepad or copy it to another folder? Have you had problems with other files being inaccessible? Have you tried to see if you get the same access error with the non–thread-safe version or the previous thread-safe version? Do you have some kind of anti-virus program running?
    • MichaelRushton
      MichaelRushton over 10 years
      I can't copy it or open it in a text editor or the Dependency Walker. I can't upload the file via FTP or HTTP. It worked in PHP 5.5.3; it doesn't work in PHP 5.5.4+. I've turned off UAC, Firewall, Defender, and Norton 360 (and restarted). No luck.
    • Synetech
      Synetech over 10 years
      Open a command-prompt and run these two commands: sc query appinfo and sc query aelookupsvc. What does it say next to STATE:?
    • MichaelRushton
      MichaelRushton over 10 years
      4 RUNNING <STOPPABLE, NOT PAUSABLE, IGNORES SHUTDOWN> for both.
    • Synetech
      Synetech over 10 years
      Doh! It would have matched the symptoms perfectly if one or both of them were not running. Then try checking to see if anything has the file locked. Unlocker is a perennial favorite, and you can either install it to use the shell-extension, or run it “portably” from the command-line. See what, if anything, has the file locked. Also, have you checked if you can access (open, copy, etc.) the file in safe-mode?
    • MichaelRushton
      MichaelRushton over 10 years
      Aha. It opens in Safe Mode. (Also, when not in Safe Mode, the Unlocker says "No Locking handle found", which I assume means the file is unlocked? Makes sense as I can delete it; just not read from it).
    • Synetech
      Synetech over 10 years
      What if anything has it locked in normal mode? Also, see if it is the contents or the name that is causing trouble. If you can access it in safe-mode, make a copy of it to another name like a or a.txt, then see if the copy is accessible in normal mode.
    • MichaelRushton
      MichaelRushton over 10 years
      Nothing seems to have it locked as I can delete it and rename it (in normal mode). If I rename the file name (e.g. php5ts2.dll) it still won't open but if I change the extension (e.g. php5ts.dll2) then it will.
    • Synetech
      Synetech over 10 years
      Okay, getting closer… What about the normal filename? Did you check if there are any locks/open-handles on it when you can’t access it? That is, check php5ts.dll in normal mode.
    • MichaelRushton
      MichaelRushton over 10 years
      I used Unlocker when in normal mode which gave the message "No Locking handle found".
    • Synetech
      Synetech over 10 years
      Two more tests: (1) You said it works if you use a different extension like .dll2. What happens if you use .exe? (2) Make a dummy file (either create an empty file or a text file with some dummy text, or just copy a file you don’t have any problems with), and give it the name php5ts.dll. Does that become inaccessible?
    • MichaelRushton
      MichaelRushton over 10 years
      (1) Cannot open the file when the extension is changed to .exe. (2) Can open a different file when renamed to php5ts.dll.
    • Synetech
      Synetech over 10 years
      So the situation is this, the file becomes inaccessible only under these specific circumstances: a file with that specific contents/pattern of bytes (that version) becomes inaccessible (locked) when it has an executable extension and booted in normal mode. It sounds a lot like a common problem with Windows Explorer and/or Security Essentials locking files. I found that it tends to be associated with the Application Experience service, but that doesn’t seem to apply to you. Try adding the file to Security Essentials’ exceptions list. Does it still lock?
    • MichaelRushton
      MichaelRushton over 10 years
      I don't have Security Essentials but after some digging I found an AVGIDSAgent service that was part of an AVG anti-virus program I wasn't aware of. I uninstalled it and now php5ts.dll is readable and PHP 5.5.7 will run.
    • Synetech
      Synetech over 10 years
      Yup, not a surprise; like I said, it was being locked by a security program, probably due to a false-positive. I can post an explanation of exactly what happened and why, as well as solution to avoid this sort of thing in the future if desired.
    • MichaelRushton
      MichaelRushton over 10 years
      That would be great for future reference. And, of course, you'd get the bounty for it.
  • MichaelRushton
    MichaelRushton over 10 years
    After some digging I found an AVGIDSAgent service that was part of an AVG anti-virus program I wasn't aware of. I uninstalled it and now php5ts.dll is readable and PHP 5.5.7 will run.
  • harrymc
    harrymc over 10 years
    Fine, so problem solved.