URL Rewrite problem

sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Fri, 2005-05-20 20:05

Hi all

I am having a few problems with URL Rewrite. In the fact gallery wont determine that it is installed. I have followed all the trouble shooting tips, and I have proved that mod_rewrtie is installed and working, as I have loging to seperate log file. All i get is " Apache mod_rewrite is not installed or not enabled". I have tryed tracking down the code actuall does the checks but got a little lost!

Is anyone able to point me in the direction, in to how to find why URL rewrite is failing to find mod_rewrite.

Thank you inadvance

system info-----------------------

Gallery version = 2.0-beta-3 core 0.9.17
PHP version = 4.3.10 apache
Webserver = Apache/1.3.33 (Unix) PHP/4.3.10
Database = mysql 4.1.10
Toolkits = ArchiveUpload, Exif, Thumbnail, Gd, NetPBM
Operating system = SunOS tank 5.10 Generic sun4u
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2005-05-20 22:22

i'm not sure why it can't detect it, but did you try checking the box to force the module to activate?

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Sat, 2005-05-21 07:42

The module is active, as I have it logging. I have not applied any rules, but is states in the log files that it has passed the URL's through, but not done anything to them.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sat, 2005-05-21 08:34

I have the same problem like sittingduck.
mod_rewrite is loaded because it works with another page on the same server but it want not runnig with gallery2 beta3.

Any suggestions? Thanks!

----------------------
Gallery version = 2.0-beta-3
PHP version = 5.0.4
Webserver = Apache/1.3.29 Win32
Database = mysql 4.1

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sat, 2005-05-21 08:39

If you get the "Apache mod_rewrite is not installed or not enabled" error, you would normaly not get the checkbox to force-activate it. You should have an "activate" link in the module admin page.

Now, to your problem... Do you run any firewall software? Try (from your server)
wget http://localhost/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt
Also, you can enable G2 debug (in the config.php) and load the setup page which tests mod_rewrite (which shows the error message). Go to the log and look for any suspicious errors after
<date> [<session id>] fsockopen(<your host>, 80, , , 1)

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sun, 2005-05-22 03:03

On module admin page, there's the two possible actions "configure" or "uninstall" corresponding to module URL rewrite.
- If I click on "configure", I get the error "Apache mod_rewrite is not installed or not enabled"
- I tried to "uninstall" and to reinstall the module but I get the same error
- My Firewall is disalbed

About troubleshooting:
- there's no info about loaded modules in my Gallery phpinfo page and
there is too no additional modules (just blank)
- I added "FileInfo options" to apache config
- At last, I get ther error "The .htaccess file does not exist"

With debug modus enabled:
- I don't find the code mentioned above related to fsockopen

----------------------
Gallery version = 2.0-beta-3
PHP version = 5.0.4
Webserver = Apache/1.3.29 Win32
Database = mysql 4.1

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sun, 2005-05-22 07:52

SusiG, make sure mod_rewrite is loaded - look in the httpd.conf / apache.conf for LoadModule rewrite_module modules/mod_rewrite.so Make sure its not commented out. For debug output; enable it in your config.php

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sun, 2005-05-22 08:44

Refered to my thread above, I use mod_rewrite with a cms application on the same server. So it' loaded and it works.
The problem persists only on gallery2.

Confirmed, mod_rewrite is uncomment in my apache config.

Thanks again!

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sun, 2005-05-22 10:33
SusiG wrote:
I use mod_rewrite with a cms application on the same server

Sorry, I didnt see that.

You havn't provided what the debug output says... It'd be realy nice if you post it (the fsockopen part).

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sun, 2005-05-22 12:36

@ pelle,
thanks for reply!
OK, I found the fsockopen part!

-----------------------------------------
file_exists(c:\www\gallery2\modules\core\classes\helpers/../../../../modules/rewrite/module.inc)
realpath(c:\www\gallery2\modules\core\classes/../../..)
Binding text domain: modules_rewrite ->
c:\www\gallery2/modules/rewrite/locale
file_exists(c:\www\gallery2\modules\core\classes/../../../modules/rewrite/SetupRewrite.inc)
file_exists(c:\www\gallery2\modules\core\classes/../../../modules/rewrite/SetupRewrite.inc)
file_exists(c:\www\gallery2/.htaccess)

