Apache sites not working after upgrade to Ubuntu 13.10

With new Ubuntu 13.10 Apache has new naming scheme for sites configuration files. Because of this your virtual servers might stop working, showing default site, which is “It works!” page, or whatever you have configured for your web server.

To fix the problem, you have to delete all old links in /etc/apache2/sites-enabled (maybe keeping 000-default.conf if you like), rename all site configuration files, residing in /etc/apache2/sites-available, to have .conf postfix, and then enable it again by manually creating a symbolic link to sites-enabled, or using a2ensite tool.

You can also use this simple shell script:

for i in `ls -1 /etc/apache2/sites-available | grep -v -e '.dpkg' -e '.conf$'`
do
   rm /etc/apache2/sites-enabled/$i
   mv /etc/apache2/sites-available/$i /etc/apache2/sites-available/$i.conf
   a2ensite $i
done

That should do the trick. Note that a2ensite accepts only the site name, without .conf postfix.

[Linux] PHP not working in userdir (public_html)

Today I wanted to give my users possibility to test their PHP scripts, but without all the fuss with creating virtual hosts for each one of them. My first and obvious choice was userdir – user creates public_html directory in his home dir, puts there files, and those files are accessible via http://servername/~username/ URL. To enable this behavior you only have to enable userdir module (a2enmod userdir), and remember to set correct permissions to the userdir (chmod +x $HOME) and public_html (chmod 755 $HOME/public_html). I did this, and everything was working fine, except PHP scripts – browser wanted to download them instead of displaying proper processed content. It appeared that apache in Debian has by default PHP disabled for userdirs. To enable scripting in this dirctory, open file /etc/apache2/mods-enabled/php5.conf, find that piece of code:

    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>

and disable it, either by deleting or by commenting it out (precede each line with # sign). You can also change php_admin_value engine setting to On, but if you do that, you will be unable to turn off PHP engine in .htaccess files.