Apache 2.0.50, PHP 4.3.8, mod_rewrite and WordPress 1.5????
anujkp
Status: New User - Welcome
Joined: 04 Mar 2005
Posts: 4
Reply Quote
I need some help here from the experts.

I am running a webserver on a WinXP box. Apache, MySQL, PHP installed.

Anyway, for my installation of Wordpress I am getting some errors most probably to do with mod_rewrite.

I looked at my httpd.conf file and it has the '#' in front of LoadModule rewrite_module modules/mod_rewrite.so removed, so I'm pretty sure mod_rewrite is enabled. In addition, my configuration file for my Gallery says that mod_rewrite is installed.

However when I look at the phpinfo() (in a phpinfo.php) file on my server, it does not give me any data at all about Apache or its installed modules!!! My website Windows based Apache site has been working fine with PHP and MySQL and everything for the past 6 months or more. So I am not sure what's happening with my Apache or more specifically my mod_rewrite.

Anyone have any hints??

I am not do good with any of these and have been surviving so far on excellent help from the net and pure luck. Now I need some seriously technical expert advice and would appreciate any help.

If you need I can put up the contents of my httpd.conf file and/or the output of the phpinfo().

Thanks a million in advance.

<edited out urls for users protection: don't give links to your site when you have phpinfo.php up :: mods>
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
You don't appear to have any modules loaded on your Windows Apache 2 installation. Your other Apache 1.3 for the gallery site is correctly configured, with the mod_rewrite module.

By the way, leaving phpinfo.php for anyone to look at is an open invitation to get hacked.

Did you install Apache / php / mysql etc on the Windows box as separate executables, or did you use one of those all in one installers like XAMPP?

Hopefully you installed each component from binaries, otherwise it's a pain to try to unravel the XAMPP stuff.

It looks like you installed the PHP cgi module instead of doing it with:
LoadModule php4_module c:/php/sapi/php4apache2.dll

It's hard to say what else was done, but that's not a promising sign.

When you enable a module, you have to restart Apache for it to take affect, by the way.

it's easy to test mod_rewrite, you just make a file called:
test.html

and make a rewrite rule that rewrites junk.html to test.html, which should display the test page. If that simple thing doesn't work, nothing more complex will work.
Back to top
anujkp
Status: New User - Welcome
Joined: 04 Mar 2005
Posts: 4
Reply Quote
Hi jeffd, thanks for taking out the time to reply.

I think I ended up getting more confused by your reply though. GUess I learned there are more things I do not know. :)

:: Quote ::
You don't appear to have any modules loaded on your Windows Apache 2 installation. Your other Apache 1.3 for the gallery site is correctly configured, with the mod_rewrite module


I just have one Apache 2.0.50 running. In fact I didnt know it was possible to have 2 servers running on the same box. So the gallery and the website and everything is running off Apache 2.0.50 . I have virtual servers for 2 sites , www.mysite.com and subdomain.mysite.com set up in the virtual servers section of my httpd.conf file.

Also, I was curious how u saw the phpinfo on my site as I didnt put up the info on my previous post. Thanks for the tip about not putting it up for all to see. I really shouldnt be messing with webservers.. I'm trying to learn as i go.

I installed Apache, PHP and MySQL separately.. all one by one.

:: Quote ::
It looks like you installed the PHP cgi module instead of doing it with:
LoadModule php4_module c:/php/sapi/php4apache2.dll


I dont have a c:/php/sapi directory at all.. and should this LoadModule go into the Apache httpd.conf file.. i tried but it refused to restart when i added this line.

i'm trying to learn (from the net) how to make rewrite rules to test the mod_rewrite. where does the rewrite rule go into?? httpd.conf file?
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
:: Quote ::
I just have one Apache 2.0.50 running. In fact I didnt know it was possible to have 2 servers running on the same box. So the gallery and the website and everything is running off Apache 2.0.50


The two sites you listed are running on two different servers, one Apache 1.3, on freeBSD. That's the gallery link.

