Floris Bos
2005-Aug-14 13:21 UTC
[Xapian-discuss] Getting Omega to execute and generate XML
Hello, I've been posting recently and James helped me quite a bit but I'm afraid I need a little bit more help. I can't get Omega to execute any scripts. I've been reading the documentation and relevant mail list postings over and over but I can't seem to figure it out on my own. I think I'm missing out on something that I'm not aware of at all. Can someone help me out here? Here's my situation: I've builded Xapian and Omega using Cygwin on my Windows XP configuration. I've build my dynamic website using PHP and Mysql and now I'm trying to add search functionality with Omega/Xapian as backend. I've been able to implement php code that generates a text file (scriptindex input file) and run omegascript to put the new document in the Xapian database. This works fine. Now I want to request XML from PHP using a predefined omega template but I can't get this to work. Can someone be more specific about how to do this because I really don't get it. I thought it would be a nice start to try and open a template page (the shipped xml template) just to test if everything works ok. After that I would change the php script so that it would request the output of this page. I've tried the following: I've put the xml template in my websites cgi-bin directory. I thought I would be able to generate xml by directing my browser to the following url: http://localhost/test/cgi-bin/xml?DB=default&P=searchterm1+searchterm2 (in this 'test' is the name of my website) When I do this I just get the script from the xml template viewed in my browser. The script isn't carried out but being displayed in my browser?! Is this because I didn't configure Omega the right way or do I need to call Omega in a different way than the way I do currently? What files do I need to copy to my cgi-bin directory? I tested with copying omega.exe to my cgi-bin dir but I also tried copying the whole Omega installation to my cgi-bin dir. It just doesn't work. As I said I'm pretty sure I'm missing out on something very essential here (or maybe even more than one thing) but I can't figure it out. I've been trying a lot of different things and did hours of reading and websearching but I'm running out of options. Is there someone that can point me in the right direction? Any help would be very much appreciated, thanks in advance!!
R. Mattes
2005-Aug-14 14:25 UTC
[Xapian-discuss] Re: Getting Omega to execute and generate XML
On Sun, 14 Aug 2005 14:20:59 +0200, Floris Bos wrote: Hi Florian,> Here's my situation: > > I've builded Xapian and Omega using Cygwin on my Windows XP configuration. > I've build my dynamic website using PHP and Mysql and now I'm trying to add > search functionality with Omega/Xapian as backend. I've been able to > implement php code that generates a text file (scriptindex input file) and > run omegascript to put the new document in the Xapian database. This works > fine.So far, so good.> Now I want to request XML from PHP using a predefined omega template but I > can't get this to work. Can someone be more specific about how to do this > because I really don't get it. I thought it would be a nice start to try and > open a template page (the shipped xml template) just to test if everything > works ok. After that I would change the php script so that it would request > the output of this page. > > I've tried the following: > > I've put the xml template in my websites cgi-bin directory. I thought I > would be able to generate xml by directing my browser to the following url: > http://localhost/test/cgi-bin/xml?DB=default&P=searchterm1+searchterm2 > (in this 'test' is the name of my website)There seems to be a missunderstading here. You don't put your templates into the CGI directory, you put then where ever you configured omega to look for them -- this is done in the omega.conf file (which a default omega expects to be in $PREFIX/ect/omega.conf. I have no idea how cygwin treats/honors $PREFIX). Anyway, there should be a configuration option 'template_dir'. My configuration file looks like this: database_dir /var/lib/omega/data template_dir /var/lib/omega/templates log_dir /var/log/omega Once this is set up, put your template into the template directory. Now, put the omega binary int oyour CGI directory and make it executable by the webserver. To select a specific template just pass the template name (sans path!) as the FMT parameter to the CGI script.> When I do this I just get the script from the xml template viewed in my > browser.<rant> Horrors! Your webserver should _never_ send any file as is from the CGI directory! This is a major security flaw. It should try to execute the xml and if that fails (and it should :) the server should just send a 500 response. </rant>> The script isn't carried out but being displayed in my browser?! Is this > because I didn't configure Omega the right way or do I need to call > Omega in a different way than the way I do currently?See above.> What files do I need to copy to my cgi-bin directory? I tested with > copying omega.exe to my cgi-bin dir but I also tried copying the whole > Omega installation to my cgi-bin dir. It just doesn't work.Only omega.exe. That's enough. But configure it with 'omega.conf'.> As I said I'm pretty sure I'm missing out on something very essential > here (or maybe even more than one thing) but I can't figure it out. I've > been trying a lot of different things and did hours of reading and > websearching but I'm running out of options. Is there someone that can > point me in the right direction? > > Any help would be very much appreciated, thanks in advance!!HTH Ralf Mattes
Floris Bos
2005-Aug-14 18:38 UTC
[Xapian-discuss] Getting Omega to execute and generate XML
Hi Ralf, Thanks for your quick reply, I'm starting to get close now but I think I need your help one more time. There is one thing I still don't understand. You said: "Now, put the omega binary int oyour CGI directory and make it executable by the webserver" I don't really see how to do this. Is this about enabling my webserver to permit cgi execution? I've done this by following the steps in this manual: http://httpd.apache.org/docs/1.3/howto/cgi.html#configuringapachetopermitcgi but this manual describes something different I believe. It's about permitting to execute scripts from a certain directory but the omega executable is not a script but the program that runs the scripts so I'm getting awfully confused now. I did configure Omega the right way using the omega.conf file so it should be able to find my templates. I copied Omega to the directory cgi-bin\search so it's full path is: C:\Apache\htdocs\test\cgi-bin\search\omega.exe Maybe I can understand this better by asking exactly how to call Omega.exe to run the script template. I thought I would do this like: http://localhost/test/cgi-bin/search?DB=default&P=test&FMT=xml When I do this I get the error I usually get when I mistype an ul: can't find the server (translated from dutch so english message might differ) Is the way I call Omega in the above example the right way to do it or am I going wrong at this point. I'm trying to find out if I'm still calling Omega the wrong way or if it is my webserver configuration that needs to be changed (and if the latter is the case, what do I exactly need to tell my webserver to permit). Thanks in advance! - Floris
Floris Bos
2005-Aug-15 18:23 UTC
[Xapian-discuss] Re: Getting Omega to execute and generate XML
Hi Ralf, Thanks again for the info. I indeed mixed up a few things (putting the templates in the cgi dir wasn't very smart). I've used your comments and have been able to call omega the right way. However now I get the following error in my browser window when calling Omega: this program cannot run in DOS mode (and after that a whole lot of strange signs - the source code of the omega executable I guess). I'm running on a Windows XP pc with Cygwin installed on it. However I have my webserver (Apache) and PHP installed on Windows (not build under Cygwin). I thought I would be able to build Omega under Cygwin and than use it in combination with my Apache webserver that runs in my Windows XP environment. Now I'm starting to get the feeling that in order to work with Omega I need to build Apache under Cygwin and serve my webpage from there (this would mean I also have to build PHP and Mysql within Cygwin). Is this the case? I thougt that I would be able to call Omega straight from Apache running in Windows XP environment because I can also use scriptindex.exe like this. By the way, my omega config file is in this dir: C:\cygwin\home\Omega\etc It looks like this: database_dir /home/omega/data template_dir /home/omega/templates log_dir /var/log/omega I hope you can help me understand this better because I'm getting confused by building under Cygwin wether programs build under Cygwin can only be used from within the Cygwin environment or not. Thanks, Floris