Install A2enmod Fedora

Active6 months ago

How do I enable apache modules from the command line in RedHat? On Debian/Ubuntu systems I use a2enmod to enable modules. For anyone working with Fedora 21. Fedora Linux a great alternative to Windows. Here¹s how to install it on your current PC (assuming you have a standard BIOS).

I've got fresh install of Apache 2.2 on my Vista machine, everything works fine, except mod rewrite.

I've uncommented

but none of my rewrite rules works, even simple ones like

All the rules I'm using are working on my hosting, so they should be ok, so my question is, is there any hidden thing in apache configuration, that could block mod rewrite?

A2enmod Proxy

Jakub ArnoldJakub Arnold
40.8k80 gold badges206 silver badges303 bronze badges

15 Answers

In order to use mod_rewrite you can type the following command in the terminal:

Restart apache2 after

or

or as per new unified System Control Way

Then, if you'd like, you can use the following .htaccess file.

The above .htaccess file (if placed in your DocumentRoot) will redirect all traffic to an index.php file in the DocumentRoot unless the file exists.

So, let's say you have the following directory structure and httpdocs is the DocumentRoot

Any file that exists in httpdocs will be served to the requester using the .htaccess shown above, however, everything else will be redirected to httpdocs/index.php. Your application files in includes/app will not be accessible.

Elangovan
2,2172 gold badges26 silver badges33 bronze badges
Jonathan MayhakJonathan Mayhak
10.7k3 gold badges17 silver badges17 bronze badges

For my situation, I had

in my .htaccess, along with the module being loaded, and it was not working.

The solution to my problem was to edit my vhost entry to inlcude

in the <Directory> section for the site in question.

MrWhite
13.6k3 gold badges35 silver badges64 bronze badges
Mike WazowskiMike Wazowski
2,2411 gold badge10 silver badges2 bronze badges

Try setting: AllowOverride All.

Second most common issue is not having mod rewrite enabled: a2enmod rewrite and then restart apache.

Bhargav Rao
32.7k21 gold badges96 silver badges115 bronze badges
JarrodJarrod
7,5305 gold badges48 silver badges66 bronze badges

If non of the above works try editing /etc/apache2/sites-enabled/000-default

Install

almost at the top you will find

Change the AllowOverride None to AllowOverride All

this worked for me

Paul
7,8882 gold badges22 silver badges45 bronze badges
Martin SaxMartin Sax

In Ubuntu:

Run:

and then:

mod_rewrite will now be enabled!

Amal Murali
64k12 gold badges106 silver badges126 bronze badges
nickleeflynickleefly
3,1451 gold badge21 silver badges29 bronze badges

There are many ways how you can fix this issue, if you know the root of the issue.

Problem 1

Firstly, it may be a problem with your apache not having the mod_rewrite.c module installed or enabled.

For this reason, you would have to enable it as follows

  1. Open up your console and type into it, this:

    sudo a2enmod rewrite

  2. Restart your apache server.

    service apache2 restart

Problem 2

  1. You may also, in addition to the above, if it does not work, have to change the override rule from the apache conf file (either apache2.conf, http.conf , or 000-default file).

  2. Locate 'Directory /var/www/'

  3. Change the 'Override None' to 'Override All'

Problem 3

If you get an error stating rewrite module is not found, then probably your userdir module is not enabled. For this reason you need to enable it.

  1. Type this into the console:

    sudo a2enmod userdir

  2. Then try enabling the rewrite module if still not enabled (as mentioned above).

To read further on this, you can visit this site: http://seventhsoulmountain.blogspot.com/2014/02/wordpress-permalink-ubuntu-problem-solutions.html

Kripa JayakumarKripa Jayakumar

Open terminal and typin a2enmod rewrite, It will enable your mod_rewrite module for Apache.

Then go to /etc/apache2/sites-available and edit default file. (For this you must have writable permissions to this file and sites-available folder.)

Replace below with existing lines 4 to 14

Now restart your apache by /etc/init.d/apache2 restart or service apache2 restart

Take clean URL test again and this time it will be passed.

Gottlieb Notschnabel
5,24116 gold badges57 silver badges99 bronze badges
Umesh PatilUmesh Patil

New apache version has change in some way. If your apache version is 2.4 then you have to go to /etc/apache2/. There will be a file named apache2.conf. You have to edit that one(you should have root permission). Change directory text like this

Now restart apache.

Hope it works.

Ijas Ahamed NIjas Ahamed N
2,5333 gold badges23 silver badges41 bronze badges

<edit>

Just noticed you said mod_rewrite.s instead of mod_rewrite.so - hope that's a typo in your question and not in the httpd.conf file! :)

</edit>

I'm more used to using Apache on Linux, but I had to do this the other day.

First off, take a look in your Apache install directory. (I'll be assuming you installed it to 'C:Program Files' here)

Take a look in the folder: 'C:Program FilesApache Software FoundationApache2.2modules' and make sure that there's a file called mod_rewrite.so in there. (It should be, it's provided as part of the default install.

Next, open up 'C:Program FilesApache Software FoundationApache2.2conf' and open httpd.conf. Make sure the line:

is uncommented:

Fedora

Also, if you want to enable the RewriteEngine by default, you might want to add something like

to the end of your httpd.conf file.

If not, make sure you specify

somewhere in your .htaccess file.

Danny BattisonDanny Battison

I just did this

then you have to restart the apache service by following command

Gottlieb Notschnabel
5,24116 gold badges57 silver badges99 bronze badges
user3470929user3470929

There's obviously more than one way to do it, but I would suggest using the more standard:

Michael CramerMichael Cramer
4,2901 gold badge16 silver badges15 bronze badges

The first time I struggled with mod_rewrite rules ignoring my traffic, I learned (frustratingly) that I had placed them in the wrong <VirtualHost>, which meant that my traffic would ignore all of them no matter how well-written they were. Make sure this isn't happening to you:

# Change the log location to suit your system.RewriteLog /var/log/apache-rw.logRewriteLogLevel 2

These parameters will activate if you perform a graceful restart of Apache, so you can recycle them in and closely monitor the mod_rewrite behavior. Once your problem is fixed, turn the RewriteLogLevel back down and celebrate.

In 100% of my experience, I've found that the RewriteLog has helped me discover the problem with my rewrite rules. I can't recommend this enough. Good luck in your troubleshooting!

Also, this bookmark is your best friend:http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

Garrett EllisGarrett Ellis

Old thread, just want to put that don't set AllowOverride to all instead use specific mod you want to use,

And this line should be un-commented

Refrences

Abhishek GurjarAbhishek Gurjar
6,0657 gold badges28 silver badges35 bronze badges

Use below command

And the restart apache through below command

prasoonprasoon

What worked for me (in ubuntu):

Also, as already mentioned, make sure AllowOverride all is set in the relevant section of /etc/apache2/sites-available/default

BenubirdBenubird
9,16219 gold badges71 silver badges121 bronze badges

protected by CommunityApr 21 '13 at 19:54

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged apachemod-rewrite or ask your own question.