BPS Stack Install Notes

The present document is relative to the installation carried out on a Mac OS X 10.6.8 system, running MAMP (Apache 2.0.63, MySQL 5.1.44, PHP 5.2.17 & 5.3.6).

For clarity, the process is decomposed in conceptually independent parts, although the actual process required a number of iterations. These notes are additional to those written by Patrick for the installation on Linode.

● MAMP Installation ○ Assuming installation folder is /Applications/MAMP ○ Set Apache port to 80, leave MySql to 3306 ○ Set PHP version to 5.2.17 ○ Do NOT, for any reason, set the root password in MySql to an empty string. ○ Make sure DocumentRoot is set to "/Applications/MAMP/htdocs" in httpd.conf ○ Add the mod_rewrite directives either in the entry in httpd.conf, or in a .htdocs file. ● Tomcat Installation ○ Extract tomcat binaries in /Applications/MAMP/tomcat ○ In the latest versions of Tomcat, permissions per user have changed in order to allow for a more fine- grained control. Modify tomcat-users.xml as follows: ○ In order to have tomcat to start with apache, add the following lines: ■ /Applications/MAMP/tomcat/bin/startup.sh to bin/startApache.sh ■ /Applications/MAMP/tomcat/bin/shutdown.sh to bin/stopApache.sh before the Apache shutdown command. Then, since Tomcat sometimes doesn’t quite quit, add these at the end: sleep 2 kill -TERM ps aux | grep [t]omcat | awk '{ print $2}' sleep 1 kill -9 ps aux | grep [t]omcat | awk '{ print $2}' ● Additional libraries ○ PEAR ■ From console, install PEAR in bin//php5.2.17/lib/php/PEAR ■ In bin/php/php5.2.17/conf, set the following ● include_path = ".:/Applications/MAMP/bin/php/php5.2.17/lib/php:/ Applications/MAMP/bin/php/php5.2.17/lib/php/PEAR" ■ The following modules are required: MDB2, its MySql_connector and RESTClient. Refer to Patrick’s install notes; all commands are to be executed locally (typically mac os x has a bundled version of PHP installed. Executing which php and which ./php in Applications/MAMP/ bin/php/php5.2.17/ will show the difference). ■ Install by either downloading and moving the libraries manually from the PEAR webiste/checkout version of BPS to bin/php/php5.2.17/lib/php/ as follows: /php |-PEAR.php |-MDB2.php |-/MDB2 |/Driver |-.php |-mysqli.php ■ or use ./pear install in bin/php/php5.2.17/bin ■ Add LoadModule php5_module /Applications/MAMP/bin/php/php5.2.17/modules/

libphp5.so to conf/apache/httpd.conf

○ mod_jk ■ Compile (could be a hassle on MacOs X if XCode is not installed; a good option is https:// github.com/kennethreitz/osx-gcc-installer ■ Move to Library/modules/mod_jk.so ● Configuration of mod_jk ○ Apache side ■ httpd.conf ● LoadModule jk_module modules/mod_jk.so ● Include /Applications/MAMP/conf/apache/extra/mod_jk.conf ■ mod_jk.conf ● JkWorkersFile /Applications/MAMP/tomcat/conf/workers.properties ● JkMount /bps.services.webapp/* ajp13_worker ○ Tomcat side ■ workers.properties workers.tomcat_home=/Applications/MAMP/tomcat workers.java_home= local JVM installation (typically in something like /System/ Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home) ps=/ worker.list=ajp13_worker worker.ajp13_worker.port=8009 worker.ajp13_worker.host=localhost worker.ajp13_worker.type=ajp13 ■ server.xml ● Server SHUTDOWN port: 8010 ● Catalina HTTP 1.1 connector: Tomcat port, typically 8080 ● AJP/1.3 Connector por: 8009 ● Engine: defaultHost=’localhost’ ● BPS environment variables ○ In Finder, select “Go->Go To Folder”, type /etc and open launchd.conf with an editor (not TextEdit - doesn’t allow to edit as root). Alternatively, do this from command line. ○ Add and edit as necessary: #BPS Environment Settings setenv APACHE_CONF /Applications/MAMP/conf/apache setenv DB_USER root setenv DB_PASSWORD root setenv DB_PASSWORD_BPS G0Names! setenv BPS_CORPORA /Users//Documents/workspace/data setenv BPS_JEESERVER_HOME /Applications/MAMP/tomcat setenv BPS_WEBROOT /Applications/MAMP/htdocs ○ Reboot

● Notable issues ● Workers port issues: configuring the apache-side and the tomcat-side of mod_jk led to erratic behaviours that initially seemed to be related to a malfunction in the URL rewriting. Having verified the issue wasn't there, I was finally able to diagnose it as a port issue in the connection between Tomcat and Apache. ● Tomcat connection: Tomcat seemed not to be able to authenticate to the local MySql database. The issue was originated by a mismatch in the classpath (Tomcat was indicating a general database connection error, but it was in fact not accessing the lib directory where mysql-connector lived). ● PHP Libraries: After getting the stack to work, issues arose in the authentication process: after a gruesome research where a number of other minor issues were highlighted and corrected (including legacy code and version mismatches), I uncovered the issue to be an obscurely documented error of libraries duplication. Cleared up the classpath and straightened up the dependencies.

● Troubleshooting ○ 502 Error when Apache tries to access Tomcat resources: most likely a port issue. Check the port settings in tomcat’s server.xml and workers.properties. ○