Building Components for the Open GlassFish Web Stack
Description
This guide shows how to build and add a new component to the Web Stack on Red Hat Enterprise Linux 5.2 for use by Laconica. In this case, we will be adding the PHP mailparse PECL extension directly into the Web Stack source tree instead of using the pecl command line program. Note that the pre-compiled bits of the Web Stack already work great to run Laconica.
This is meant to serve as an introduction to adding a new component to the Sun GlassFish Web Stack. Please join the mailing list and tell us what you are up to.
Steps
Download Web Stack Source
hg clone ssh://anon@hg.opensolaris.org/hg/webstack/wsbuild hg clone ssh://anon@hg.opensolaris.org/hg/webstack/wstools hg clone ssh://anon@hg.opensolaris.org/hg/webstack/wslibs hg clone ssh://anon@hg.opensolaris.org/hg/webstack/php5 hg clone ssh://anon@hg.opensolaris.org/hg/webstack/php-extensions hg clone ssh://anon@hg.opensolaris.org/hg/webstack/apache2 hg clone ssh://anon@hg.opensolaris.org/hg/webstack/mysql51
Configure wstools
mkdir -p /export/wstools cd wstools; make; cd - rm /export/wstools/hg # use system hg instead
Build wslibs
cd wslibs; make publish; cd -
Build mysql51
cd mysql51; make publish; cd -
Build apache2
cd apache2; make publish; cd -
Build php5
cd php5; make publish; cd -
Adding the PHP MailParse Extension
cd php-extensions
Add the mailparse subdir to the Makefile so it looks similar to
ifeq ($(BUILD_OS),Linux) SUBDIRS=APC idn memcache suhosin tcpwrap xdebug mailparse endif
Let's use the idn package as a starting point.
cp -r idn mailparse; cd mailparse rm -rf patches idn* package.xml wget http://pecl.php.net/get/mailparse-2.1.5.tgz
The build system assumes a tar extension so let's change it
mv mailparse-2.1.5.tgz mailparse-2.1.5.tar.gz
Edit mailparse/Makefile.generic for the correct version and ext name
COMPONENT_NAME=mailparse COMPONENT_DIRNAME=php COMPONENT_VERSION=2.1.5 COMPONENT_SUMMARY=PHP mailparse module COMPONENT_DESCRIPTION=PHP mailparse module SRC_DIR=$(COMPONENT_NAME)-$(COMPONENT_VERSION) COMPONENT_PKGNAME=sun-php52-mailparse COMPONENT_LICENSE=PHP COMPONENT_COPYRIGHT=$(SRC_ROOT)/$(COMPONENT_NAME)/etc/Solaris10/pkgdef/$(COMPONENT_DIRNAME)-$(COMPONENT_NAME)/copyright
Edit mailparse/etc/Linux.mk so CONFIG_OPTIONS looks like
CONFIG_OPTIONS=\
--with-php-config=./php-config-proto
Now let's update the spec file
cd etc/RedHat/rpm mv idn mailparse cd mailparse/SPECS mv idn.spec mailparse.spec
Now let's update the spec file
perl -pi -e "s@idn@mailparse@g" mailparse.spec cd ../../../../../..; make publish
Install the packages
cd ../RedHat.i386 sudo rpm -ivh sun-wsbase-1.5-0001.i386.rpm sun-apache22-2.2.11-0001.i386.rpm sun-mysql51-5.1.30-0001.i386.rpm sun-mysql51lib-5.1.30-0001.i386.rpm sun-php*
Edit php.ini
Set the short_open_tag to On in /etc/opt/sun/webstack/php/5.2/php.ini
short_open_tag = On
Start Apache and MySQL
sudo /sbin/service sun-mysql51 start sudo /sbin/service sun-apache22 start
Install Laconica
cd /var/opt/sun/webstack/apache2/2.2/htdocs wget http://laconi.ca/laconica-0.8.0.tar.gz tar xvfz ln -s laconica-0.8.0 laconica
Create Database
Secure root mysql account
/opt/sun/webstack/mysql/5.1/bin/mysqladmin -u root password "secure" /opt/sun/webstack/mysql/5.1/bin/mysql -uroot -p mysql> create database laconica; mysql> grant all on laconica.* to 'laconica'@'localhost' identified by 'laconica'; mysql> exit
Now go to http://localhost/laconica/install.php and enter the database settings.
Links
Main Project Page --
http://www.opensolaris.org/os/project/webstack/sunwebstack/
Mailing Lists --
http://opensolaris.org/os/project/webstack/Mailing_LIsts/
Forum --
http://forums.sun.com/forum.jspa?forumID=980
Adding Web Stack Components --
http://opensolaris.org/os/project/webstack/addcomponent/