fsockopen(localhost, 80, , , 1)
fwrite(Resource id #98, ..., ) fflush(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fgets(Resource id #98, 4096) feof(Resource id #98) fread(Resource id #98, 4096) feof(Resource id #98) fclose(Resource id #98)

fsockopen(localhost, 80, , , 1)
fwrite(Resource id #99, ..., ) fflush(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fgets(Resource id #99, 4096) feof(Resource id #99) fread(Resource id #99, 4096) feof(Resource id #99) fclose(Resource id #99)

file_exists(c:\www\gallery2\modules\core\classes\helpers/../../../../modules/icons/classes/IconsImpl.class) file_exists(c:\www\gallery2-data\cache\module/icons/0/0/0.inc)
fopen(c:\www\gallery2-data\cache\module/icons/0/0/0.inc, rb, 0)
fread(Resource id #102, 4096)
fclose(Resource id #102)

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sun, 2005-05-22 13:05

SusiG, what do get with this request http://localhost/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt ? Sorry for all the questions, but I'm trying to determine if this is a G2 bug.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sun, 2005-05-22 14:19

I get:

FAIL_NO_REWRITE

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sun, 2005-05-22 15:25

Well, then your mod_rewrite doesnt work... Check your apache configuration once again. You might want to take a look in the apache error log too.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Sun, 2005-05-22 16:22

mod_rewrite works, because I use it on mambo for "Search Engine Friendly URLs"
Short url on (mod_rewrite required):
http://localhost/mambo/content/section/1/2/

Short url off:
http://localhost/mambo/index.php?option=com_content&task=section&id=1&Itemid=2

In Apache config:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

 
sremick
sremick's picture

Joined: 2005-05-06
Posts: 47
Posted: Sun, 2005-05-22 17:54

I'm having a similar problem. I know mod_rewrite is installed in Apache, because it works for other users on my webhost AND it was working in G2 beta 2. I just updated to beta 3 and mod_rewrite won't work anymore. I too get "Apache mod_rewrite is not installed or not enabled." Like the others, my only options from the modules page are "Configure" and "Uninstall".

On beta 2 although I also got the "Apache mod_rewrite is not installed or not enabled." message I was still given the option to activate the module anyways, and it worked. Not with beta 3.

Because I have the .htaccess that beta 2 created, that step is happy and it says "Gallery can write to the .htaccess file".

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Mon, 2005-05-23 10:36

SusiG and sremick, get tonights snapshot.

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Tue, 2005-05-24 21:53

sorry I have not been able to give responces to all your suggestions, till work likes to keep me busy

Ok I have upgraded to the latest snapshot, however that did not change the URL rewrite module, but it did update the core, but the problem is still there

In answer the following questions

Quote:
wget http://localhost/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt

I get PASS_REWRITE

Within the debug logs all I can find about URL rewrite is

2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/core/classes/hel
pers/../../../../modules/rewrite/module.inc)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/core/classes/../
../../modules/rewrite/SetupRewrite.inc)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/core/classes/../
../../modules/rewrite/SetupRewrite.inc)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/.htaccess)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] is_readable(/usr/local/apache/htdocs/gallery2/.htaccess)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] is_writeable(/usr/local/apache/htdocs/gallery2/.htaccess)

which to me does not show any sign of a problem.

Thank for everyone help so far

sittingduck

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Tue, 2005-05-24 23:25

I do upgrade core module 0.9.17 to 0.9.18 one on Jesse Mullan's snapshot page, but I always get the same error :(

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Wed, 2005-05-25 08:18

did the same, same error as well

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Wed, 2005-05-25 10:31

SusiG,

SusiG wrote:
I get:

FAIL_NO_REWRITE

What this does is testing mod_rewrite in action, as long as you get FAIL_NO_REWRITE mod_rewrite doesnt work - its an apache issue. Does this test also fail? http://localhost/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt

sittingduck, it'd be great if you could post the fsockopen part too.

sremick, what does this test show you? http://localhost/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Wed, 2005-05-25 10:55

Something strange to add

When I browse to http://<MYDOMAIN>/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt

I get PASS_REWRITE

How ever if I cat that file directly (/usr/local/apache/htdocs/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt)

I get a different result of FAIL_NO_REWRITE

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Wed, 2005-05-25 10:58

I get the same strange results when I view /usr/local/apache/htdocs/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt and ask for it through the web browser

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Wed, 2005-05-25 11:03

The rest of the log file are requested

