![]() |
|||
SRM - Article |
||||||||||||||||||
An Idiots Guide to Insalling SRMJonathan Arkell
IntroductionAs 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
Where to go for more helpif 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
Starting OutSRM 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:
Compiling and installing SRMThis 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:
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.
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
The next thing to do is to make the thing. This is pretty easy. Just type:
This compiles everything. After that, all you have to do is Install it. That's as easy as typing in:
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:
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.
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 PHPSRM 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
(this copies the SRM extension into PHP's extension directory) next, you need to copy the SAPI... and you guessed it..
Remove the configure file that is in your /usr/local/src/php4 directory:
than you want to do a
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:
and you should see (something like ) this:
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.
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:
This is WRONG! (and will break your sapiConfigure script):
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!
Problems with compiling?
Testing everything so farIf 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:
Otherwise, do this:
You should see something like this:
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 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!
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
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 InstallNow 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? 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 |
||||||||||||||||||