If you installed Apache on Windows (I like WAMPServer myself) and you’re trying to run Perl scripts, you might encounter the dreaded Internal Server Error (500) and a cryptic entry in Apache’s error log:
[Sat Jun 04 19:01:50 2011] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified. : couldn't create child process: 720002:
[Sat Jun 04 19:01:50 2011] [error] [client 127.0.0.1] (OS 2)The system cannot find the file specified. : couldn't spawn child process:
I realized I had installed ActivePerl to the wrong place, and Apache couldn’t find it (I was able to run my Perl scripts from the command line, just not from Apache). All my perl scripts start with #!/usr/local/bin/perl as the shebang line, since this is what my Linux servers all use. So on Windows, I always install ActivePerl to c:\usr\local and it works great. My earlier mistake was to install ActivePerl to c:\usr\local\perl. So by removing and reinstalling ActivePerl to the correct directory, I thought this would be solved.
Then I was getting:
[Sun Jun 05 07:29:24 2011] [error] [client 127.0.0.1] (OS 5)Access is denied. : couldn't create child process: 720005:
[Sun Jun 05 07:29:24 2011] [error] [client 127.0.0.1] (OS 5)Access is denied. : couldn't spawn child process:
Now I was scratching my head. Access denied? Turns out, even though I had uninstalled and reinstalled ActivePerl to c:\usr\local, there was still a “perl” folder inside c:\usr\local\bin from the earlier installation of ActivePerl. Of course my scripts are looking for \usr\local\bin\perl – so they are finding the FOLDER called “perl” rather than the executable, perl.exe. You can’t execute a folder, hence the access denied error. Once I deleted the erroneous folder, the shebang lines in my scripts directed Apache to the perl executable and my script started working immediately.
So, if you are seeing this error, look very closely at your shebang lines and where they point to. In my case, uninstalling ActivePerl did not fully remove the prior directory structure and that caused problems even when I later reinstalled it to the correct place.