Enable mod rewrite zentyal

July 13, 2021 . 3 MIN READ

So you’ve installed apache and the rest of your lamp system in Ubuntu, and you’re needing to do some configuring. You’ve got some virtual hosts you need set up and some modules you need enabled. You can dive into the config files and enable everything that way, however apache comes with some nice methods to do this for us. Lets say we want to enable the rewrite module. If you browse the directory structure you will see there is “/etc/apache2/mods-available” and “/etc/apache2/mods-enabled”. This is pretty self explanatory, the trick is mods-enabled directory is really just symbolic links to the modules in mods-available.

Enable Apache Module

Ok, so now that you know the inner workings, here’s how to enable an available module from the terminal without getting our hands too dirty:

copy

sudo a2enmod rewrite

That wasn’t too bad! Also you can run just “a2enmod” and it will print out all available modules and ask you to type in the one you want.

Enable Apache Site/VirtualHost

Ok, now you have a site you need enabled, “mynewsite”. You’ve already added “mynewsite” to your host file (/etc/hosts). Now you would create a new site file in “/etc/apache2/sites-available” called “mynewsite” and add your virtual host config:

copy

sudo pico /etc/apache2/sites-available/mynewsite

I’ll let you handle the details of your new site’s virtual host config and move on. Now we can call apache’s tool to enable this site (essentially tell apache to create a symbolic link in sites-enabled):

copy

sudo a2ensite mynewsite

# running just a2ensite will print available sites and allow you to key in the site you want

And finally restart apache, and we’re done!

copy

sudo apache2ctl restart

Now after all of this if you need to disable a module or site you can run “a2dismod” or “a2dissite” accordingly. Thats it! You’re enabling and disabling apache modules like a pro!

 

 

 

 

 

http://www.unixmen.com/how-to-enable-and-disable-apache-modules/

 

For  Debian / Ubuntu Linux you can enable or disable any apache module using a2enmod and a2dismod. You don’t need to edit the conf file for that unless you are having some problem with this method. The syntax of these commands is really simple. For centos and other redhat based distributions we don`t use a2enmod and a2dismod, but  another  methode is used to enable and disable modules in apache.

 

For  Debian / Ubuntu Linux

Ubuntu and debian comes with two scripts:
1-a2enmod is a script that enables the specified module within the apache2 configuration. It does this by creating symlinks within /etc/apache2/mods-enabled.

2- a2dismod disables a module by removing those symlinks. It is not an error to enable a module which is already enabled, or to disable one which is already disabled.

To enable a module:

sudo a2enmod module_name

To disable a module:

sudo a2dismod module_name

For instance, to enable mod_expires, execute sudo a2enmod expires in the terminal. If you see the following output, you can be sure that it has been enabled.

pirat9@pirat9-pc:~$ sudo a2enmod expiresEnabling module expires.Run ‘/etc/init.d/apache2 restart’ to activate new configuration!

To disable mod_expires:

sudo a2dismod expires

Restart the server after enabling the module.

 

sudo /etc/init.d/apache2 restart

For Centos/Fedora and other redhat based linux distribuntions:

For centos/ fedora and other redhat based distributiosn, things work different than in Ubuntu/ Debian, you need to modify *.conf file stored in /etc/httpd/conf.d/ directory. So for example if you don`t want to use the module expire, to disable this module, you need to rename  expire.conf to mod_expire.bkp and then restart apache.

If you want to enable the module  again simply rename it to it original name and then restart apache.

Example: To enable module expire, we need to rename mod_expire.bkp to the original name :  mod_expire The command will be:

# cd /etc/httpd/conf.d/# mv mod_expire.bkp expire.conf# /etc/init.d/httpd restart

http://trentrichardson.com/2011/06/17/enabling-apache-sites-and-modules-in-ubuntu/

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *