plainblack.com
Username Password
search
Bookmark and Share
Subscribe

Compile mod_php into WRE

Introduction

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:

  1. Install a separate Apache with mod_php running on an alternate port. Rewrite requests for the PHP url to this server
  2. Install mod_php into modproxy.

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.

Ubuntu

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]

Trouble-shooting

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

0jigou: "I had a similar need, and happen to be running the VMWare appliance that uses CentOS.

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.

"
0knowmad: "10/25/2010 - While compiling v5.3 for Ubuntu 10.04.1, I found that I should have been using the WRE versions of libxml and libcurl. I've revised this entry with the updated configure statement which uses these libs."
4vanjwilson: "These instructions still work, although like @jigou I had to download the source from a PHP mirror, because the source in repository for the Ubuntu I was using (12.04 LTS) wouldn't compile.

One additional note:
I had to add the following to /data/wre/etc/modproxy.conf,

   Alias /php /data/WebGUI/www/php
"
Search | Most Popular | Recent Changes | Wiki Home
© 2018 Plain Black Corporation | All Rights Reserved