Thursday, November 4, 2010

How to enabled mod_rewrite on Apache2.2 and Linux Debian 5 Lenny

Below a little tutorial with an example on how to enable apache mod_rewrite to be able to use htaccess, that is for example necessary to use pretty permalinks in WordPress and Joomla, with URL rewriting. The is no extra download necessary if you have Apache 2.2 already installed and running.


There are two easy steps to activate, install or enable mod_rewrite for Apache 2.2 Web Server. Go in the Command line of your linux. It doesn't matter where you are in the folder structure, but you should either be the root or put sudo infront of the commands, like below to switch to the root user.

1. Type below command and hit enter

sudo a2enmod rewrite
A successful response should be:
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!


2. Restart Apache2.2

/etc/init.d/apache2 restart
Again, use sudo in front of the command, if you not logged in as root user.
You could also use:
/etc/init.d/apache2 stop
/etc/init.d/apache2 start
If you have problems in Linux RedHat you might want to try:
/etc/init.d/httpd restart

Problem: /etc/init.d/apache2 command not found


Another command that could work instead is:
sudo service apache2 restart
Another reason for this error message is that you might not have installed apache2 properly. In this case it helps to delete the old installation and run a clean install via.
sudo apt-get install apache2


Problem: /etc/init.d/apache2 permission denied



If you are not the root user run:
sudo /etc/init.d/apache2 restart
The instructions might also work for other Debian versions and other Linux destributions like Open Suse Linux, Ubuntu, RedHat etc. Let me know if you have problems with the instructions.

0 comments:

Post a Comment