Part IV: Open Enterprise Server Web Services
|
||||||
Chapter 14. OES Foundations
Instant Access Apache Web Server Tomcat Servlet Engine |
Instant AccessInstalling Apache Web Server and Tomcat Servlet Engine
Managing Apache Web Server
Managing Tomcat Servlet Engine
This chapter looks at Apache Web Server and Tomcat Servlet Engine. Together, they form the foundation necessary for delivering web services on the OES Linux platform:
Several powerful OES Linux services rely on Apache and Tomcat, including
The following sections will discuss Apache Web Server and Tomcat Servlet Engine and their possibilities with OES Linux. |
Apache Web Server
Apache Web Server is the primary HTTP stack provided for OES Linux. Apache is an
Apache Web Server is a complex and
Apache Web Server can be used in a few different ways on OES Linux. First, Apache is installed automatically as a dedicated web server to support the administrative tools for OES Linux and its related products and services. You can find all files
If you are using iFolder, a customized configuration of Apache is required. Normally, this is accomplished by installing iFolder on its own dedicated server (with no other OES components). However, it is possible to install other OES
NOTE The iFolder version of Apache is highly customized and specific to the iFolder process. Configuration files for this instance of Apache should not be modified manually. For more information on iFolder, see Chapter 15, "OES Web Services." Another way Apache is commonly used with OES is to host your own custom web content. In this situation, you should not load another instance of Apache, but rather customize the administrative instance of Apache to recognize a virtual server, or separate document root directory. This is covered later in this chapter. When you use iManager, accessible from any web browser, it is the Admin configuration of the Apache Web Server that serves the data between the web browser and OES Linux. Installing Apache Web ServerIf you are interested in using Apache only as the foundation for your OES Linux tools and services, you don't have to do anything to get Apache up and running. The admin server configuration of Apache is installed automatically during most OES Linux installations. However, if you chose to perform a custom installation of OES, or are adding OES components to an existing SLES9 server, you may want to install Apache manually. To install Apache Web Server manually through YaST, complete the following steps:
NOTE If you also installed Tomcat 5, the initialization script for use with that version is /etc/init.d/tomcat . These initialization scripts accept command-line parameters of start and stop , which determine what action the scripts will perform on each service. Also, the installation process will configure both of these daemons to automatically start in runlevels 2 through 5. Apache Web Server ConfigurationApache Web Servers are managed through a primary configuration file called httpd.conf and a secondary file called default-server.conf . In addition to these two main configuration files, Apache is also designed to load external service-specific configuration files stored in the /etc/apache2/conf.d directory, and virtual server configuration files found in the /etc/apache2/vhosts.d directory. When implementing a custom web server, your configuration changes could be written directly to the global configuration files for Apache. However, rather than directly editing these files, it is usually better to create new configuration files containing only your new configuration. These files can then be stored in the Apache configuration directories and easily removed or edited should the need arise.
OES Linux also
Configuring OES components through iManager may modify some of the configuration files found in the OES-specific directories. These configuration files, however, should not normally be adjusted manually. It is possible, and perhaps likely, that you will want to adjust the global, non-OES configuration files for Apache. Any configuration change you may want to implement can be performed through manually editing the configuration files, or through the YaST HTTP Server module (shown in Figure 14.1). Figure 14.1. HTTP Server YaST Module.
The HTTP Server module within YaST can be used to adjust most of the commonly modified parameters of Apache. To use this module, execute the following steps:
Using the HTTP Server module is
Storing Web Content
The most important aspect of running a web server is making sure that the various web pages are available to your web users. Although the art of creating web pages is beyond the scope of this book, you need to know the basics about storing files on Apache Web Servers so that pages will be available as needed. To do this, you should become familiar with three main web server directory features: Document Root, Additional Document Directories, and
DOCUMENT ROOT
The home page associated with your web server's IP address and/or DNS
The document root, also called the
primary document directory
, is where a web server will start looking for
/srv/www/htdocs
Because it's not
NOTE For the best web server performance, you should keep the document root as high in the directory structure as possible to reduce document search times.
YaST makes performing these type of changes a rather trivial task, but it is also important to understand how to perform these changes from a terminal. To adjust the DocumentRoot manually from a terminal, complete the following steps:
After restarting Apache, you will be able to access your web content at the new directory. ADDITIONAL DOCUMENT DIRECTORIESYou can also create additional document directories for those who want to publish their own content, but to whom you don't want to grant access to the document root. This also lets you easily distribute the responsibility of web content to those responsible for it.
This functionality requires the use of the
Alias
directive. This directive is used to map a local file system directory to a
url-path
. When the
url-path
is accessed, Apache automatically
To create an additional document directory manually using the Alias directive, you must add an Alias definition and Directory configuration entry into one of the Apache configuration files, such as default-server.conf or a custom configuration file in /etc/apache2/vhosts.d . This entry should be configured as in the following example:
Alias /marketing /var/web/marketing
<Directory /var/web/marketing>
Order allow,deny
Allow from all
</Directory>
The
Alias
directive in this example links the
/marketing url-path
to the
/var/web/marketing
directory. When
USER HOME DIRECTORIES
This feature enables you to set up document directories for each local user, and any LUM user in your eDirectory tree. These document directories are then used as personal
In order to use this feature, the mod_userdir Apache module must be installed and configured. This is performed automatically, with the OES installation, and if necessary can be double-checked through the Add and Remove Software module of YaST. If you'd like to adjust the default configuration of this module, you must edit the /etc/apache2/mod_userdir.conf configuration file. The following are some important directives found within this file:
After adjusting any parameters in this file, restart Apache for your changes to take effect. Using the default configuration, users' web directories can be found in the
public_html
directory
http://www.quills.com/~jharris
NOTE Before attempting to access the web directory for LUM users, ensure that they have logged in at least one time. Logging in will create their home directory and the public_html directory beneath their home directory that is required for web access. If you want to avoid encountering a listing of the contents of the public_html directory, each user should create an index.html file as a placeholder in this directory. To configure this automatically for all new users, create a default index.html file and place it in /etc/skel/public_html . All new users will automatically receive a copy of this file during their home directory creation. Hosting Multiple Websites
Apache supports
virtual servers
to host multiple websites on a single physical server. This lets a single OES Linux server
You can host two types of virtual servers on your Linux server:
NOTE Due to requirements of SSL, Name-based Virtual Hosting is not compatible with SSL communication. If SSL is a requirement, you must use IP-based Virtual Hosting. In order to configure either of these types of virtual servers, you should create a configuration file for each virtual host (named after each host with a .conf extension), and place the configuration file in the /etc/apache2/vhosts.d directory. You can also create a new host from within the HTTP Server module in YaST by following these steps:
The
NOTE For more information on both of these virtual server options, see the Apache documentation at http://httpd.apache.org/docs-2.0/vhosts/. Apache Modules
Apache Web Server has been developed with a component architecture that
Several modules are available for use with Apache Web Server on OES Linux:
Each of these modules can be installed via the Install and Remove Software module of YaST. For more information on using Apache modules, see the Apache Web Server documentation site at http://httpd.apache.org/docs-2.0/mod/. Adding Content to Your WebsiteAfter Apache Web Server has been installed and enabled, you can immediately access a sample web page and some subpages that are included for demonstration. The default website used with OES is a collection of OES component Welcome pages. These pages offer links to many of the management utilities that are available with OES. This content is accessed using the HTML data stored at the default document root at /srv/www/htdocs . To view the default OES Welcome pages, open a client web browser on a workstation in your network and enter your OES server's IP address or DNS name. For example: http://prv-serv1.quills.com When your web server is running, you can start posting content for your web server audience to accesswhether that's your department, your company, or the whole world. Do this by placing files in the web server's primary or additional document directories.
For example, suppose you created a new HTML file called
mktg_docs.html
that includes links to the marketing
After the file is stored in the additional document directory, users can access the file by entering the web server's DNS name together with the additional document directory identifier and the filename. For example: http://www.quills.com/marketing/mktg_docs.html The same general process governs the creation of any web content, whether that content is an Internet site, a corporate intranet, a departmental page, or even a personal web page. What differentiates one web site from another is how it is available (internally versus externally) and what type of server it is running on. External sites and larger corporate sites are usually run on dedicated web servers or hardware virtual servers, whereas smaller departmental sites work well on software virtual servers where users can easily create personalized pages, if necessary. Publishing Content to a WebsiteWhen you are configuring an internal website, you will often have areas of a website that are available for contributors to publish their content. This makes it possible for users to communicate within a department, share information with other departments, and communicate items of general interest.
NOTE Virtual Office is a powerful new feature for OES Linux that makes it much easier to create temporary or ad-hoc portals for information-sharing purposes. For more information on Virtual Office, see Chapter 15. Web content contributors have several options for publishing content to your web server. For example:
Additionally, users who are familiar with web publishing tools can choose any of those with which they are familiar. PUBLISHING CONTENT USING A MAPPED DRIVE
If your contributors are using the Novell Client, this is one way of providing access to web content areas. Use iManager to assign the appropriate rights to web content contributors and provide users with the correct network path so that they can map a drive to the content directory. For use with mapped
PUBLISHING CONTENT USING WEBDAV
Web-based Distributed Authoring and Versioning (WebDAV) is an
WebDAV support is provided on OES Linux through NetStorage. With NetStorage enabled, you can publish content directly to a specified document directory from any WebDAV-enabled browser, for example, Internet Explorer. For more information on NetStorage, see Chapter 12, "OES Linux File Access." PUBLISHING CONTENT WITH NETDRIVENovell NetDrive lets you map a drive to any server without using the traditional Novell Client. This means that with NetDrive, you can access your files on any server and modify them through standard Windows utilities such as Windows Explorer. The NetDrive client can be installed from the Novell client's CD-ROM. For more information on NetDrive, see Chapter 12. Apache Web Server Management
Managing Apache Web Server on a day-to-day basis should not
SERVER CONFIGURATION
The main area of concern for most administrators is the basic configuration of their Apache server. Although this has been covered
PERFORMANCE TUNINGPerformance within Apache is not normally an issue. However, if you have customized your web configuration to include a large amount of data, or are expecting your server to be under a heavy load, it may be worth your time to investigate this subject.
Apache-specific performance tuning options are
MIME TYPESAlso known as context labels, MIME (Multipurpose Internet Mail Extension) types specify the file types that Apache Web Server recognizes and supports. The MIME types configuration file is /etc/apache2/mime.types . This file is actually just a symbolic link to the same mime.types file used by SLES ( /etc/mime.types ). It is important that this file contain the definitions of all file types used on your Apache server. For example, if you want to put MP3 files on your server, you must add the MP3 extension to your MIME types. If this extension is not added, the server transfers the file to the user as text, instead of as a sound file. To add a new MIME type to your web server, add a new entry into the /etc/mime.types file containing the following two fields:
NOTE To add a new extension to an already defined MIME type, just add the new extension to the existing MIME definition. Separate multiple extensions with spaces. After making the changes, save the updated file and the new MIME type will be recognized at the next Apache restart. LISTEN PORTSThe /etc/apache2/listen.conf file is used to configure the various IP addresses and ports that Apache Web Server uses to listen for incoming requests. If you have to adjust these settings, you should be aware of which ports may already be in use by other OES components. Some port assignments in the OES Linux environment can be reassigned, whereas others are permanent. Table 14.1 shows the default port assignments for OES Linux web services as a starting point for any adjustments you may have to make. Table 14.1. OES Linux Default Port Assignments
ERROR RESPONSESTypical HTTP error messages are pretty generic and do not give much information. Use the /etc/apache2/errors.conf file to customize error messages and potentially redirect the client to a location where more help is available. When a server cannot complete a request, it typically sends one of the following four error messages to the client:
In place of these generic errors, there are many situations in which you might want to use custom messages. For example, if users are denied access, instead of receiving a message that simply says "Unauthorized," they could receive a custom error message that explains the reason they were denied access and points them to the help desk to have an account created. The default installation of Apache already employs custom error pages. These pages are defined in errors.conf and found in the /usr/share/apache2/error directory. To further change the error response for your server, the error pages found in this directory can be customized, or the error code and new action can be manually defined in the errors.conf file. Manual changes to errors.conf must be in the following format: ErrorDocument < Error_Code > < Action >
Possible actions include a custom message
SERVER LOGS
In addition to configuration changes and website updates, monitoring your web activity through log files is necessary to track down errors, and an
ACCESS LOGThe access log records information about web clients that access your web server, and records client information such as IP addresses and date and time of access. By default, the access log is /var/log/apache2/access_log . The access log is configured in a number of places because the access log is normally specific to each virtual server. However, there is still a default, site wide configuration for the access log. This configuration is found in the /etc/sysconfig/apache2 file. In this file, the APACHE_ACCESS_LOG directive defines where the default log is located. ERROR LOGThe error log records diagnostic information related to errors that occurred while processing requests. The error log is very important because it often contains details of what went wrong and how to fix it. By default, the error log is /var/log/apache2/error_log . If necessary, this location can be adjusted in the httpd.conf configuration file. If necessary, the logging level of the error log can be adjusted using the APACHE_LOGLEVEL directive in the /etc/sysconfig/apache2 file. Care should be taken when adjusting this to track more information as performance may suffer because of the logging of unnecessary details. |