Monday, November 18, 2013

Apache2 Notes

Enabling a module

On seeing this error:

.htaccess: Invalid command 'RewriteEngine'

This indicates that rewrite module is not enabled. In Apache 2, both module and sites are handled in the separated folders under /etc/apache2:


In the *-available folders are the configurations to be used, for instance, here we need to enable rewrite module, we just type

sudo a2enmod rewrite

You see that rewrite.load is in the folder mods-available with the content:

LoadModule rewrite_module /usr/lib/apache2/modules/

You will be notified to restart/reload the Apache service. Do it.

Enabling a website

We write the configurations as in sites/available:

        ServerName  localhost

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/foo

        # Logfiles
        ErrorLog  /var/www/foo/logs/error.log
        CustomLog /var/www/foo/logs/access.log combined

Make sure there is a logs folder

cd /var/www/foo
mkdir logs

And then enable the website

sudo a2ensite 

Just to notice how to disable the website:

sudo a2dissite

Most importantly, enact the changes.

sudo service apache2 restart

No comments:

Post a Comment