Categories
Computers

Weird Apache2 Error

A couple of days ago, I was trying to update my older netbook, which is now the kids netbook, and I got a bunch of strange errors during the update. A little later that morning, I discovered that my internal web server had stopped working. It’s a pretty vanilla apache install from the debian/wheezy repo. The only mods I’d made were to allow for support of the public_html folder in user directories as well as setting it up for WordPress.

I’d performed an update over the weekend and my guess is that is when it got zooted. When I tried to restart the server I got the following error message:

/usr/sbin/apache2: 1: /usr/sbin/apache2: Syntax error: ")" unexpected
Action 'configtest' failed.

This meant next to nothing to me. I mean, it looks like an error in the compiled image, but that makes no sense. I had an even more cryptic error in the error.log file which I can’t reproduce because I deleted it in the process of getting it running again. But it read similar to the above with a bunch of what looked like Unicode characters after it- in other words, no text but a bunch of symbols. Very weird. Oh, and Google was no help. I seem to be the only one to have encountered this problem.

Ultimately, I was able to get it back by uninstalling and purging all the packages related to apache2. It’s possible it had something to do with the apache2.2-bin package, but I can’t really be sure. All I know is that until I removed everything webserver related, followed by reinstalling, I was unable to get it running again. Before I did that, I archived the configuration directories for apache, php and wordpress so all I’d have to do, hopefully, is replace the stock configuration with my archived settings. As it turned out, that worked.

Ultimately, not a very satisfying conclusion. But it’s running again, so I’ll take it.

Categories
Computers

php5 and apache2 and public_html directories

I finally got around to setting up WordPress on my home server for purposes of tinkering. I decided to install the blog in the public_html directory in my home. The apache2 webserver was already installed and I knew that browsing to the public_html folder worked just fine.

But when I tried to access the WordPress install page, all the browser wanted to do was download it as a text file.

Hmmm.

So I stuck a php file with phpinfo() in the public_html folder and tried to access it. Same result.

OK. So I check for a few things using aptitude and checking the enabled modules in the apache2 setup directory and it looks like everything should work. So I decide to stick the phpinfo() code into a file under /var/www since that’s the document root.

VOILA! The PHP info page pops into view. So, for some reason, PHP is disabled for public_html folders on my machine (a debian/testing installation). Some quick googling turned up the culprit. It was 5 lines in the php5.conf file under the apache2/mods-available directory:

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.    
#    <IfModule mod_userdir.c>
#        <Directory /home/*/public_html>
#            php_admin_value engine Off
#        </Directory>
#    </IfModule>
</IfModule>

As can be seen, there’s even a handy little explanation! After commenting them out and running /etc/init.d/apache2 restart I was finally able to install WordPress on my home machine. Kinda blew the whole “5 minute install” thing though.