Can not get mod rewrite or mod alias to work in Linux Fedora9

I was creating a test web server.  Our production server runs on FreeBSD without any issues on apache 2.  I tried to start our web server.  Apache works fine, as well as cgi-bin and php.  However, I can not get mod_alias or mod_rewrite working at all.  The virtual hosts are working fine as well.  I see they are loaded in the php info page.  I also do not use any .htaceess files.
ssarkarnetipAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HackneyCabCommented:
The rewrite module is not compiled into Apache 2 by default.

If you compiled Apache yourself, you need to include "--enable-rewrite" in your call to the configure command.

To find out what modules are compiled into your Apache build, run

apachectl -l

(that's a lowercase L for Lima).

If you don't see mod_rewrite.c in the output, then your Apache build does not have the rewrite module you need to make RewriteRule work.
0
HackneyCabCommented:
Oh, and you also want to see mod_alias.c in the output.
0
ssarkarnetipAuthor Commented:
I am trying to run both mod_alias and mod_rewrite as a DSO. I am going to give you my httpd.conf.  It should run as a DSO theoretically.  I am uploading my httpd.conf file.  
httpd.txt
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

HackneyCabCommented:
Have you checked (using apachectl -l) that mod_so.c is part of your Apache build? The mod_so module is included by default in Windows, but not necessarily in Linux.

Also, have you checked that the path /usr/lib/httpd/modules/mod_rewrite.so is correct (same for /usr/lib/httpd/modules/mod_alias.so) because if the modules are on your machine in a different location, LoadModule won't be able to find them.
0
ssarkarnetipAuthor Commented:
Yes, I checked those.  Other dso modules such as php and cgi are running fine.  
0
HackneyCabCommented:
In the httpd.conf file you shared, I can't see anywhere that a PHP module is loaded.

How are you testing the RewriteRule, and what result does Apache give you?

You have a lot of Redirect statements that seem to be using a full path, whereas you should be using a path beginning with a slash from the public web root. So instead of

Redirect 301 /var/www/html/Hmedicine/htdocs/shopping/symptom http://www.hmedicinetest.info/homeopathic/treatment

I believe you should be using

Redirect 301 /shopping/symptom http://www.hmedicinetest.info/homeopathic/treatment

(this assumes that the public web root of the hmedicine site is found on your machine at /var/www/html/Hmedicine/htdocs/)
0
ssarkarnetipAuthor Commented:
I added the load module for php.   They say it is already loaded so it is skipping this module.  I used to have the redirect as you suggested but it did not work.  
0
ssarkarnetipAuthor Commented:
When testing the rewrite module, it does not rewrite.  It does not give any errors.  It simply did not work.  
0
HackneyCabCommented:
Do the rewrite statements work in the form you have them now?

What statement did you use to test the Rewrite directive?

Does this do anything (use on a test server only):

RewriteEngine On
RewriteRule ^/(.*)$ /$1?result=REWRITE-ON

If it works, a request to any page will redirect to the page, but add a query string of "?result=REWRITE-ON" to the end of the URL in the address bar of your browser.

If it doesn't work, what do you see in Apache's logs? On my box, these are found in /usr/local/apache2/logs but they may be in a different place on your rig.
0
HackneyCabCommented:
Actually, thinking about it, that RewriteRule will loop infinitely, so change it to this:

RewriteEngine On
RewriteCond %{QUERY_STRING} !result=REWRITE-ON
RewriteRule ^/(.*)$ /$1?result=REWRITE-ON
0
ssarkarnetipAuthor Commented:
This what the error logs say when I did that.  No errors were reported per se.  It did not do anything on the server.  This is a normal error for the page that I was on.

I went to www.hmedicinetest.info/homeopathic to see if anything happens.

[Thu Apr 15 15:29:49 2010] [error] [client 64.134.188.50] PHP Notice:  Undefined
 variable: s_description in /var/www/html/Hmedicine/htdocs/shopping/sidebar.php
on line 63, referer: http://www.hmedicinetest.info/homeopathic/
[Thu Apr 15 15:29:49 2010] [error] [client 64.134.188.50] PHP Notice:  Undefined
 index:  query in /var/www/html/Hmedicine/htdocs/homeopathic/search.php on line
33, referer: http://www.hmedicinetest.info/homeopathic/
[Thu Apr 15 15:29:49 2010] [error] [client 64.134.188.50] PHP Fatal error:  Call
 to undefined function mysql_connect() in /var/www/html/Hmedicine/htdocs/shoppin
g/connection.php on line 8, referer: http://www.hmedicinetest.info/homeopathic/

  These are some php errors which are okay.  The page is not redirecting or doing anything.
0
HackneyCabCommented:
I'm afraid I don't know what else to suggest. If the modules are loaded, then the rewrite should have an effect. And if the modules aren't loaded, then I believe you should get a 500 status "internal server error" message when you try to request a page.

So I don't know where the problem lies.
0
Brad HoweDevOps ManagerCommented:
Hi,

Add the lines with -> to httpd.conf for your logging and rewriting.
...
    CustomLog logs/woodwayflooring.com-access_log common
->              RewriteEngine On
->              RewriteLog /logs/rewrite.log
->              RewriteLogLevel 9
->              RewriteMap escape int:escape
->              RewriteRule ^(.*)$ /$1 [R=301,L]
</VirtualHost>

The above rule won't do anything...... but it will write to the  /logs/rewrite.log so you can see if the engine is working.

Let us know if you have any issues.
Hades666
0
ssarkarnetipAuthor Commented:
Okay,  I was getting a configuration error in the log files.  Also, the virtual host is not putting the log file where I specify.  It seems to be using the global variable in putting the log file.  It is putting it in the /etc/httpd/logs.  It should be putting it in the /var/www/html/Hmedicine/htdocs/ area.

This is the error log.
  [Thu Apr 15 17:19:05 2010] [notice] SIGHUP received.  Attempting to restart
[Thu Apr 15 17:19:05 2010] [warn] module php5_module is already loaded, skipping
[Thu Apr 15 17:19:05 2010] [notice] Digest: generating secret for digest authent
ication ...
[Thu Apr 15 17:19:05 2010] [notice] Digest: done
Configuration Failed
Configuration Failed
Configuration Failed

This is the custom log.
[Thu Apr 15 17:28:33 2010] [error] (2)No such file or directory: mod_rewrite:
 could not open RewriteLog file /logs/rewrite.log

0
HackneyCabCommented:
Change the path of the RewriteLog directive to a path that suits you (and to which your Apache process will have permission to write).
0
ssarkarnetipAuthor Commented:
I tried that.  When I put that code into the configuration. Apache dies.  It is giving an error that the configuration fails.  It is not starting at all.
0
Brad HoweDevOps ManagerCommented:
That is because you have it written in your httpd.conf :/ .
I would suggest to start reading over it throughly.

EXCERPT FROM YOUR ATTACHMENT
------------------------------------------------------------------------------------
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# Don't give away too much information about all the subcomponents
# we are running.  Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/httpd/"
------------------------------------------------------------------------------------

In this case ServerRoot  = "/etc/httpd/" there for if you try to write to /logs/rewrite.log and the folder /logs doesn't exist then you will get that error. With that said, remove the / as it says above and try again.

Cheers,
Hades666
0
ssarkarnetipAuthor Commented:
This is a test server.  Do you guys think that I should remove these rpms and start over with the installation of apache and php.  I know removing rpms is pretty straight forward.  I did this to install the packages.

yum install apache
yum install php

  Do you think there should be anything else that needs to be done with an installation?
0
Brad HoweDevOps ManagerCommented:
This is not an installation issue.  It is a configuration issue.

With that said, I would start be going over your httpd.conf since is is the default one done during the install of apache and most of the time has a ton of usuless crap that is not needed.

I would also suggest taking a look at the apache documentation if you are going to be putting this into production as this more then just a simple rewrite issue.

http://httpd.apache.org/docs/2.1/

Im going to bed, see you tomorrow.

Cheers,
Hades666
0
ssarkarnetipAuthor Commented:
My freebsd works prefectly in production.  The main difference between the two is the document root is in the same place on the virtual host.  Also the only dso module in the production version is php.  I am going to do a total emulation of my production httpd.conf and work from there but I do want to add mod_rewrite  and mod_alias as a DSO.
0
ssarkarnetipAuthor Commented:
I am getting mod rewrite to work but not correctly.  I am going to double check my production httpd.conf to my test http.conf to make sure everything is correct.  I am also going to get rid of all the modules that are not needed in the default httpd.conf.  The Rewrite Log directive is working now.  I am definitely closer to getting everything working.
0
ssarkarnetipAuthor Commented:
I get this error message in the rewrite.log.  It is obviously adding an extra / to the rewrite.  I am trying to figure out where that is happening.  It may be a global variable somewhere.  I actually have this httpd.conf file working in BSD.   A BSD conf file should work the same as linux conf file.  I have removed many of the unnecessary things in the default file.  Of course, I could have easily missed something.

 (2) rewrite '/index.html' -> '//index.html'
(2) explicitly forcing redirect with http://www.hmedicinetest.info//index.html
(1) escaping http://www.hmedicinetest.info//index.html for redirect
 (1) redirect to http://www.hmedicinetest.info//index.html [REDIRECT/301]
0
ssarkarnetipAuthor Commented:
 The problem is solved.  It actually had to do with the apache.conf.  It calls it differently in Fedora than FreeBSD.  I had to go to a php.conf called from the httpd.conf.  I had to modify this php.conf.  Once it was modified everything worked great.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.