Looking for "localhost" apache server that allows .htaccess - apache

Is there some apache server software out there that can be installed on my Windows PC (for local development purposes) that also allows .htaccess for URL rewriting?
I'm currently using Xampp which does not seem to offer this functionality (although maybe I'm wrong about that).
Any advice would be much appreciated.
Thanks.

You will have to activate mod_rewrite in your apache config. Go to your xampp folder an you will find the httpd.conf file in apache/conf/. Open it an go to the line with:
#LoadModule rewrite_module modules/mod_rewrite.so
Change it to
LoadModule rewrite_module modules/mod_rewrite.so
Save the httpd.conf and restart your apache. Now mod_rewrite should work.

Xampp will do it, you'll need to enable mod_rewrite first.
open the directory you installed Xampp then open \apache\conf\httpd.conf in notepad and search for mod_rewrite.
Uncomment the line by removing the # from the beginning. By default mod_rewrite is disabled on a fresh install.
LoadModule rewrite_module modules/mod_rewrite.so
Restart Xamppp should take .htaccess rules now.

It's true that by default, Xampp on windows does not support URL rewriting.
However it's an pretty easy fix:
In your httpd.conf file, find the line that contains "mod_rewrite" and remove the # in front of it
Again in your httpd.conf file, find all occurrences of AllowOverride None and change it to AllowOverride All
Restart apache and you're done:)

Related

Rewrite Module not Working

I installed last night wamp on my win 7 laptop and started creating a small framework for my projects,
But when I firstly added the RewriteEngine on,it just wasn't working. So I checked to see if the module was on, After I edited the conf file and restarted the server and also checked on apache mods under wamp menu, i confirmed that it was on. So i try to check the page again and I still get an internal server error. So i check the conf file again to check directories permission settup and it seems fine.
So then I go go the error logs and I find Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration. I checked if the .so file actually exist. I dont know what else to try, please help me before i go nuts.
<Directory >
AllowOverride none
Require all denied
</Directory>
<Directory "c:/wamp/www/">
AllowOverride All
Allow From All
Require all granted
</Directory>
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
Since it didn't make sense to me why the RewriteEngine wasn't working (code wise). I suspect there was something wrong with my Wamp installation (it would work in the background even after I close it) even though it was a fresh installation. So I decided to re-install the Wamp server, change the Apache conf file and everything is working fine now.

How do I get my /server-status stats to display on my apache2 installation?

I copied the relevant lines over from another installation but it doesn't work here. I get a 404 generated by the word press that's installed on the server.
<Location /server-status>
SetHandler server-status
Order Allow,Deny
Allow from [my ip]
</Location>
I used to visit http://[old server ip]/server-status and it worked fine. Now I just get a 404 coming out of the wordpress that's installed on the new server.
Is this what happens if the proper mods are not installed in this installation? How can I tell? How can I trouble shoot this? Thanks.
You're probably missing the LoadModule for mod_status. On debian/ubuntu, use a2enmod. If you manage your config directly, just add the LoadModule for mod_status.
The problem was that this config had to go in /etc/apache2/mods-enabled/status.conf
From what I read it seemed to me like it could also go in apache2.conf or the individual site config file but those didn't work for me for some reason.

mod rewrite in apache server and htaccess file

what is the difference between
mod_rewrite.so and mod_rewrite.c in Apache server ? In .htaccess file also we should write mod_rewrite.so or mod_rewrite.c ?
In Apache 2.x, it's normal to just use the .so. For example:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
In Apache 1.x it was necessary to AddModule module.c after loading the shared library .so.

setting up passenger: keeps showing apache default page instead

I am trying to get passenger to work but i keep seeing the apache default page instead. I am using centos 6.3 on an inmotion VPS. Here is what I've done so far:
gem install passenger.
rvmsudo passenger-install-apache2-module
pasted the following code into /usr/local/apache/conf/includes/post_virtualhost_global.conf (this gets loaded into httpd.conf)
LoadModule passenger_module /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/username/.rvm/wrappers/ruby-1.9.3-p194/ruby
<VirtualHost 123.123.123.123:80>
ServerName http://XXXXXX.inmotionhosting.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/username/rails/current/public
<Directory /home/username/rails/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
edit: not sure why this isnt formatting properly. its lined and tabbed fine in the text editor.
in etc/hosts there is the line:
123.123.123.123 XXXXXX.inmotionhosting.com XXXXXX
i restarted apache via sudo service httpd restart in /etc/init.d
still shows apache default page
Any ideas? thanks
I stumbled upon this 1 year old post for the similar problem but none of the comment worked for me. So I'm just adding my 2 cents for those who are looking for some help.
If you are seeing Apache default page, it means that phusion passenger is probably not running. You might have seen a warning message when you started/stopped/restarted the apache server that says the phusion passenger module is already loaded, skipping.
So Apache has skipped the most recent LoadModule line you added in the conf file.
Then check the error.log which is in the directory set for error log in apache config file. (httpd.conf for centos)
In my case, it was complaining that it couldn't find the watchdog in the directory set in PassengerRuby. This confirms that the passenger module loaded is NOT what I just added. This might have happened because I am using RVM now but also installed an old version of Passenger a while ago as a root. So I looked at the config.d directory under Apache root, there was a file "passenger.conf" that was loading the old version of Passenger.
I deleted the file, kept the new LoadModule as is - copied from the instruction Phusion Passenger gave me while installing apache2-module, restarted the apache server, no warning message, and passenger worked.

How do you configure the Apache server which ships Mac OS X?

Mac OS X ships with apache pre-installed, but the files are in non-standard locations. This question is a place to collect information about where configuration files live, and how to tweak the apache installation to do things like serve php pages.
Apache Config file is: /private/etc/apache2/httpd.conf
Default DocumentRoot is: /Library/Webserver/Documents/
To enable PHP, at around line 114 (maybe) in the /private/etc/apache2/httpd.conf file is the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the pound sign to uncomment the line so now it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Restart Apache: System Preferences -> Sharing -> Un-check "Web Sharing" and re-check it.
OR
$ sudo apachectl restart
Running
$ httpd -V
will show you lots of useful server information, including where the httpd.conf file can be found.
To get SSI/includes (mod_include) to work I found I had to edit /private/etc/apache2/users/myusername.conf and change AllowOverride None to AllowOverride All.
Then add the following in a .htaccess file in the root of your site:
Options +Includes
AddType text/html .html
AddOutputFilter INCLUDES .html
httpd.conf is in /private/etc/apache2
Enable PHP by uncommenting line:
LoadModule php5_module libexec/apache2/libphp5.so
/etc/httpd/users contains user-specific configuration files which can be used to override the global configuration. For example, adding "AddHandler server-parsed html" to the <Directory> block in the /etc/httpd/users/*.conf file that corresponds to one user will enable mod_include parsing of HTML files for that particular user's $HOME/Sites directory, but nowhere else.