+ All Categories
Home > Documents > Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems...

Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems...

Date post: 31-Mar-2015
Category:
Upload: johan-mumby
View: 215 times
Download: 2 times
Share this document with a friend
Popular Tags:
93
Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope [email protected] Treasurer – Metro Midrange Systems Association [email protected]
Transcript
Page 1: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Getting Started with IBM HTTP Server Powered by Apache and CGI

Chris Adair

Information Systems Director - National [email protected]

Treasurer – Metro Midrange Systems [email protected]

Page 2: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 3: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

iSeries GUI Debugger

Chris Adair

Information Systems Director - National [email protected]

Treasurer – Metro Midrange Systems [email protected]

Page 4: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 5: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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?

Page 6: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.).

Page 7: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 8: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 9: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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)

Page 10: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 11: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 12: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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/

• 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

Page 13: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 14: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 15: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Now that the Admin Server is started, we can use the wizard

to create a new IBM HTTP Server Powered by Apache

Page 16: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”

Page 17: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 18: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 19: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 20: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 21: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 22: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 23: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 24: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 25: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 26: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 27: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 28: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 29: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 30: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 31: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 32: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 33: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 34: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 35: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 36: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 37: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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……

Page 38: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 39: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 40: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Serve Some Static Reports

Page 41: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 42: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 43: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 44: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 45: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 46: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 47: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 48: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 49: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 50: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”

Page 51: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 52: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 53: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 54: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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”.

Page 55: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 56: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 57: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 58: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 59: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 60: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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:

• http://www.code400.com/cvt2pdf.php

– Download 4 source members:• CVT2CMD, CVT2CLP, CVT2HTML, and CVT2PDF

– Compile and Run

Page 61: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 62: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 63: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 64: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Dynamic Data

Page 65: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Dynamic Data Examples

• CGI

• Net.Data

• PHP

• PERL

• WevDav

Page 66: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 67: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

QHTTPSVR/QZHBCGI

• Contains HTTP API procedures for communicating with server – just a few are:

– QtmhWrStout – The most used API that writes data to standard output. In other words, writes HTML or JavaScript commands to a browser.

– QtmhRdStin – This API will read information that is made available with a POST operation.

– QtmhGetEnv – Used to retrieve values set by the server. Typically used to retrieve GET data.

Page 68: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Step 2: Binding Directory

• Create a binding directory– CGILIB/CGIBNDDIR

• Put your QZHBCGI service program in the binding directory.– ADDBNDDIRE

Page 69: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 70: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 71: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 72: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 73: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 74: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 75: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 76: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 77: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 78: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 79: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Interactive CGI

Page 80: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Interactive 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

Page 81: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 82: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.
Page 83: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Code Snippets

Page 84: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

CGI Freebies

Page 86: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

WRKCGISPLF

Page 87: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

STRCGISQL

Page 88: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

STRCGISQL

Page 89: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Conclusion

Page 90: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

Page 91: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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

Page 92: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

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.

html

• Lot’s of code samples and pre-written procedures

Page 93: Getting Started with IBM HTTP Server Powered by Apache and CGI Chris Adair Information Systems Director - National Envelope cadair@natenv.com Treasurer.

Questions?

You may contact me via email at:

[email protected]


Recommended