Friday, 27 April 2012

Strange PHP/Zend/Apache2 issue

Setting up a new laptop for development on a complex system hardly ever goes according to plan. The same thing happened with me and I ended up getting my entire office involved in figuring out the problem.

I ensure I back up every single thing when I switch systems. I did the same here. I've even contemplated writing a small shell script that can install everything I'll need. But anyway, all that happened perfectly. Everything was installed and we were ready to go.

I fired a browser, hit the URL and lo, the scary 403. At commonfloor.com, we use a pretty cool .htaccess file. And for some reason, apache2 was looking for the file four directory levels above where it was pointing to. It had to look for it at /path_to_home/prog/php/commonfloor.com/another_dir/another_dir/ but it was looking for the file here /path_to_home/prog/. That wasn't even the DocumentRoot inside apache, and the errors being thrown were:

(
13)Permission denied: /home/ashesh/prog/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Gwibberish. The error message wasn't going to lead us anywhere.

What fixed the problem:


  • Set AllowOverride None
  • Ensure libapache2-mod-php5 is installed/loaded [install it using your package manager if not, enable it using sudo a2enmod php5 if your package manager didn't do it already
  • Restart apache2. Hit the URL and groove away in joy!


[I know that the fix is simple but the point is that it's pretty easy to overlook these problems when faced with the task of setting up a new computer.]

The king of fixes: A really cool systems guy like ours. All credits to Goutham ji.



No comments:

Post a Comment