Presentation on theme: "Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope Treasurer."— Presentation transcript:
Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope Treasurer – Metro Midrange Systems Association
iSeries GUI Debugger Chris Adair Information Systems Director - National Envelope Treasurer – Metro Midrange Systems Association
Disclaimer Note: In this presentation, when we refer to the eServer i5 or iSeries primary operating system, we refer to OS/400, even though the operating system name has changed to i5/OS in V5R3. If it is not explicitly stated otherwise, the term OS/400 also refers to i5/OS.
HTTP Server And CGI How many of you have a HTTP Server running on a Systemi? How many of you have CGI running on that server?
What is an HTTP Server? A computer that is responsible for accepting HTTP requests from clients, which are known as Web browsers, and serving them HTTP responses along with optional data contents, which usually are Web pages such as HTML documents and linked objects (images, etc.).
Why the Apache HTTP Server? Most popular Web server in the industry –70% of the web sites on the internet are using Apache ( 2005 Netcraft Web Server Survey) Easily maintainable –Many Apache skills in the marketplace Scalable –Handles the small usage sites to the well traveled sites Affordability –Most likely, you already have everything you need.
What Do You Need? 5722–DG1 IBM HTTP Server for iSeries –HTTP Server (original) - Only until OS/400 V5R2 –HTTP Server Powered by Apache –Net.Data –Webserver Search Engine and Crawler –Apache Software Foundation’s Jakarta Tomcat –Highly Available HTTP Server –Triggered Cache Manager 5722-TC1 TCP/IP Utilities 5722-JV1 Java Developer Kit 1.3
The Admin Server A HTTP Server used to manage Web Servers To Start the Admin Server –iSeries Navigator Under Network > Servers > TCP/IP: Right Click HTTP Administration –Command STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)
Accessing the Admin Server The Admin Server “listens” on port 2001 for normal HTTP traffic Using a browser, enter this URL –http://your_system:2001/http://your_system:2001/ The Admin Server is secured by i5/OS user profiles User profiles must have *IOSYSCFG and *ALLOBJ special authority to perform configuration activities IBM does not recommend using QSECOFR
Now that the Admin Server is started, we can use the wizard to create a new IBM HTTP Server Powered by Apache
Create a New HTTP Server From the Admin Server, click IBM Web Administration for iSeries When the HTTPAdmin page is displayed, be sure to select the “Manage” and “All Servers” tabs From the navigation pane on the left, click “Create HTTP Server”
Step 1: Server Name and Desc. On the Create HTTP Server pane, key a name and description for your server. On the bottom of the page, click “Next”.
Step 2: Specify Root Directory The root directory is where the configuration files and log files are kept. This will be in the Integrated File System. Typically, this will just be defaulted, and there’s nothing to key. On the bottom of the page click “Next”.
Step 3: Specify Document Root The document root directory is where all the servable files are kept. You will put all your HTML’s, images, etc... under this directory or subdirectories Typically, this will just be defaulted, and there’s nothing to key. On the bottom of the page click “Next”.
Step 4: Specify IP Addresses / Port Typically, you will want all IP addresses Key the desired port number –The HTTP default is 80 –Do not use a port number already in use On the bottom of the page click “Next”.
Step 5: Access Log You can indicate whether or not you want an access log. An access log will keep track of who is making requests of your server. The error log will automatically be created, regardless of this selection. On the bottom of the page click “Next”.
Step 6: Specify Time to Keep Logs New log files will be created on a daily basis to prevent any one file from becoming to large. Specify whether or not to keep log files, both error and access logs. And, how many days to wait before they’re purged On the bottom of the page click “Next”.
Step 7: Summary Screen The wizard displays all the information from the prior steps for a final review. If any changes are needed, click the “Back” button. If no changes are needed, and your ready to create the server, click “Finish”.
Back To The Admin Server Once completed, the Admin Server is displayed with the new server. We can continue to make configuration changes, or start the server and give it a test, We’ll start the server by clicking the green arrow.
Here’s What We Added Some IFS Directories/Files to hold our configuration and content 5 Jobs running in the QHTTPSVR subsystem Let’s take a look……
Serve Some Static Reports
Create Your Own index.html Using your favorite HTML editor, make your own index.html. I used IBM Rational Software Gave my page a title and image Moved it to the “HTDOCS” directory under APACHE01 in the IFS
Add Some Directories I added some links for a few locations Those links need to direct us to a directory under the APACHE01, where I plan to put some month end reports, stored as PDF’s But first, we’ll need to change the configuration of the server to allow directory listings.
Global Configuration I added all my directories under “Global Configuration”. Now, I need to go to each directory location and specify “Directory Handling” and “Security”
Create the IFS Directories Now that the server is set, we need to create the IFS directories Using iSeries Navigator: –Under File Systems > IFS > Root > WWW > Apache01, Right click on HTDOCS and select “New Folder”.
Restart the Server All my directories have now been entered. I’ve secured the ones I need, based on a i5/OS profile. All the directories have been created on the IFS. Let’s restart the server and see what happens.
There’s Not Any Files Use your SPLF conversion utility to put some files in the directories If you don’t have a SPLF conversion utility –Take a look at this site: –Download 4 source members: CVT2CMD, CVT2CLP, CVT2HTML, and CVT2PDF –Compile and Run
Summary Started the Admin Server Created an IBM HTTP Server (Powered by Apache) Configured the server Added some IFS directories Downloaded some conversion software Displaying static reports via the browser
Dynamic Data Examples CGI Net.Data PHP PERL WevDav
Step 1: CGI Create a new library to hold your new programs –CGILIB Create source file –CGILIB/QRPGLESRC Copy Service Program to your new library –QHTTPSVR/QZHBCGI
Step 2: Binding Directory Create a binding directory –CGILIB/CGIBNDDIR Put your QZHBCGI service program in the binding directory. –ADDBNDDIRE
Step 3: Change Your HTTP Server We’ll to change the configuration to allow for CGI programs –Add a directory under Global configuration –Add a “Script Alias Match” under URL Mapping in Global configuration –Check security of new directory –Enable CGI in new directory Stop the server and re-start
Step 4: Create a Sample Program Don’t let all the CGI routines scare you Basically, all it’s doing is formatting some HTML and giving it to the browser. Compile using CRTBNDRPG and place in the CGILIB
If It Doesn’t Work Check the error log in the IFS –/www/apache01/logs/error_log Check you server configuration –If you didn’t APPLY your changes, it may not have taken Check security of the CGI directory
Summary We made a library and put a service program and binding directory in it. Changed a few things on our HTTP Server to allow for CGI Wrote some sample code to test CGI
Using you favorite HTML editor, create a page that asks for some input. I created an “Inventory Lookup” page The user keys a SKU number, presses “Submit” The “Submit” actually calls a CGI program I use the QtmhGetEnv API to retrieve the SKU number entered Process the request and display
Some CGI Freebies WRKCGISPLF STRCGISQL
Summary We started the Admin Server Created and configured a HTTP server Allowed for some static report serving Compiled and ran some CGI Cost = 0 –Most likely, you already have everything you need.
Hints Learn some HTML –It doesn’t take much to get started. The basic syntax of creating some basic HTML Tables and Hyperlinks will go a long way Buy a good CGI book and read the online articles –Brad Stone –Paul Tuohy –Bob Cozzi –Jon Paris –All are using RPG CGI and have written publications on how to get started
CGIDEV2 Thank You, Giovanni B. Perotti –39 years at IBM –Creator of CGIDEV2 If you’re at V5R1 download CGIDEV2 –http://www.easy400.net/easy400p/maindown. htmlhttp://www.easy400.net/easy400p/maindown. html Lot’s of code samples and pre-written procedures