Adding the application structure to the webserver

As we have noted in previous posts we are going to use one of our internal products to show application modernization using the Zend 5250 Bridge, we will be using the application we use to package, license and track all of our products which ship as IBM LPP’s.

The first action we need to take is to remove the original document root which was set up by the IBM website generator. This is accomplished by simply adding a # (comment) to the entry in the config file or deleting the line entirely. We will also removed the global ProxyPass and ProxyPassReverse statements as we are going to define them in each individual Virtual Host container. This allows a level of flexibility where we can use this same config file for serving non Proxy’d sites should we wish to do so. (We will post the completed config file at the end of this post.)

Now we need to configure Named Virtual Hosting, we have decided we will use the Apache Named Virtual Hosting capabilities to allow us to run multiple websites from a single IP and Address port.
First we add the entry to say we will use Named Virtual Hosting
NameVirtualHost 192.168.200.21:80
This is simply stating that any request passed to Port 80 on IP address 192.168.200.21 will use NameVirtualHost support built into the server. There is information about the use of this directive in the Apache Docs Under the VirtualHosts directive information.
Now we have to set up our Virtual Host information which is used by the Apache server to determine which directory structure to use. (We will also have to configure the PASE Zend server to react with this information later).

This is a sample of what you need as a minimum, we will build on this later as we add Apache features to the sites.

#Software Product Manager Application

     ServerName app.spmgr.local
     DocumentRoot /www/apps/spmgr/htdocs
     ProxyPreserveHost On
     ProxyPass / http://127.0.0.1:8000/
     ProxyPassReverse / http://127.0.0.1:8000/

The first line simply adds a comment, then we add the virtual host directive to say which virtual host we are configuring. As we are going to be using NameBased hosting this will be the same for all the servers we configure. There are too many options to discuss all of the possibilities here but you can get really creative on what you servre and how you server it!
The ServerName is what is sent back as the server name in the HTTP header, this is important because it is used to resolve the Name part of the virtualhost request.
ProxyPreserveHost On is telling the server to pass onto the proxy server the HostName (app.spmgr.local) so it can match that up with its configuration when preparing any page requests.
ProxyPass and ProxyPassReverse is how PHP is implemented, basically the PASE server is waiting for requests on the localhost port 8000 and we are going to pass all requests (/) to this proxy and we will accept all returns (/) from this same proxy.

That is all we have to do for this configuration, next we have to change the PASE configuration to support the NameVirtualHosts. Depending on what software level you are at will determine how to access the config file. There is a PTF (V5R4 SI31564) which IBM made available to allow the update of the Zend Apache Server directly from the IBM interface, but it does not appear to allow the update of the Zend Apache Configuration file which is located in /usr/local/Zend/Apache2/conf/httpd.conf. This is where we will configure the PHP side of virtual hosting.

Note:
Some have made the mistake of changing the ZENDCORE (/www/zendcore/conf/httpd.conf) configuration which is available through the IBM interface, this is configured to sit on port 89 and is configured to pass all requests back to the PASE server, but it is not set up for Virtual Hosting and will be changed if you re-install ZendCore. We leave this server up because it does allow us to go through to the ZendCore Admin panels etc. We could set our new server up to do the same thing but decided to leave this configuration as shipped.

This is a very large file so we will not post the entire file, what we will post are the changes made to the file, the rest should be left the same unless you really know what you are doing.

First lets make sure it understands that all requests will be based on a NameVirtualHost request.
Using the 5250 Link editor (WRKLNK and select edit against the file) we can position the cursor to the relevant section using Section 3 as the Control and pressing F16. This is where most of our configuration changes will be.

Note: If you use NameVirtualHosting and you mistype the server name or just don’t add it the server will pick the very first VirtualHost entry and use that information to service the request. This can be very confusing when your requests come back as 404 errors and yet the path and everything looks good!

First let the server know you want to use NameVirtualHosts, simply un-comment the NameVirtualHost entry so it reads NameVirtualHost 127.0.0.1:8000 This states it should use NameVirtualHost processing for all requests which are made through IP127.0.0.1 port 8000. We could have used NameVirtualHost *:8000 as we know any request on port 8000 should be for a PHP service but the above restricts it to a single IP address.