The second site is running on XP, with Apache 2. The freeBSD site is of course correctly setup, with full module support, I assume that's on a professional hoster. The second site I assume is running on your own box.

:: Quote ::
Also, I was curious how u saw the phpinfo on my site as I didnt put up the info on my previous post. Thanks for the tip about not putting it up for all to see. I really shouldnt be messing with webservers..

Like any hacker, I assumed you'd left the phpinfo.php in your root directory, so I typed in yoursite.com/phpinfo.php and got the full readout for each site, including all relevant server paths, file paths, etc. That's a good first step to crack a system. Especially a windows system.

:: Quote ::
I dont have a c:/php/sapi directory at all.. and should this LoadModule go into the Apache httpd.conf file.. i tried but it refused to restart when i added this line.

You have to install PHP correctly in order to have it run as a module. Read the PHP documentation and you'll see the error. You can't install it as a module until you have the files you need installed, with windows you have to add some dll's to your /winnt/system/dll directory, then once it's all done correctly, you can add it as a module.

Your Windows PHP is running as a cgi currently, as I learned from scanning your phpinfo.php document. You have no module support at all, or at least, you don't have any installed modules.

:: Quote ::
i'm trying to learn (from the net) how to make rewrite rules to test the mod_rewrite. where does the rewrite rule go into?? httpd.conf file?

Mod_rewrite is easily the hardest thing to do I've ever come across, except for very basic stuff, it's the densest, most compact type of programming language I've ever seen.

The rewrite rules, once you have mod_rewrite working of course, can go into either your .htaccess file or the httpd.conf file. It's more efficient to run them through httpd.conf, but you can only do that if you control the server, which I assume you do in the case of the windows box.

However, there are some small syntax differences depending on whether the rewrite rules are located in .htaccess or in httpd.conf, which can drive you crazy, especially if the samples you got were intended for .htaccess, which most of the stuff you find on the web will be, since most shared hosting does not give you access to httpd.conf.

Hosting a website on a Windows box is a VERY RISKY, let me repeat, VERY RISKY thing to do. If you don't know windows security, IIS security, and Apache configuration, it's almost impossible to do this securely. Pay for hosting, no problems. All this stuff will work fine, as long as your hoster supports mod_rewrite, not all do, but most do.

If you aren't up on these issues, it's essentially guaranteed that your system is not secure, and shouldn't be up live on the web. For local development purposes it's fine of course, no problem there.

There was also some talk when XP SP 2 came out that it broke Apache, although I never followed up on that, that may have changed from the prerelease candidates to the Gold SP release though, I can't say for sure.
Back to top
anujkp
Status: New User - Welcome
Joined: 04 Mar 2005
Posts: 4
Reply Quote
Oops Jeff ... the gallery link that i had posted was the link for the actual Gallery (the package) website. So i guess that will be correctly configured to the hilt! after all they are professionals.. my mistake.

The windows xp box is my server.

Thanks for the tip about the phpinfo.. am wiser now.

I'll read up on the PHP docs and try and get it corrected to run as a module. Thank you so much for your info.. and advice.

The server I have on my box is just something that i play about with as a hobby. I am not trained in this at all. So I guess it is risky, but again, its not a crucial website. I just hope to learn a bit about all the cool technology and play about with it. Just an experimenter. :)

Again thank you for your info, advice and warnings. Much appreciated. I will research and try and get the PHP and mod_rewrite stuff working. I just might post with more questions!

Hope XP SP 2 didnt break my apache!!
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
anujkp, oh, that explains it, ok.

The real trick here with Apache, PHP, and MySQL is to really read the readme files that come with it, they are quite well documented. Since your MySql is running fine, the main problems are with the Apache and PHP installs. Why you have no modules loaded in Apache is hard to say without seeing the httpd.conf file, and even with seeing it it's hard to say.

However, if you can get php running as a module, you will be halfway there, since then you know you have the module support enabled.

If in doubt, search the Apache website, they have a lot of documentation, although sadly a lot of it really too obscure to be of use to newbies.