2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fsockopen(<MYDOMAIN>, 80, , , 1)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fwrite(Resource id #157, ..., )
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fflush(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fread(Resource id #157, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fclose(Resource id #157)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fsockopen(<MYDOMAIN>, 80, , , 1)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fwrite(Resource id #176, ..., )
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fflush(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fgets(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fread(Resource id #176, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] feof(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fclose(Resource id #176)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/core/classes/hel
pers/../../../../modules/icons/classes/IconsImpl.class)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/array/gallery/cache/module/icons/0/0/0.inc)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fopen(/array/gallery/cache/module/icons/0/0/0.inc, rb, 0)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fread(Resource id #199, 4096)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] fclose(Resource id #199)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/array/gallery/smarty/templates_c/%%932032367)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] is_dir(/array/gallery/smarty/templates_c/%%932032367)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/array/gallery/smarty/templates_c/%%932032367)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] is_writeable(/array/gallery/smarty/templates_c/%%932032367)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/array/gallery/smarty/templates_c/%%932032367/v_6)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/templates/local/global.t
pl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] stat(/usr/local/apache/htdocs/gallery2/templates/global.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./templates/local/layout.css)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./themes/matrix/local/theme.css)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./modules/icons/iconpacks/paularmstrongdesigns.com/local/i
cons.css)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./lib/javascript/local/BlockToggle.js)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./images/local/galleryLogo_sm.gif)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/core/templates/l
ocal/SiteAdmin.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] stat(/usr/local/apache/htdocs/gallery2/modules/core/templates/SiteAdmi
n.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/rewrite/template
s/local/SetupRewrite.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] stat(/usr/local/apache/htdocs/gallery2/modules/rewrite/templates/Setup
Rewrite.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(/usr/local/apache/htdocs/gallery2/modules/rewrite/template
s/local/Troubleshooting.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] stat(/usr/local/apache/htdocs/gallery2/modules/rewrite/templates/Troub
leshooting.tpl)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./lib/tools/local/phpinfo.php)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./images/local/xhtml10.png)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./images/local/gallery.gif)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./modules/core/data/local/g2b3-bingo.wav)
2005-05-24 22:45:30 [f72cf17a630ae895a04170eb3dd895ed] file_exists(./modules/core/data/local/g2b3-bingo.png)
2005-05-24 22:45:31 [f72cf17a630ae895a04170eb3dd895ed] touch(/array/gallery/sessions/f72cf17a630ae895a04170eb3dd895ed, , )

This log was enterated when I cliecked the "Test Webserver again" button

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Wed, 2005-05-25 14:46

sittingduck, Rewrite.txt contains FAIL_NO_REWRITE - this is normal. What you see if mod_rewrite works is the contents of Works.txt. Can you please PM me your Gallery URL?

 
sremick
sremick's picture

Joined: 2005-05-06
Posts: 47
Posted: Wed, 2005-05-25 15:09
pelle wrote:
sremick, what does this test show you? http://localhost/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt

From that URL I think you're assuming I run my own server... I do not. I have shared hosting that I pay for.

Anyway, when I modify that URL for where my files are... it doesn't work. Which is strange because the file is there:

http://vtbsd.net/gallery/modules/rewrite/test/mod_rewrite/gallery2/

When you click on it you get:

Not Found
The requested URL /gallery2/modules/rewrite/test/mod_rewrite/gallery2/Works.txt was not found on this server.

The file has 644 permissions and the gallery2/ folder it is in has 755 permissions.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Wed, 2005-05-25 18:36
pelle wrote:
What this does is testing mod_rewrite in action, as long as you get FAIL_NO_REWRITE mod_rewrite doesnt work - its an apache issue. Does this test also fail? http://localhost/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt

also:
FAIL_NO_REWRITE

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Thu, 2005-05-26 08:53

Right I have put my debug hat on, and I'm getting into what the problem is. The problem is not that the wrong code is return in Rewrite.txt. The problem is that RewriteHelper.class when is requests the the file with this line of code

if ($headers == 'HTTP/1.1 200 OK' && $body == "PASS_REWRITE\n") {
            $ret = GalleryCoreApi::setPluginParameter('module', 'rewrite', 'needOptions', 'false');
            if ($ret->isError()) {
                return array($ret->wrap(__FILE__, __LINE__), null);
            }

            return array(GalleryStatus::success(), REWRITE_STATUS_OK);
        }
        /*
         * More added code to debug the system
         */
        else if($headers != 'HTTP/1.1 200 OK') {
                return array(GalleryStatus::success(), REWRITE_STATUS_TEST_FILE_NOT_THERE);
        }