Here is our corresponding link to the VirtualHost we want to be served.

# PHP application for Software Product Manager

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

The elements are self explanatory but you should ensure the ServerName matches the one in the original server configuration we did above. The note about the order of the VirtualHosts containers is important, if the request passes a ServerName which does not match one in the config it will take the first VirtualHost container and use that to map the request. This can be both confusing and hard to get to grips with when you first start with VirtualHosts.

Next we will build the directory structure and add a simple PHP page to show that the configuration is working.

Add the following path using the MKDIR commands
/www/apps/spmgr/htdocs
The create a file called test.php using your favorite method (We simply used EDTF)
Add the following content



Software Product Manager


Test Page for the Software Product manager Application

Now we need to restart all of the servers as we have changed the configurations, once they have been restarted you should either add a host entry or a DNS entry before trying the following request.
http://apps.spmgr.local/test.php which if everything has gone to plan should result in a screen which has a line of text and the PHP information table printed.

Completed config file for the PHPSERVER

 1	   # Configuration originally created by Create HTTP Server wizard on Thu Nov 15 08:37:37 EST 2007
  2	   LoadModule proxy_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
  3	   LoadModule proxy_http_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
  4	   LoadModule proxy_connect_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
  5	   LoadModule proxy_ftp_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
  6	   Listen 192.168.200.21:80
  7	   # DocumentRoot /www/phpserver/htdocs
  8	   Options -ExecCGI -Includes -IncludesNoExec -Indexes -MultiViews
  9	   LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
  10	   LogFormat "%{Cookie}n "%r" %t" cookie
  11	   LogFormat "%{User-agent}i" agent
  12	   LogFormat "%{Referer}i -> %U" referer
  13	   LogFormat "%h %l %u %t "%r" %>s %b" common
  14	   CustomLog logs/access_log combined
  15	   LogMaint logs/access_log 7 0
  16	   LogMaint logs/error_log 7 0
  17	   NameVirtualHost 192.168.200.21:80
  18	   SetEnvIf "User-Agent" "Mozilla/2" nokeepalive
  19	   SetEnvIf "User-Agent" "JDK/1.0" force-response-1.0
  20	   SetEnvIf "User-Agent" "Java/1.0" force-response-1.0
  21	   SetEnvIf "User-Agent" "RealPlayer 4.0" force-response-1.0
  22	   SetEnvIf "User-Agent" "MSIE 4.0b2;" nokeepalive
  23	   SetEnvIf "User-Agent" "MSIE 4.0b2;" force-response-1.0
  25	   ProxyPreserveHost On
  26	   # ProxyPass / http://127.0.0.1:8000/
  27	   # ProxyPassReverse / http://127.0.0.1:8000/
  28	   
  29	        Order Deny,Allow
  30	        Deny From all
  31	   
  32	   
  33	        Order Allow,Deny
  34	        Allow From all
  35	   
  36	   #Software Product Manager Application
  37	   
  38	        ServerName App.spmgr.local
  39	        DocumentRoot /www/apps/spmgr/htdocs
  40	        ProxyPreserveHost On
  41	        ProxyPass / http://127.0.0.1:8000/
  42	        ProxyPassReverse / http://127.0.0.1:8000/
  43	   

Additional Notes:
If like us you have problems with the output (We had a line of hieroglyphics which made no sense at all) you should look at the CCSID of the file being published. We found that the EDTF function created the file in 13488 CCSID, after changing it back to 1252 CCSID the page displayed correctly. We did try to find out why this was happening with Zend Support last year but simply gave up once we knew how to correct the problem. If I find the real answer I will post it.

We have installed the Zend Platform which is running and should be speeding up the webserver, the problem we found is that it is caching the pages and not resending changed pages back to the browser. This did cause some confusion as the cached CCISD error would keep coming back! We had to create new files every time with new code and request those from the browser (test1.php test2.php test3.php etc as we made changes).

We will implement the ZendFramework next as this is what we will use as our design template for the new site. Setting this up using the ready installed framework will be new to us (we installed the framework within the site structure before) so we expect a few challenges.

Keep reading and let us know if you have any comments..

Chris…

Leave a Reply

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