mySQL question + rev drivers

Björnke von Gierke bvg at mac.com
Sat Aug 30 05:56:32 EDT 2008


Hi CGI on OS X testers

To get the 2.9 cgi engine on Mac OS X you need to look in your  
Revolution installation. there's several possible engines, and some  
work for some people, and others work for other people. So it's best  
to try em all.

The engines to try are the ones Rev uses to build it's apps. They're   
found at:
Applications/Revolution Enterprise (or Studio)/2.9.0-gm-1/Runtime/Mac  
OS X

Copy the "Revolution" executable files found in the subfolders (only  
those that can run on your processor) to your cgi-executables  
directory, naming them appropriately:
Library/Webserver/CGI-Executables

If all these won't work, then another possible engine to try is the  
executable within the bundle. So right click (control click) your  
"Revoluion" IDE application, and choose "show package contents". Next  
navigate to "contents/MacOS" and copy the executable.

Now make the files executable, using the terminal, or your favourite  
tool:
chmod 755 Library/Webserver/CGI-Executables/Revolution

The actual cgi code goes into a text file (I normally just use  
TextEdit), and that too needs the same execute permissions.

There's two things to look out for:
The first line of your code needs to reference the engine, and include  
a parameter to tell it not to load any graphical user interface. A  
simple test cgi could look like this:

--- start code below this line
#Revolution -ui

on startup
   put "hello world" into buffer
   put "Content-Type: text/plain; charset=ISO-8859-1"  & cr
   put "Content-Length:" && the length of buffer & cr & cr
   put buffer
end startup
--- end code above this line

Try out the relevant engines, and make sure that you picked one that  
does indeed work. Also don't forget to start websharing in the Mac OS  
X Preferences, and that you enter "localhost/cgi-bin/ 
your_cgi_filename.cgi" in your web browser (not "localhost/cgi- 
executables/...").

To work with a database, you need to fiddle even more around, so make  
sure everything already works perfectly well, before you continue on.  
And you need even more files, namely those found in the Revolution  
folder where you got your working engine from. you need the  
"revdb.bundle" one, and the relevant contents of the "database" folder  
(not the folder itself). Copy it all into the CGI-Executables folder.  
If you want to use any database other then SQLite, then you need to  
install that one too. For MySQL, the server needs to run already, and  
several setup tasks have to be made, but it's well documented, and  
there are several helper applications to ease this, so I won't go into  
those details.

For referencing the database, you'll need to include them as externals  
in the cgi code. an example code could look like this (untested):

--- start code below this line
#Revolution -ui

on startup
   --setup mySQL
   set the externals of the templateStack to "/Library/Webserver/CGI- 
Executables/revdb.bundle"
   create stack "externals"
   start using stack "externals"
   revSetDatabaseDriverPath "/Library/Webserver/CGI-Executables/"

   --use "try" to output errors to the browser
   try
     put revOpenDatabase("mysql", "localhost", "aDB", "aUser", "aPW", 
0) into connID
     put "All is working well:" && connID into buffer
   catch buffer
     put "Error:" && connID & return & buffer into buffer
   end try

   put "Content-Type: text/plain; charset=ISO-8859-1"  & cr
   put "Content-Length:" && the length of buffer & cr & cr
   put buffer

   --extremely important:
   close stack "externals"
end startup
--- end code above this line

If you leave stacks open (even unsaved ones), then the cgi will not  
run at all (an alternative to "close stack" could be "quit", or  
"delete stack"). Note that for security purpose, you might want to not  
put the externals into the cgi folder, and although that should work,  
I never tried it myself.

If you do not want to use "try", you can also see most problems in the  
console application (found in the utility folder). Look for the apache  
error logs, they're in different locations for every Mac OS X version,  
for me it's at:
"LOG FILES" -> "var/log" -> "apache2" -> "error_log"

Of course there's even more things that can and will go wrong, and  
there's subtle differences to get things running on a virtual host,  
but for local Mac OS X installations these steps should work.

Have Fun
Björnke

On 29 Aug 2008, at 07:13, Jim Ault wrote:

> I am using Rev 2.6.1 to develop some cgi stacks.. because
> I want to test the environment of scripts, stack and libraries on  
> Mac OSX
> web server.
>
> a) my current web host does not work for Rev 2.6.1, 2.7.2, 2.9
>
> b) the lastest Eev for OSX seems to be 2.1.2
>
> c)  using 2.6.1 saves in legacy format
>
> I plan to move to DreamHost when my client is satisfied with the  
> deveilpment
> betas, so mySql will be the database available.
>
> I will be using the MAMP install of Apache, Mysql, Php on OSX for  
> testing.
>
> Checking the archives and such did not give a clear picture, nor do  
> I know
> where to download the drivers for older versions of Rev.



More information about the use-livecode mailing list