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
- It is assumed you have read Scenarios: HTTP Server.
- It is assumed you have read and completed JKL Toy Company creates an HTTP Server or you have an existing HTTP Server configuration.
- It is assumed you have read and completed JKL Toy Company adds a new directory to HTTP Server.
- It is assumed you have installed and are familiar with System i® Navigator.
- It is assumed you have read User profiles and required authorities for HTTP Server.
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.
- Start System i Navigator.
- Expand the IBM i server
the HTTP Server is installed on.
Example: JKL_SERVER
- Select Users and Groups, or click the Users and Group icon in the toolbar.
- Click Create a new user, or click the Create a New Use icon in the toolbar.
- Enter a new user name.
Example: SJONES
- Optional: Enter a description for this new profile.
Example: This is a test profile.
- Optional: Add a password if necessary for your IBM i server.
- Click Capabilities.
- Set the system privileges to allow the new user profile to use the HTTP Server.
- Click OK.
- Click Add.
Create a new user directory with System i Navigator
- Start System i Navigator.
- Expand the IBM i server
the HTTP Server is installed on.
Example: JKL_SERVER
- Expand File Systems > Integrated File System > Root.
- Right-click directory home.
- Click New Folder.
- Enter the name of your new user profile.
Example: sjones
- 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
- Start System i Navigator.
- Expand the IBM i server
the HTTP Server is installed on.
Example: JKL_SERVER
- Expand File Systems > Integrated File Systems > Root >
www > [server_name] > htdocs.
Example: /www/jkltest/htdocs
- Right-click file index.html.
- Click Copy.
- Right-click the new user directory.
Example: sjones
- 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
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
Example: JKLTEST
- Select Global configuration from the Server area list.
- Expand Server properties.
- Click URL Mapping.
- Click the User Directories tab in the form.
- Select Disable all users except for the following under Enable or Disable user directories.
- Click Add under the Enabled users table.
- Enter the name of your new user profile.
Example: sjones
- Click Continue.
- Click Add under the Current user directories table.
- 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.
- Click Continue.
- 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.
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select Global configuration from the Server area list.
- Expand Server Properties.
- Click Container Management.
- Click the Directories tab in the form.
- Click Add under Directory/Directory Match containers table.
- Select Directory from the list in the Type column.
- Enter /home in the Directory path or expression column.
- Click Continue.
- Click OK.
- Select Directory /home from the Server area list.
- Click Security.
- Click the Control Access tab in the form.
- Select Deny then allow from the Order for evaluating access list under Control access based on where the request is coming from.
- 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.
- Click OK.
Restart your HTTP Server
Select one of the following methods below:
Manage one server
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
- Click the Stop icon if the server is running.
- Click the Start icon.
Manage all servers
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select All Servers from the Server list.
- Click the All HTTP Servers tab.
- Select your HTTP Server name in the table.
Example: JKLTEST
- Click Stop if the server is running.
- Click Start.
Test your HTTP Server
- Open a new Web browser.
- 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.
- Click the Manage tab.
- Click the HTTP Servers subtab.
- Select your HTTP Server from the Server list.
Example: JKLTEST
- Expand Tools.
- 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>