Vulcan Logic SRM  

SRM - Article

An Idiots Guide to Insalling SRM

Jonathan Arkell

Revision History
Revision 1.018 May 2002First version
Revision 1.0.120 June 2002Updated docbook tags, small adjustsments to changes in version requirements

Introduction

As a programmer, and primarily a Web programmer, I had a difficult time compiling SRM, and making it go, The purpose of this document is to give a hand to all the PHP programmers out there who have wanted exactly that which SRM provides, but who perhaps lack experience in being able to compile and install PHP. If you are comfortable with installing and compiling PHP, than chances are this document is not for you (you might however, find the pitfalls and tips section edifying)

What you will need

  • Patience

  • The CVS version of SRM, as well as PHP v 4.2 or greater. (the sources) On my Debian Woody box, I needed to use the 4.2 Source Tarball, as well as the 4.3 CVS version.

  • autoconf 2.52, automake 1.4 or automake 1.5, libtool 1.4. (you need these to build the php cvs version)

  • The will to install and test this thing. This is beta software, and it does take some tweaking. If you are Joe Server Admin, chances are you already know what you are doing, and know exactly how to do this. If you are Fred Webguy on the other hand... there might be pain involved.

  • The ability to read docs! All kinds of docs! If you try these instructions, and it breaks, than read the instillation docs, from the web, in the source directory...everywhere.

Where to go for more help

if you have an IRC client, you can always hop onto EFNet and ask around in channel #vl-srm

You can also join the mailing list

Thanks you's

  • Everyone in #vl-srm who helped me out.

  • Zak Greant and Trevor "Skinneet" For helping make this document better.

Starting Out

SRM has 3 components to it. The first being the SRM daemon itself, the second being the Zend Engine for the SRM daemon, and the third being the extension for the version of PHP that runs on your web server.

So that means compiling 3 times. You will end up compiling the SRM source once, and the PHP source Twice.

First, you need to get the SRM Sources .. They are available via CVS, and all the pertinent details are right here at http://www.vl-srm.net/download.php

I checked everything out into /usr/local/src/srm-CVS .. assuming you did the same thing, you should have a directory structure like this:


  /usr/local/src/srm-CVS
      |
      +-- php_srm
      |
      +-- sapi_srm
      |
      +-- srm
  

Compiling and installing SRM

This is actually rather easy, and I was able to compile the SRMD server, as well as the libraries with the least amount of pain.

Its as easy as going to /usr/local/src/srm-CVS/srm and typing in the following things:


./buildconf
   

Than let it do its thing. with any luck it will not spit out any errors at you.

After that, you have to tell the compiler what kind of options you want with your copy of SRM. I started with just a basic debug config, and figured I would add to it once I got more comfortable with SRM.

I found it extremely handy to write up a little script that handles my configure options. Mine is named srmdConfigure, and this is what it looks like.


./configure --enable-debug
   

Pretty tiny huh? The reason why I did it this way tho, is so I know exactly what kind of configure options I built with srm. A full list of compile options is available here: http://www.vl-srm.net/doc/admin.compile.php

now, run that little script


./srmdConfigure
   

The next thing to do is to make the thing. This is pretty easy. Just type:


make
   

This compiles everything.

After that, all you have to do is Install it. That's as easy as typing in:


make install
   

The final thing that you need to do is deal with the srm.ini. First put it in /etc. If you can't find it.. it is probably located in /usr/local/srm/sbin. If you still can't find it, try:


find / -name 'srm.ini'
   

Finally, you should edit the srm.ini file, and set up all the options. If you ended up using the srmdConfigure script, you will need to turn off the 'load "auth";' and 'load "http";' lines, by putting a # in front of it. (I've included my own srm.ini so you can have a look). You can also change the banana classpath (which is where all your banana's will live, as you can see, i put mine in /var/srm/ ) and the function_library.

