Two More Apache Tweaks Required After Ubuntu 10.04 Upgrade

Posted on May 3rd, 2010 in Development, Linux | No Comments »

While I was troubleshooting why Apache stopped serving php apps from my home directory, I ran into two more annoyances that required attention. I figured I’d share them as well in case you run into them yourself.

Here’s what I saw when I reloaded Apache:

jkendall@san-diego:/etc/apache2$ sudo /etc/init.d/apache2 reload
  * Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri Apr 30 13:47:38 2010] [warn] NameVirtualHost *:80 has no VirtualHosts
                                                                                    [ OK ]

As you can see, Apache reloaded fine, but I don’t like seeing anything other than [ OK ] when I’m reloading my web server. Let’s tackle these one at a time.

Could not reliably determine the server’s fully qualified domain name

Why is Apache all of a sudden complaining about what’s worked for so long? I’m not sure exactly, but thankfully the fix was simple and easy. Simply adding “ServerName localhost” to /etc/apache2/httpd.conf took care of the first complaint (Big thanks to Mohamed Aslam for his clear instructions on how to get this fixed.).

NameVirtualHost *:80 has no VirtualHosts

The problem boiled down to having NameVirtualHost defined in more than one place. In my case, NameVirtualHost was defined both in /ect/apache2/ports.conf and /etc/apache2/sites-available/default. Commenting out the NameVirtualHost *:80 line in /etc/apache2/sites-available/default did the trick (Thanks to the guys in this Server Fault thread, especially to Ivan, for providing the necessary clues to track this one down.).

After making the above changes, reloading Apache didn’t throw any more warnings. w00t!

Share

Upgrading to Ubuntu 10.04 Breaks Serving php from Home Directories

Posted on April 30th, 2010 in Development, Linux | 5 Comments »

I upgraded to Ubuntu 10.04 this morning and immediately noticed I could no longer serve php applications from my home directory. When I tried to visit one of my projects, http://test.local for example, Firefox opened a download dialog with a message similar to “You have chosen to open index.phtml . . .”

After quite a bit of googling and forum searching, I went to Twitter asking for help. Many thanks to @sypherNL for helping me resolve this one.

It seems that something has changed in /etc/apache2/mods-enabled/php5.conf. If you’re experiencing this same issue, check your php5.conf and see if it matches mine.

<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>

If your php5.conf file looks like the one above, simply comment out the

<IfModule mod_userdir.c>

lines as instructed. Once that’s done, restart apache with the following command:

sudo /etc/init.d/apache2 reload

Clear your browser’s cache and try to visit your site again. I didn’t think the fix took at first, but after clearing cache everything worked just fine.

Related Links

Share