The first part of the if statement is failing, because the responce code returned is not HTTP/1.1 200 OK, which I have proved by adding additonal code in to the system. Now all I have to do is to find a way to find firstly what the actual request it is making for Rewrite.txt, and what responce is being returned.

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Thu, 2005-05-26 10:47

I have tracked the problem down even further. I belive that the problem relates to the GalleryCoreAPI::fetchWebPage($fetch); function. It would appear this function does not look up the host file first.

So what is happening to me is that my server is behind a NAT firewall, on an interal addresses in a 192.168.0.0/24 range, I use port forwarding to get the traffic to the web server, there for my domain name points to the external address of the firewall.

I have found that $fetch is equal to http://<MYDOMAIN>/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt

if I wget on the localy on the server for http://<MYDOMAIN>/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt

I get the correct responce PASS_REWRITE, as I have entery in the host file for my domain to point to the local interface address

However, the when the GalleryCoreAPI::fetchWebPage($fetch); function is called, it does not read the host file, and get a DNS lookup for the external addresses, which the firewall will answer, thus the request for http://<MYDOMAIN>/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt is serviced by the web mangement port on my firewall!!!! Which returns a 404!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 11:00

sittingduck, nice debugging!

the questions are now:
- can anyone reproduce this? (hosts file etc)
- if so, should fsockopen check the hosts file, is it a php bug?
- what do we do about it?

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Thu, 2005-05-26 15:30

Ok real strange, I use the gethostbyname() function, to see exactly what address it is resoliving my domain to, and that reads from the host file and returns the correct IP address! :(

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Thu, 2005-05-26 15:41

I think I have found a solution :D:D:D:D:D

in /gallery2/modules/core/classes/helpers/WebHelper_simple.class

I have changed the code from $fd = @$platform->fsockopen($components['host'], $port, $errno, $errstr, 1);

to

$fd = @$platform->fsockopen(gethostbyname($components['host']), $port, $errno, $errstr, 1);

In both functions within WebHelper_simple.class and it now works!!!

Does this fix the problems everyone has been having?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 15:54

yes, should work.
i just tested gethostbyname with various test hosts, numeric (IP) and domain name based host strings.
for domain name based strings, it returned the ip, for numeric (IP) strings, it just returned the same string again.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 16:23

sittingduck, before I change something in G2, i'd like to better understand what's happening in this case.

could you list
- the url that GalleryCoreAPI::fetchWebPage is called with.
- the entry in your hosts file that should be used
- how the final request *should* look like
- the ip/dname of your firewall/nat box

if you know ethereal, you could check what request finally leaves your box.

i guess i'll understand the case once i have this information...

and perhaps the conclusion will be, that php fsockopen should do the hosts lookup, i.e. it's a php bug. then we'd have to fix it in g2 similarly as you suggested and file a php bug.

 
sittingduck

Joined: 2005-04-08
Posts: 19
Posted: Thu, 2005-05-26 16:33

I'll get on that and send you all that stuff in the next couple of days

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 16:58

thanks

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Thu, 2005-05-26 18:29
pelle wrote:
What this does is testing mod_rewrite in action, as long as you get FAIL_NO_REWRITE mod_rewrite doesnt work - its an apache issue.

I do apache upgrade to latest version 1.3.33 but I get same error.

sittingduck wrote:
$fd = @$platform->fsockopen(gethostbyname($components['host']), $port, $errno, $errstr, 1);
Does this fix the problems everyone has been having?

I appreciate your effort!
I changed code to mentionned above but the error is there.

I'd like to know with which version of Apache, php and MySQL (OS win2k) is mod_rewrite (in gallery2 beta3) installed succesfully.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Thu, 2005-05-26 21:19
SusiG wrote:
I'd like to know with which version of Apache, php and MySQL (OS win2k) is mod_rewrite (in gallery2 beta3) installed succesfully.

So, good news :D mod_rewrite works fine on configuration below:

Apache 2.0.52
PHP 5.0.2
mysql server 4.1.7-nt
OS: Windows XP SP2

I finaly get the "activate" link for mod_rewrite module on admin panel.
I had to create myself a blank .htaccess file in gallery2 root directory,
to solve the error related to it.

Now, when I browse my gallery, I finally get the short url :)
http://localhost/gallery2/v/test/?g2_GALLERYSID=af6af43bfe5a400a6adaf5bf91fb1f81