One quick note. You will have to make sure that the PHP file that is your function library exists. (that's OK, it can be a PHP file that looks like <?php ?>). You might want to use the one I have provided called "library.php", this will help in testing your SRM installation.

Warning

If you ever need to compile SRM again... which, hopefully you wont, be sure to run make clean and make distclean BEFORE you do anything else.

You will not have to do the buildconf step again.

(is another ./configure necessary? I am not sure to be honest. I always did it though. Better safe than sorry.)

What did you just do? You just compiled the SRM Daemon (programmed in C) that will handle the raw requests from your PHP scripts on the web server. the SRM Daemon can't run PHP scripts yet.

Making SRM Speak PHP

SRM will only work with PHP 4.3.0 and higher, you need to get the source for this version from CVS.

Anonymous CVS access to PHP is available here: http://www.php.net/anoncvs.php

First you need to copy the SAPI (sapi_srm), and the extension (php_srm) sources of SRM into your PHP source directory.

Assuming your PHP source lives in /usr/local/src/php4 it is as simple as


cp -R /usr/local/src/srm/php_srm /usr/local/src/php4/ext/
mv /usr/local/src/php4/ext/php_srm /usr/local/src/php4/ext/srm
   

(this copies the SRM extension into PHP's extension directory) next, you need to copy the SAPI... and you guessed it..


cp -R /usr/local/src/srm/sapi_srm /usr/local/src/php4/sapi/
mv /usr/local/src/php4/sapi/sapi_srm /usr/local/src/php4/sapi/srm
   

DO NOT SYMLINK!

I know it seems like a good idea to just make a symlink in the php4 directory to the srm_sapi and php_srm directory, but its not! Apparently "make clean" does not clean out symlinked directories.

Remove the configure file that is in your /usr/local/src/php4 directory:


rm configure
   

than you want to do a


./buildconf
   

in the php4 directory. This builds the php4 configure.

If you want to test and make sure you can build PHP with the SRM modules, by doing this:


./configure --help | grep srm
   

and you should see (something like ) this:


--with-srm-sapi[=DIR]   Include SRM-SAPI support                              
--with-srm[=DIR]        Include SRM: Script Running Magic (http://www.vl-srm.net/) support
--with-tsrm-pth[=pth-config]    Use GNU Pth.
--with-tsrm-st
--with-tsrm-pthreads    Use POSIX threads (default)
   

If not, you haven't got the srm SAPI and/or the SRM extension in the php4/sapi and php4/ext sections of your source.

After it is done, we need to configure PHP 4. This is where I found the use of a script extremely beneficial. Because if this step breaks, and you have to do this all over again, its just right here for you.

It also makes adding new modules very easy. So which much further ado, here is my configure script, I called it sapiConfigure.

An important thing to realize is that SRM doesn't officially support shared modules.. and it is "not a good idea to use shared modules with SRM". I would just follow that advice.


./configure \
--with-srm-sapi=/usr/local/srm \
--with-srm=/usr/local/srm \
--with-layout=GNU \
--disable-static \
\
--enable-memory-limit \
--enable-track-vars \
--enable-debug \
--with-config-file-path=/etc/php4/srm \
\
--with-mysql=/usr \
#--with-exif \
#--enable-bcmath \
   

I am not going to go into every line by line detail, you can find out what is going on by checking out http://www.php.net/manual/en/install.configure.php .

In case you don't know, the \ 's in the script, tell your shell (hopefully) that even tho there is a CR at the end of this line, don't interpret the code right away.

At the end of the file, there is a bunch of options commented out ( i.e. #--with-exif) These are options that I may or may not want to add in the future. If you want to add modules to the SRM PHP engine, go ahead, But don't just un-comment them out! make sure that all the commented out config options stay together... i.e.

This is correct:


./configure \
--with-srm-sapi=/usr/local/srm \
(...)
--with-config-file-path=/etc/php4/srm \
\
--with-mysql=shared,/usr \
--enable-bcmath \
#--with-exif \
   

This is WRONG! (and will break your sapiConfigure script):


./configure \
--with-srm-sapi=/usr/local/srm \
(...)
--with-config-file-path=/etc/php4/srm \
\
--with-mysql=shared,/usr \
#--with-exif \
--enable-bcmath \
   

Why does this break things? Because when your shell interpreter runs into the first comment .. it assumes that your multi-line command is finished... when really its not.

Also, make sure that the --with-srm and --with-srm-sapi options have =/usr/local/srm after them (like I do), Your milage might very if you used the --prefix option, in compiling SRM.

You are compiling the SRM-SAPI (basically the thing that makes SRM speak in PHP) library. You are also compiling in the SRM extension because the server needs some functions it provides to run. So just to re-iterate, you are compiling both the SRM extension and the SRM-SAPI extension for the SRM-SAPI library. (phew)

Now, weather you think you need it or not, do this! make clean and make distclean because we are going to have to rebuild PHP for your web server (later).

Problems with compiling?

  • Try removing some of your ./configure options, and do a basic, what-you-need compile.

  • Make sure you have the proper versions of autoconf, automake and libtool! If you have Debian Woody in fact, the stock libtool WILL shaft you. (recompiling and installing the proper version isn't hard at all) You can find out what you need from here: http://www.php.net/anoncvs.php

Testing everything so far

If you are semi-paranoid like me, you like to test stuff. So here is how to test SRM and make sure it worked.

If you compiled srmd with --enable-debug than do this:


/usr/local/srm/sbin/srmd
    

Otherwise, do this:


/usr/local/srm/sbin/srmd -L
    

You should see something like this:

2002-05-08 13:34:27 [Log]      Logfile opened (level 100)
2002-05-08 13:34:27 [--------] ------------------------------------------------
2002-05-08 13:34:27 [Module]   Standard function module
2002-05-08 13:34:27 [Module]   Version:              0.6.1
2002-05-08 13:34:27 [Module]   Vendor:               Vulcan Logic Group
2002-05-08 13:34:27 [Module]   Description:         
2002-05-08 13:34:27 [Module]   SRM API version:      6010
2002-05-08 13:34:27 [Module]   Loading functions...
2002-05-08 13:34:27 [Module]   Addr: 080530A0
2002-05-08 13:34:27 [Func]     - Loaded srm_version
2002-05-08 13:34:27 [Func]     - Loaded srm_function_list
2002-05-08 13:34:27 [Func]     - Loaded srm_function_exists
2002-05-08 13:34:27 [Func]     - Loaded srm_module_list
2002-05-08 13:34:27 [Func]     - Loaded srm_module_exists
2002-05-08 13:34:27 [Func]     - Loaded srm_module_info
2002-05-08 13:34:27 [Func]     - Loaded srm_application_keys
2002-05-08 13:34:27 [Func]     - Loaded srm_session_keys
2002-05-08 13:34:27 [Func]     - Loaded lock
2002-05-08 13:34:27 [Func]     - Loaded unlock
2002-05-08 13:34:27 [--------] ------------------------------------------------
2002-05-08 13:34:27 [Module]   Initializing module...
2002-05-08 13:34:27 [SRM-SAPI]
2002-05-08 13:34:27 [Module]   - Module intialization OK.
2002-05-08 13:34:27 [Module]   PHP 4 / Zend
2002-05-08 13:34:27 [Module]   Version:              0.6.1
2002-05-08 13:34:27 [Module]   Vendor:               PHP Group
2002-05-08 13:34:27 [Module]   Description:          Scripting Language
2002-05-08 13:34:27 [Module]   SRM API version:      6010
2002-05-08 13:34:27 [Module]   Loading functions...
2002-05-08 13:34:27 [Module]   Addr: 402CE538
2002-05-08 13:34:27 [Func]     - Loaded start_banana
2002-05-08 13:34:27 [Func]     - Loaded banana_function_call
2002-05-08 13:34:27 [Func]     - Loaded get_loaded_bananas
     

If you see this, (or something reasonably like it) it means that you have SRM working properly, and it will be able to speak PHP!

Serve Me up, Compiling PHP

Did you make clean and make distclean in your php4 source directory yet? no? Bad admin! No Cookie!

Now we have to build the srm client with the server module of choice. (probably Apache) this means leaving out the --with-srm-sapi option.

If you are currently using a pre-built .deb or .rpm of PHP, you will want to make a quick phpinfo() page, and get the "Configure Command" setting, its the third option down. You can't miss it. Copy this, and save it somewhere. You might want to know why (for instance) half your scripts that required gd, curl, shmop, and any number of other modules don't work ;)

Now, you probably want to write up another configure script.. I called this one srmApacheConfigure, for obvious reasons. In this compile, we do not need to worry about shared modules, so if you use them, no worries!


./configure \
--prefix=/usr \
--with-srm=/usr/local/srm \
--with-layout=GNU \
--disable-static \
\
--with-apxs=/usr/bin/apxs \
\
--with-config-file-path=/etc/php4/apache \
--enable-memory-limit \
--enable-track-vars \
\
--with-mysql=shared,/usr \
--with-curl \
--with-exif \
--enable-bcmath \
--enable-sockets \
   

OK, remember that configure line you grabbed? you want to compare that with what is here, specifically if there is a --prefix option (and what the directory is after it), as well as --with-layout, and --with-config-file-path. (if your previous version was a .deb, than you should be able to use this configure just fine.

Additionally, the --with-apxs line may not be applicable to you at all, check out Configure Server Options. Again, check your previous configure to see what it was before.

Than, all you have to do is


./srmApacheConfigure
make
make install
   

and you have PHP ready to talk to srm! If you did everything right, than all you need to do is restart your webserver!

Testing Your Install

Now you will want to test to make sure SRM is installed, and is running properly.

The first test you should run, is to make sure that Apache's PHP has the SRM module installed.. so just run a phpinfo() page, and check it out. You should see SRM showing up in the modules list, with the funky volcano image. If you don't you have done something wrong. You will need to do a ./buildconf and ./srmApacheConfigure and recompile.

The next test should be to make sure you can run Banana's and functions within SRM's copy of php. There are two files included in this package that will help you test out SRM, and make sure that it works. One is called uptime.php (which is a modification of the origignal uptime.php on the SRM website.) The other is called srm_test.php. You should make sure that Uptime.banana.php is installed on your Banana classpath, and that your function library points to library.php in this package.

The first test you should perform is to see that SRM is running, and check to make sure its options are working just fine. That's what srm_info.php is all about. Visit that page (on your server) with a browser, and you should see "SRM server is running, and receiving connections", and a link to view the PHP info. Click that link and check to see that your PHP under SRM is working properly, and has all appropriate compile options.

The second test is to make sure that banana's are working. Open up the uptime.php (in your browser), and you should see your servers uptime twice.

That's it! You now have a fully working copy of SRM!

WTF? (What the FAQ?)

1. PHP throws an error that it can't start a session, but I didn't even use SRM's session handling functions at all! Whats going on?

1. PHP throws an error that it can't start a session, but I didn't even use SRM's session handling functions at all! Whats going on?

Weather or not you use session handling, SRM itself does. What is going on is that php cannot use your session save handler, and you probably set it to something like "file" instead of "files" or "srm".

Thats All Folks!

Hopefully you have found this little tutorial helpful. if you need to contact me for comments, corrections, don't hesitate, you can reach me via email at: jonny@sanriowasteland.net

My next tutorial will be on how to effectively program bananas, and little gotchas in banana's that you should watch out for.



© 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by The Vulcan Logic Group