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:
mods-available/ mods-enabled/ sites-available/ sites-enabled/
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/mod_rewrite.so
You will be notified to restart/reload the Apache service. Do it.
Enabling a website
We write the configurations as foo.com in sites/available:
<VirtualHost 127.0.0.3:80>
ServerAdmin webmaster@example.com
ServerName localhost
ServerAlias foo.com
# 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
</VirtualHost>
Make sure there is a logs folder
cd /var/www/foo mkdir logs
And then enable the website
sudo a2ensite foo.com
Just to notice how to disable the website:
sudo a2dissite foo.com
Most importantly, enact the changes.
sudo service apache2 restart
No comments:
Post a Comment