Adding PHP to the mix

Now we have a fully functioning webserver which is serving two sites from the same IP address and using Name Based Virtual Hosting, we need to add the ability for those sites to interact with the PHP engine. We have already set up the Zendcore (the engine) which starts up automatically, so all we have to do is set up our sites to pass PHP requests back to the server. This is done by using the proxy module available in Apache.

Here is the first part of the code we need to add to the configuration file, this will add the Proxy Modules to our Webserver instance. All this is done using the IBM HTTP Interface which is reached using the :2001 port against your IP address.

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/

We will also remove the directory instructions from the config files as we will put it into the PASE Apache Servers configuration. So we simply removed the following elements from the config file. You can leave them in if you wish.


      Order Allow,Deny
      Allow From all
   

      Order Allow,Deny
      Allow From all
   

This is how your config file should now look.

# Configuration originally created by Create HTTP Server wizard on Mon Nov 12 20:56:15 EST 2007
LoadModule proxy_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_http_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_connect_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_ftp_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
Listen 192.168.200.134:80
Options -ExecCGI -FollowSymLinks -SymLinksIfOwnerMatch -Includes -IncludesNoExec -Indexes -MultiViews
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
LogFormat "%{Cookie}n "%r" %t" cookie
LogFormat "%{User-agent}i" agent
LogFormat "%{Referer}i -> %U" referer
LogFormat "%h %l %u %t "%r" %>s %b" common
CustomLog logs/access_log combined
LogMaint logs/access_log 7 0
LogMaint logs/error_log 7 0
NameVirtualHost 192.168.200.134:80
DocumentRoot /www/webserver/htdocs
AccessFileName .htaccess
SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
SetEnvIf "User-Agent" "JDK/1.0" force-response-1.0
SetEnvIf "User-Agent" "Java/1.0" force-response-1.0
SetEnvIf "User-Agent" "RealPlayer 4.0" force-response-1.0
SetEnvIf "User-Agent" "MSIE 4.0b2;" nokeepalive
SetEnvIf "User-Agent" "MSIE 4.0b2;" force-response-1.0
DirectoryIndex index.html

   Order Deny,Allow
   Deny From all

# Our Tools Server

   ServerName www2.toolserver.local
   DocumentRoot /www/toolserver/htdocs
   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:8000/
   ProxyPassReverse / http://127.0.0.1:8000/

# Our Webserver

   ServerName www2.webserver.local
   DocumentRoot /www/webserver/htdocs
   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:8000/
   ProxyPassReverse / http://127.0.0.1:8000/

This is all you need in the IBM configurations to allow the php requests to be served, however we now need to configure the PASE based PHP server to respond to the requests this server will pass onto it. Remember we are using Name Based Virtual Hosting, so a really important element of the configs we have done so far is the ProxyPreserveHost On statement. This will ensure when we call the PASE server the host address this server responded to will be passed on. You can restart the server now if you want or wait until all the changes have been made.

A couple of important things to remember here are the location of the configuration files. We have a single server running multiple sites, we only need a single httpd.conf file in the webserver directory, the toolserver instance is simply being fed from the webserver configuration. So our IBM (some call it the ILE instance) server has a single httpd.conf located in ‘/www/webserver/conf’ directory. We now need to change the configuration file for the ZendCore PASE instance, this is located in the ‘/usr/local/Zend/Apache2/conf’ directory. Do not confuse this with the server configuration which is installed in ‘/www/zendcore/conf’ directory. This is the IBM level server for the Zendcore interface which we will review later.

Now we need to add a few elements to the ‘/usr/local/Zend/Apache2/conf/httpd.conf’ File. There is a configuration interface provided with the Zendcore product but we update the configuration file manually for the purposes of this exercise. To do this we will use Wordpad from a PC connected to the IFS on the i5. Open the directory structure until you find the file and open it using Wordpad.

The config file as shipped needs a few additional statements to be added.
First add the server admin email address, this allows the system to know where emails sent to the server admin should be directed to. If you dont have a specific email don’t worry its not essential to fill this in. Find the statement ServerAdmin and add in your email address if you want. Then we will set the user profile the Apache server will run as, this is required where you have directory access set to help manage security of the web pages etc. We use QTMHHTTP which ships with the IBM server. Find the User statement and add qtmhhttp to it, dont worry about the Group statement we wont be using it on the i5.

We also removed the some of the global statements for the FollowSymLinks etc but as the Virtual Host definitions override these you dont have to. Next we added a statement to show we are going to use Virtual Hosting and the IP address and port it will respond to

NameVirtualHost 127.0.0.1:8000

Now we simply add the Virtual host configurations, remember we removed the directory statements from the IBM configurations so we need to make sure we add them here.

# Web Server

   DirectoryIndex index.php index.html
   DocumentRoot /www/webserver/htdocs
   ServerName www2.webserver.local
   
      Options Indexes FollowSymLinks
      Order Deny,Allow
      Allow From All
   

# Tool Server

   DirectoryIndex index.php index.html
   DocumentRoot /www/toolserver/htdocs
   ServerName www2.toolserver.local
   
      Options Indexes FollowSymLinks
      Order Deny,Allow
      Allow From All
   

Now you can save the file and restart the server. To restart the server you need to use the ZendCore menu which is in ZENDCORE/ZCMENU. We have noticed that we have lots of problems unless this is done methodically, using the restart option seems to stop things from working. So go to the ZCMENU and take option 5, then option 5 to stop the HTTP servers. Use WRKACTJOB to ensure all the server instances related to the ZENDCORE server in QHTTPSVR subsystem plus ZENDCOREAP in the ZEND subsystem have ended before taking option 4 from the menu to start the servers again.

Now we need to test the servers, we will simply change the index.html file to be a php file. Rename the files ‘/www/webserver/htdocs/index.html’ and ‘/www/toolserver/htdocs/index.html’ to index.php. Next add the following code between the body statements within the files.


This will print out a list of the php environment if it runs correctly. We came across a problem which stopped our phpinfo from being displayed so if you have the same problem review our findings here After this you should now have a working environment with 2 Name Based Virtual Hosts. If you want to know how to configure IP based Virtual Hosting or using Alias statements to manage multiple hosts let us know and we will publish the details.

Next stage will be installing phpMyAdmin which allows us to manage the MySQL database using a GUI interface from a browser.
After that we will install SugarCRM and a few other tools and utilities. We will also look at how to create programs and interfaces that address both the DB2 and MySQL databases.

Chris…

2 thoughts on “Adding PHP to the mix”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.