The problem with not securing your local Apache Windows server isn't so much someone hacking in your site and posting:
youve been hacked by the zyborg crew
or whatever, it's that if they can hack into your server, they can probably hack into the box, which is probably running with full admin permissions, which lets them do whatever they want, install zombie controls, etc, wipe out your system, and other fun stuff.

Of course, when you try to use mod_rewrite, you have to explicitly state that you are doing this in the directory that contains the main site:

:: Code ::
<VirtualHost *>
   ServerName yoursite
   ServerAdmin webmaster@dummy-host.example.com
   DocumentRoot "c:/websites/yoursite"
   <Directory "c:/websites/yoursite">
      Options +FollowSymLinks
      AllowOverride None
      RewriteEngine On
      RewriteBase /sampleblog/
      RewriteRule  ^([0-9]{4})/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9]+)?/?([0-9]+)?/?$ index.php?year=$1&monthnum=$2&day=$3&p=$4&page=$5 [QSA]
      RewriteRule ^category/?(.*) index.php?category_name=$1 [QSA,L]
   </Directory>
   php_value include_path ".;c:/websites/includes/yoursite"
   DirectoryIndex index.htm index.html index.php
</VirtualHost>

This is just an example of how one virtual hosts listing would be. The key elements for mod_rewrite are:
:: Code ::
Options +FollowSymLinks
      AllowOverride None
      RewriteEngine On


Options +FollowSymLinks is not always required, but doesn't hurt.
Allow override none is only if you also have .htaccess files in that directory which you don't want to run on the local machine. That wouldn't apply in your case, so you wouldn't need that, but it doesn't do anything if you have no .htaccess files.
RewriteEngine On is the critical one, this is what turns on the rewrite engine after you've enabled the module and restarted.

If you don't have this, you can't do rewriting in that directory, it will just ignore your rewrite rules.
Back to top
anujkp
Status: New User - Welcome
Joined: 04 Mar 2005
Posts: 4
Reply Quote
jeffd ... you are a genius and a great help!

I redid my PHP installation to get it to work as a server module rather than a cgi binary. I guess it was working as a CGI because I had installed PHP using the "Windows installer" rather than the recommended manual installation - a long time ago, when I was more clueless than i am right now (if that is possible).

But I got it working as an Apache module. The mod_rewrite is enabled and working. I also got a very pretty decent start on understanding the mod_rewrite from your post, and realised that I needed the <directory> directive within my <virtualHost>. And I managed also to understand the .htaccess file.

This pretty much solves a bunch of problems that I was having.. phew..

I must say I am extremely grateful for your help and advice... Thank you for taking time out, and for sharing your expertise.

Anuj
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
That's great, I wasn't expecting you to get it working this quickly, nice going.

:: Quote ::
a long time ago, when I was more clueless than i am right now (if that is possible)

We're all clueless when it comes to this stuff, the trick is realizing that's the truth of it, and then going on... the real problems start when you think you know what you're doing ;-)

There is a key in your comments however, when one of these packages like PHP recommends you do things a certain way, it's a very good idea to take their advice, since they tend to know what they're talking about.

Congratulations, it's always a good day when you can make something that wasn't working work for you the way it's supposed to.

In the above example, it would probably have been better to put the rewrite rule in the correct <directory>, in this case where you have your wordpress, that way it won't compete with other rewrite rules in other directories, for example:

:: Code ::
<Directory "c:/websites/yoursite/wordpress">
      Options +FollowSymLinks
      AllowOverride None
      RewriteEngine On
      RewriteBase /wordpress/
      RewriteRule  ^([0-9]{4})/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9]+)?/?([0-9]+)?/?$ index.php?year=$1&monthnum=$2&day=$3&p=$4&page=$5 [QSA]
      RewriteRule ^category/?(.*) index.php?category_name=$1 [QSA,L]
   </Directory>

Note the absence of the closing / after 'wordpress'. That's not an accident, it's one of the many things that have to be done exactly right to make apache work correctly.
Back to top
Display posts from previous:   

All times are GMT - 8 Hours