JKL Toy Company adds user directories for HTTP Server

This scenario discusses how to add a user directory in an IBM® HTTP Server for i Web server.

Scenario

The JKL Toy Company (a fictitious company) has decided to allow employees to maintain their own personal Web pages. The JKL Web administrator wants the personal Web pages to be stored in a directory of the root file system called /home on the JKLTEST HTTP Server. The directory /home will contain one subdirectory for each employee.

To begin, the JKL Web administrator creates a user profile and user directory for fellow employee Sharon Jones on the IBM i server. The new user profile will be called SJONES and the new user directory will be located at /home/sjones.

Prerequisites

Create a new user profile with System i Navigator

For in-depth information on how to use the System i Navigator, read the System i Navigator help installed with the product.

Note: It is not necessary to create a new user profile on your IBM i server if you want to use an existing profile. If using an existing profile, make certain the user profile has the appropriate permissions.
  1. Start System i Navigator.
  2. Expand the IBM i server the HTTP Server is installed on.

    Example: JKL_SERVER

  3. Select Users and Groups, or click the Users and Group icon in the toolbar.
  4. Click Create a new user, or click the Create a New Use icon in the toolbar.
  5. Enter a new user name.

    Example: SJONES

  6. Optional: Enter a description for this new profile.

    Example: This is a test profile.

  7. Optional: Add a password if necessary for your IBM i server.
  8. Click Capabilities.
  9. Set the system privileges to allow the new user profile to use the HTTP Server.
  10. Click OK.
  11. Click Add.

Create a new user directory with System i Navigator

Note: The /home directory comes preinstalled on your IBM i server.
  1. Start System i Navigator.
  2. Expand the IBM i server the HTTP Server is installed on.

    Example: JKL_SERVER

  3. Expand File Systems > Integrated File System > Root.
  4. Right-click directory home.
  5. Click New Folder.
  6. Enter the name of your new user profile.

    Example: sjones

  7. Click OK.

Copy HTML welcome page to user directory with System i Navigator

The new user directory does not contain any files. Use System i Navigator to copy index.html, found in /www/[server_name]/htdocs directory of your HTTP Server, to your new user directory.

Example: /www/jkltest/htdocs

  1. Start System i Navigator.
  2. Expand the IBM i server the HTTP Server is installed on.

    Example: JKL_SERVER

  3. Expand File Systems > Integrated File Systems > Root > www > [server_name] > htdocs.

    Example: /www/jkltest/htdocs

  4. Right-click file index.html.
  5. Click Copy.
  6. Right-click the new user directory.

    Example: sjones

  7. Click Paste.

Optional: Edit file index.html in any way you choose. This is the file the HTTP Server will look for when this directory is requested by the Web browser.

Start the IBM Web Administration for i interface

Access the IBM Web Administration for i from your browser. For information about how to access the Web Administration for i interface, see Starting Web Administration for i.

Set up user directories for HTTP Server

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server from the Server list.

    Example: JKLTEST

  4. Select Global configuration from the Server area list.
  5. Expand Server properties.
  6. Click URL Mapping.
  7. Click the User Directories tab in the form.
  8. Select Disable all users except for the following under Enable or Disable user directories.
  9. Click Add under the Enabled users table.
  10. Enter the name of your new user profile.

    Example: sjones

  11. Click Continue.
  12. Click Add under the Current user directories table.
  13. Enter /home in the User directories column.
    Note: The order in which the user directories are listed determines which directory the HTTP Server will use first. If a match is not found in the first (top) user directory, the next user directory listed will be used. This continues until a match is found.
  14. Click Continue.
  15. Click OK.

Set up /home directory for HTTP Server

After creating the user directory, you must set up your HTTP Server to provide access to directory /home.

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select Global configuration from the Server area list.
  4. Expand Server Properties.
  5. Click Container Management.
  6. Click the Directories tab in the form.
  7. Click Add under Directory/Directory Match containers table.
  8. Select Directory from the list in the Type column.
  9. Enter /home in the Directory path or expression column.
  10. Click Continue.
  11. Click OK.
  12. Select Directory /home from the Server area list.
  13. Click Security.
  14. Click the Control Access tab in the form.
  15. Select Deny then allow from the Order for evaluating access list under Control access based on where the request is coming from.
  16. Select Allow access to all, except the following under Control access based on where the request is coming from.
    Note: Do not add restrictions at this time. Return to this form at the end of the scenario to add restrictions.
  17. Click OK.

Restart your HTTP Server

Select one of the following methods below:

Manage one server

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server from the Server list.
  4. Click the Stop icon if the server is running.
  5. Click the Start icon.

Manage all servers

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select All Servers from the Server list.
  4. Click the All HTTP Servers tab.
  5. Select your HTTP Server name in the table.

    Example: JKLTEST

  6. Click Stop if the server is running.
  7. Click Start.
Note: If your HTTP Server does not start, see Troubleshooting.

Test your HTTP Server

  1. Open a new Web browser.
  2. Enter http://[i_hostname]:[port]/~[user_directory] in the location or URL field .

    Example: http://jkl_server:1975/~sjones

Your new user directory will display the generic HTML file copied from directory /htdocs.

View your HTTP Server configuration

Your configuration will look similar if you used the given example in this and previous examples.

  1. Click the Manage tab.
  2. Click the HTTP Servers subtab.
  3. Select your HTTP Server from the Server list.

    Example: JKLTEST

  4. Expand Tools.
  5. Click Display Configuration File.

Listen *:1975
DocumentRoot /www/jkltest/htdocs
TraceEnable Off
Options -FollowSymLinks 
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
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
UserDir Disable
UserDir Enable Sjones
UserDir /home
<Directory />
	Require all denied
</Directory>
<Directory /www/jkltest/htdocs>
	Require all granted
</Directory>
<Directory /home>
	Require all granted
</Directory>