Thanks for your supports!

 
sremick
sremick's picture

Joined: 2005-05-06
Posts: 47
Posted: Thu, 2005-05-26 21:27

Ok so I'm a bit confused... what do I need to change? I'm not clear what the final answer is, or what SusiG did between those last two posts to make it go from not working to working.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-05-26 21:37

sremick, susig didn't solve the problem. she changed her setup (moved from apache 1.33 to apache 2.x), which "solved" it for her.
the problem in sittingduck's case is different, and he could solve it by the above fix.

but i guess sittingduck's fix doesn't apply to a lot of configurations.

 
SusiG

Joined: 2005-05-21
Posts: 16
Posted: Thu, 2005-05-26 21:44

I do not make change on gallery2 beta3 code.
I just changed my system configuration (Apache, php, MySQL and OS) to:

Apache 2.0.52
PHP 5.0.2
MySQL Server 4.1.7-nt
OS: Windows XP SP2

and it rocks.

Before, it fails on the config below:

Apache 1.3.29
PHP 5.0.4
MySQL 3.1
OS: Windows XP SP1

and

Apache 1.3.33
PHP 4.3.4
MySQL Server 4.1.7-nt
OS: Windows 2000 SP3

 
ChezDude

Joined: 2005-05-27
Posts: 2
Posted: Fri, 2005-05-27 02:11

I tried the code changes identifed above by sittingduck and they didn't make a difference in my case. I also manually verified that mod_rewrite was working by requesting the Rewrite.txt file and go the pass response. When I watch my Apache logs, I never see a request for the Rewrite.txt file when I use the configure option of the module setup.

Gallery version = 2.0-beta-3+ core 0.9.20
PHP version = 4.3.10 apache2handler
Webserver = Apache/2.0.51 (Fedora)
Database = mysql 3.23.58
Toolkits = Ffmpeg, Gd, Thumbnail, Dcraw, ArchiveUpload, Exif, ImageMagick, NetPBM
Operating system = Linux space.local 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686
Browser = Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312

And from my Apache log:

From when I click the button on the setup page:
edge.outerspaceconsultants.com - heath [26/May/2005:17:11:15 -0400] "POST /gallery2/main.php HTTP/1.1" 302 -
edge.outerspaceconsultants.com - heath [26/May/2005:17:11:15 -0400] "GET /gallery2/main.php?g2_view=core%3ASiteAdmin&g2_subView=rewrite%3ASetupRewrite&g2_navId=xe24193c1 HTTP/1.1" 200 15723

And manually requesting the file:
edge.outerspaceconsultants.com - - [26/May/2005:17:12:41 -0400] "GET /gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt HTTP/1.1" 200 13

Anything else that might help here or something I can look for?

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Fri, 2005-05-27 06:22

sremick, http://vtbsd.net/gallery/modules/rewrite/test/mod_rewrite/gallery/Rewrite.txt is fine. I hardcoded that URL in to my Gallery and it detected mod_rewrite. Please, turn on debugging in your config.php and look for the fsockopen part (should be near file_exists tests for your .htaccess file).

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Fri, 2005-05-27 06:42

ChezDude, which error message do you get when configuring URL Rewrite?

 
jmlane

Joined: 2005-05-27
Posts: 3
Posted: Fri, 2005-05-27 17:59

pelle, I've been having the same problem, where I have a working mod_rewrite enabled on my server, however G2 doesn't seem to pick it up. After installing the rewrite module in G2 and creating a writable .htaccess file, I'm still getting the famous "Apache mod_rewrite is not installed or not enabled." error.

Here is my server setup:

Gallery version = 2.0-beta-3+ core 0.9.18
PHP version = 4.3.2 apache2filter
Webserver = Apache/2.0.46 (Red Hat)
Database = mysql 3.23.58
Toolkits = ArchiveUpload, Exif, Gd, ImageMagick, Thumbnail
Operating system = Linux $myserver 2.4.21-27.0.2.ELsmp #1 SMP Wed Jan 12 23:35:44 EST 2005 i686
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 

I've ran the http://$myserver.org/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt and .../mod_rewrite/gallery2/Rewrite.txt files from my own browser (remotely) and I get the "PASS_REWRITE" message. So I decided to try browsing to it from my web and shell servers (two different machines on the same network). If I do a wget on that URL, from either shell03 or web02, I receive this message:
Connecting to $myserver.org[$myserverip]:80... failed: Connection refused.

