|
|
All AS/400 Tip Categories
/
Web
/
Configuring the AS/400 as a Web Server
Question:
How do you serve Web pages from the AS/400? What's the easiest way
to set it up?
Answer(s):
Basic Web configuration doesn't take much effort at all. Of course,
you do have to have TCP/IP up and running. And with HTTP Server for
AS/400 (known as Internet Connection Server in versions of OS/400
prior to V4R3), you have to explicitly authorize the server to serve
pages from a particular location. HTTP Server can serve out of all
AS/400 filing systems, but because the IFS is best for speed and
compatibility, my instructions are for serving Web information from a
directory in the IFS. Let's get creative and call this directory
"web". The first thing to do is create this directory. Of the many
ways to do this, one is to use the CRTDIR command. Issue the following
command from an AS/400 command line to call our Web directory "web"
and put it in the IFS:
CRTDIR DIR(web)
To enable Web browsing via the HTTP server, you need to make sure the
special Web user profile QTMHHTTP has at least *RX authority to the
Web folder and the objects within that folder. Do this by issuing the
following commands:
To enable access to the folder:
CHGAUT OBJ('/web') USER(QTMHHTTP) DTAAUT(*RX)
To enable access to the folder's objects, for each object run the following command:
CHGAUT OBJ('/web/*') USER(QTMHHTTP) DTAAUT(*RX)
Note: You need to be sure that the QTMHHTTP profile has *RX authority
to all objects served by the Web server. This includes new files that
get placed on your Web server. When you add new objects to your Web
server, you may have to rerun the second CHGAUT command shown above for the objects that you add. Also, the 2nd CHGAUT command (the one with wildcards) will not change authorities in directories underneath /web, so you'll have to change each directory specifically (and the objects in that directory).
The next step is to change the Web server's configuration. This is
actually a source file member with lines in it representing different
Web server configuration settings. These lines are called directives.
Directives can do many things, including determining which files are
served, protecting directories with a password, and allowing users to
see files in directories. Groups of directives are stored in members
in a configuration file (QUSRSYS/QATMHTTPC). If you want to get
tricky, with V4R1+, you can have multiple configurations going at the
same time, listening on different ports. For now, we'll work with a
single configuration, the default configuration.
Make sure someone else isn't already using the AS/400 as a Web server,
and make the changes shown below to matching lines in the file. If you
don't have a configuration file, enter the lines exactly as shown, one
directive on each line of the configuration file. Don't forget the
asterisks!
To create/change HTTP Server directives, from an AS/400 command line
type "WRKHTTPCFG" and press Enter. This will bring up the default
configuration. IBM supplies a configuration file with
lots of directives in it as a sample. You can comment out lines by
beginning the line with a # sign. I suggest using a # and your
initials to mark the lines that you comment out. If you're certain
your AS/400 isn't already working as a Web server (i.e., you're not
stepping on anyone's current configuration), comment out any
uncommented lines and enter the following directives:
*Minimal Web Server directives*
Welcome index.htm
AlwaysWelcome On
DirAccess Off
PASS /* /web/*
Once the Web server is configured, the next step is to start it. Do
this by issuing the following command:
STRTCPSVR *HTTP
This will start all instances of the Web server. If you want to start
only your instance, issue the command STRTCPSVR SERVER(*HTTP)
HTTPSVR([your instance]).
That's all there is to configuring the AS/400 as a Web server. The
next step is to put an HTML file into the '/web' directory on your
AS/400. First, create an HTML file using any tool (many PC tools can
do this, or you could use the spool file example from last issue).
Then use Client Access Network Drives (or, better yet, OS/400's
NetServer) to drag the spool file from your PC to the '/web' directory
on your AS/400. You can name it anything you want, but I suggest
"index.htm" for your first file name. The directives we used above
will cause the file named "index.htm" to be served when people don't
request a specific file. It is your "Welcome" file or your home page.
Make sure the QTMHHTTP profile has *RX authority to it (and all Web
objects), as described above.
To surf your AS/400, simply type:
http://as400name/
where "as400name" is the TCP/IP name of your AS/400. The Web page
called "index.htm" will be served directly to your browser. You're
surfing your AS/400!
For more information about how to configure your AS/400 to be a Web
server, see the Internet/Web Servers section of our new Index400 Web
site at
http://www.news400.com/index400/52.htm
Other tips in this category:
Click here to see all categories.
Configuring the AS/400 as a Web Server
HTTP Protect Directives
A Simple Web Counter in RPG
How To Set Up Multiple WWW Domains
Is there a webcounter for the AS/400?
Net.Data trouble
AS/400 HTTP Server
|