Although we all love WebGUI, there are times when PHP is needed for custom apps or tools. We've implemented this solution in two ways:
It turns out #2 wasn't that hard and didn't even require the WRE source files to build. Here's how I did it in Ubuntu 8.04 with the wre-0.8.3-ubuntu-7.04-feisty-ia32.tar.gz version of WRE.
1. Libraries needed to install for Ubuntu:
apt-get install libgd-noxpm-dev (or libgd2-noxpm-dev)
apt-get install libxpm-dev
2. Extract PHP source
apt-get source libapache2-mod-php5
3. Compile - this disables the CLI
cd php5-5.3.x
make distclean
'./configure' '--with-mysql=/data/wre/prereqs/' \
'--with-apxs2=/data/wre/prereqs/bin/apxs' \
'--prefix=/data/wre/prereqs/' \
'--bindir=/data/wre/prereqs/bin' '--disable-cgi' \
'--with-gettext' '--enable-mbstring' '--with-gd=/usr/lib/' \
'--disable-cli' '--program-suffix=53' \
'--with-curl=/data/wre/prereqs/' --enable-pdo=shared --with-pdo-sqlite=shared \
--with-sqlite=shared \
--with-gd --with-freetype-dir=/usr/lib --with-png-dir=/usr/lib \
--with-jpeg-dir=/usr/lib \
--with-libxml-dir=/data/wre/prereqs \
--with-zlib --with-zlib-dir=/data/wre/prereqs/lib \
--with-config-file-path=/data/wre/etc --with-config-file-scan-dir=/data/wre/etc
make
4. cp libs/libphp5.so /data/wre/prereqs/modules
5. cp php.ini-production /data/wre/etc/php.ini
6. Edit wre/etc/modproxy.conf with following:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
7. Modify DirectoryIndex to include 'index.php' in either the primary conf (wre/etc/modproxy.conf) or in the virtualhost conf file
8. Edit virtual host file to add a RewriteRule or Directory or Location to prevent passthru to modperl server
RewriteRule ^/php/ - [L]
Problem: /usr/lib/libxml2.so: undefined reference to `gzopen64'
Solution: The likely problem is that the libz is being loaded from WRE rather than the system path. Do not source the setenvironment.sh file when compiling.
Problem: Cannot load libphp5.so into server: undefined symbol: __dn_expand
Solution: TBD
Problem: The php.ini is not being loaded. Look at output of phpinfo to see if this is happening.
Solution: I added the --with-config-file-scan-dir to the configure options to get it to pickup the path to the php.ini file. I do not know why the --with-config-file-path is not working on my system.
Problem: PHP sessions cannot be created.
Solution: You must manually create and specify a sessions directory in php.ini. I created mine in
/data/wre/var/php/session
Change the ownership of php/sessions to the user webgui runs as. Now, add the following directive to your php.ini:
session.save_path = "/data/wre/var/php/session"
Restart the web server and sessions should work.
Keywords: WRE
To get PHP running on my box, I had to install a few more prerequisites (likely because they were stripped out to make the system more efficient as an appliance):
1. Install additional libraries to enable PHP compilation:
a. yum -y install gcc
b. yum -y install curl-devel
c. yum -y install libjpeg-devel
d. yum -y install libpng-devel
d. yum -y install freetype-devel
e. yum -y install libxml2-devel
2. Download the PHP Source from a PHP mirror and extract it:
cd /
wget http://us.php.net/get/php-5.2.10.tar.gz/from/this/mirror
tar zxvf php-5.2.10.tar.gz
cd php-5.2.10
From there I picked up step 3 above at the "Configure" step and followed through the remainder of the instructions posted.
"
One additional note:
I had to add the following to /data/wre/etc/modproxy.conf,
Alias /php /data/WebGUI/www/php
"