So I turned on logging and looked up the fopensocket line, like suggested in the above posts:

2005-05-27 07:21:18 [6204071a84093303531425135d2b9641] fsockopen($myserver.org, 80, , , 1)
2005-05-27 07:21:18 [6204071a84093303531425135d2b9641] Error 111: 'Connection refused' retrieving http://$myserver.org/gallery2/modules/rewrite/test/mod_rewrite_no_options/gallery2/Rewrite.txt
2005-05-27 07:21:18 [6204071a84093303531425135d2b9641] fsockopen($myserver.org, 80, , , 1)
2005-05-27 07:21:18 [6204071a84093303531425135d2b9641] Error 111: 'Connection refused' retrieving http://$myserver.org/gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt

I think that's mainly the only things you've mentioned wanting to know. I'm a novice user, especially when it comes to Unix system administration, but I am on the learning path, so I should be able to handle any instructions that you'd recommend for fixing this problem. If you need any more information, just let me know. I didn't want to put my server's URL or IP up on these public forums, just because I share this server with many people, so it's not my risk to take.

Thanks for all your help,

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sat, 2005-05-28 12:43

jmlane, sounds like there's a firewall in action.

Overall I think it's a good idea to add a checkbox to override Gallery's autodetection, just like we do if Gallery is installed at another location than /gallery/ or /gallery2/.

 
jmlane

Joined: 2005-05-27
Posts: 3
Posted: Sat, 2005-05-28 14:33

pelle, okay, thanks. I would most likely have to speak with my server admin to see if we can sort this out then.

This so-called override button that I've heard mentioned, should I find that in G2B3 because I haven't seen one anywhere? Or was your statement just a suggestion that we should include one in a future release of G2?

Thanks,

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Sat, 2005-05-28 14:43

There's one, if you install Gallery at any other location than /gallery/ or /gallery2/. I will also create one for these two cases.

 
firepol
firepol's picture

Joined: 2004-05-19
Posts: 99
Posted: Wed, 2005-06-01 12:53

Like, sremick, i also remember mod_rewrite was working in versions prior to beta 3. then the G2 develoeprs changed something and it didn't work anymore.

I already experienced this problem, but it seems nobody corrected it and it's still a BUG now.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-06-01 13:18

pelle, are there any improvements in detecting mod_rewrite since beta 3?
maybe another test is required, maybe a fix in the webhelper stuff.

 
lupar_blackice
lupar_blackice's picture

Joined: 2005-04-21
Posts: 60
Posted: Thu, 2005-06-02 02:28

I am also having the same problem, here is my info

I go to the URL Rewrite setup page & it is giving me this MSG

Apache mod_rewrite is not installed or not enabled.

The odd thing is I have Gallery 1.5 running on the same system & it is having no problem with the mod_rewrite, witha older version of G2 this was working & am now at tonights CSV.

I have added Directory info to my Apache configuration

<Directory "C:\Apache Group\Apache2\htdocs\gallery2">
AllowOverride FileInfo Options
</Directory>

And Gallery can write to the .htaccess file

Maybe I am missing something but under Troubleshooting it say "Go to the Gallery phpinfo page and look for Loaded Modules. You should see mod_rewrite in the list if it's loaded."

mod_rewrite is a Apache thing not a php or did I miss something.

The MSG I am getting from gallery2/modules/rewrite/test/mod_rewrite/gallery2/Rewrite.txt is PASS_REWRITE

I try the change that sittingduck with in the WebHelper_simple.class, but it didn't work.

And this was working in G2 Beta 2.

----

Gallery version = 2.0-beta-3+ core 0.9.18
PHP version = 4.3.11 cgi-fcgi
Webserver = Apache/2.0.53 (Win32)
Database = mysql 4.0.24-nt
Toolkits = Exif, Thumbnail, NetPBM, ImageMagick, Ffmpeg, Dcraw
Operating system = Windows NT ICEBOX 5.2 build 3790
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

 
RobFerrer

Joined: 2005-03-10
Posts: 33
Posted: Thu, 2005-06-02 08:26
lupar_blackice wrote:
Maybe I am missing something but under Troubleshooting it say "Go to the Gallery phpinfo page and look for Loaded Modules. You should see mod_rewrite in the list if it's loaded."

mod_rewrite is a Apache thing not a php or did I miss something.

mod_rewrite is an Apache module, but should be listed on a phpinfo page under Apache -> Loaded Modules.