While every precaution has been taken in the preparation of this book, the .. Describes how to create Apache modules using the Apache Apache server transparently send the most appropriate content type (PDF files to suitable. Finding Modules Using caite.info Installing .. The recipes in this book are geared toward two major platforms: Unixish (such as. Linux. EBook收集整理国内外最新IT计算机编程PDF电子书，提供免费电子书下载 服务. Now, caite.info's Nick Kew has written The Apache Modules Book .
|Language:||English, Spanish, Portuguese|
|Genre:||Children & Youth|
|ePub File Size:||30.47 MB|
|PDF File Size:||14.41 MB|
|Distribution:||Free* [*Regsitration Required]|
The Apache modules book: application development with Apache / Nick Kew. p. cm. might change the contents from XML to HTML or PDF. with Perl modules, the focus of the book is on the Apache API through the eyes of the convert Adobe Acrobat (PDF) files into GIF images when dealing with a. docs/The Apache Modules Book - Application Development with caite.info Fetching contributors Cannot retrieve contributors at this time. MB.
The main Apache server configuration file. In doing so, ensure that no critical files, such as password or system configuration files, can be read from the outside. Apache uses the host field in the HTTP header that is sent by the client to connect the request to a matching ServerName entry of one of the virtual host declarations. Tells Apache to handle all files within this directory as CGI scripts. Now you can generate the certificate. To develop modules for Apache or compile third-party modules, the package apache2-devel is required along with the corresponding development tools.
By doing so, you can provide different module sets for different virtual hosts. Global configuration for all virtual hosts with reasonable defaults.
Instead of changing the values, overwrite them with a virtual host configuration. Defines how Apache responds to errors. To customize these messages for all virtual hosts, edit this file. Otherwise overwrite these directives in your virtual host configurations. The main Apache server configuration file.
Avoid changing this file. It primarily contains include statements and global settings. Overwrite global settings in the pertinent configuration files listed here. Change host-specific settings such as document root in your virtual host configuration. Binds Apache to specific IP addresses and ports. Name-based virtual hosting is also configured here. Do not change this file. Configuration files for the modules that are installed by default.
Note that configuration files for optional modules reside in the directory conf. Properly test your Web server when making changes here. Do not put other configuration files in this directory. Your virtual host configuration should be located here. The directory contains template files for virtual hosts with and without SSL.
Every file in this directory ending with. Configuring Apache manually involves editing plain text configuration files as user root. The term virtual host refers to Apache's ability to serve multiple universal resource identifiers URIs from the same physical machine. This means that several domains, such as www. It is common practice to use virtual hosts to save administrative effort only a single Web server needs to be maintained and hardware expenses each domain does not require a dedicated server.
Virtual hosts can be name based, IP based, or port based. To list all existing virtual hosts, use the command apache2ctl -S. This outputs a list showing the default server and all virtual hosts together with their IP addresses and listening ports. Furthermore, the list also contains an entry for each virtual host showing its location in the configuration files.
All files in this directory with the extension. A basic template for a virtual host is provided in this directory vhost. It is recommended to always create a virtual host configuration file, even if your Web server only hosts one domain. By doing so, you not only have the domain-specific configuration in one file, but you can always fall back to a working basic configuration by simply moving, deleting, or renaming the configuration file for the virtual host.
For the same reason, you should also create separate configuration files for each virtual host. When using name-based virtual hosts it is recommended to set up a default configuration that will be used when a domain name does not match a virtual host configuration.
The default virtual host is the one whose configuration is loaded first. When Apache receives a client request for a defined virtual host, it uses the directives enclosed in this section. Almost all directives can be used in a virtual host context. See http: With name-based virtual hosts, more than one Web site is served per IP address. Apache uses the host field in the HTTP header that is sent by the client to connect the request to a matching ServerName entry of one of the virtual host declarations.
If no matching ServerName is found, the first specified virtual host is used as a default. The opening VirtualHost tag takes the IP address or fully qualified domain name as an argument in a name-based virtual host configuration. A port number directive is optional. When using IPv6 addresses, the address must be included in square brackets. This alternative virtual host configuration requires the setup of multiple IP addresses for a machine. One instance of Apache hosts several domains, each of which is assigned a different IP.
The physical server must have one IP address for each IP-based virtual host. If the machine does not have multiple network cards, virtual network interfaces IP aliasing can also be used. The following example shows Apache running on a machine with the IP A separate VirtualHost block is needed for every virtual server. Here, VirtualHost directives are only specified for interfaces other than When a Listen directive is also configured for At least the following directives should be in each virtual host configuration to set up a virtual host.
Path to the directory from which Apache should serve files for this host. For security reasons, access to the entire file system is forbidden by default, so you must explicitly unlock this directory within a Directory container.
E-mail address of the server administrator. This address is, for example, shown on error pages Apache creates. The error log file for this virtual host. Although it is not necessary to create separate error log files for each virtual host, it is common practice to do so, because it makes the debugging of errors much easier. The access log file for this virtual host. Although it is not necessary to create separate access log files for each virtual host, it is common practice to do so, because it allows the separate analysis of access statistics for each host.
As mentioned above, access to the whole file system is forbidden by default for security reasons. Therefore, explicitly unlock the directories in which you have placed the files Apache should serve—for example the DocumentRoot:. In previous versions of Apache, the statement Require all granted was expressed as:. When starting the module for the first time, the HTTP Server Wizard starts, prompting you to make a few basic decisions concerning administration of the server. In the last step of the dialog, you may enter the expert configuration mode to make even more specific settings.
Here, specify the network interfaces and ports Apache uses to listen for incoming requests. You can select any combination of existing network interfaces and their respective IP addresses.
Ports from all three ranges well-known ports, registered ports, and dynamic or private ports that are not reserved by other services can be used. The default setting is to listen on all network interfaces IP addresses on port Keeping the port closed is only useful in test situations where no external access to the Web server is necessary.
If you have multiple network interfaces, click Firewall Details to specify on which interface s the port s should be opened. The Modules configuration option allows for the activation or deactivation of the script languages that the Web server should support. Click Next to advance to the next dialog. This option pertains to the default Web server. The first declared virtual host in the configuration file is commonly called the default host.
Each virtual host inherits the default host's configuration. To edit the host settings also called directives , select the appropriate entry in the table then click Edit. To add new directives, click Add. To delete a directive, select it and click Delete.
Path to the directory from which Apache serves files for this host. Using Alias directives, URLs can be mapped to physical file system locations. This means that a certain path even outside the Document Root in the file system can be accessed via a URL aliasing that path.
With Directory settings, you can enclose a group of configuration options that will only apply to the specified directory. It should not be necessary to change the defaults. With include, additional configuration files can be specified. Two Include directives are already preconfigured: With this directive, all files in this directory ending in. This specifies the default URL used by clients to contact the Web server.
After finishing with the Default Host step, click Next to continue with the configuration. Server Resolution is used to determine how a host is identified name based or IP based. Clicking Next advances to the second part of the virtual host configuration dialog. In part two of the virtual host configuration you can specify whether to enable CGI scripts and which directory to use for these scripts.
It is also possible to enable SSL. If you do so, you must specify the path to the certificate as well. With the Directory Index option, you can specify which file to display when the client requests a directory by default, index. Add one or more file names space-separated to change this. It is not possible to add virtual hosts at will. If using name-based virtual hosts, each host name must be resolved on the network. If using IP-based virtual hosts, you can assign only one host to each IP address available.
This is the final step of the wizard. Here, determine how and when the Apache server is started: Also see a short summary of the configuration made so far. If you are satisfied with your settings, click Finish to complete configuration. To change something, click Back until you have reached the desired dialog.
The HTTP Server Configuration dialog also lets you make even more adjustments to the configuration than the wizard which only runs if you configure your Web server for the first time.
It consists of four tabs described in the following. No configuration option you change here is effective immediately—you always must confirm your changes with Finish to make them effective.
Clicking Abort leaves the configuration module and discards your changes. In Listen on Ports , Add , Edit , or Delete addresses and ports on which the server should be available. The default is to listen on all interfaces on port You should always check Open Port In Firewall , because otherwise the Web server is not reachable from outside. With Log Files , watch either the access log file or the error log file.
This is useful if you want to test your configuration. The log file opens in a separate window from which you can also restart or reload the Web server. These commands are effective immediately and their log messages are also displayed immediately. You can change the status enabled or disabled of Apache2 modules by clicking Toggle Status.
Click Add Module to add a new module that is already installed but not yet listed. These dialogues are identical to the ones already described. You can change this behavior using YaST's Services Manager or with the systemctl command line tool systemctl enable or systemctl disable. To start, stop, or manipulate Apache on a running system, use either the systemctl or the apachectl commands as described below. Stops the Web server by advising all forked Apache processes to first finish their requests before shutting down.
This command allows activating changes in the Apache configuration without causing connection break-offs. Stops the Web server after a defined period of time configured with GracefulShutdownTimeout to ensure that existing requests can be finished.
Checks the syntax of the configuration files without affecting a running Web server. Because this check is forced every time the server is started, reloaded, or restarted, it is usually not necessary to run the test explicitly if a configuration error is found, the Web server is not started, reloaded, or restarted. Dumps a short or full status screen, respectively. If you specify additional flags to the commands, these are passed through to the Web server.
The Apache software is built in a modular fashion: Apache modules can be compiled into the Apache binary at build time or be dynamically loaded at runtime. Base modules are compiled into Apache by default. All others are available as shared objects: In general, modules labeled as extensions are included in the Apache software package, but are usually not compiled into the server statically.
Modules labeled external are not included in the official Apache distribution. MPMs are responsible for accepting and handling requests to the Web server, representing the core of the Web server software.
Among other packages, the results list contains all available external Apache modules. Activate or deactivate particular modules either manually or with YaST.
If you have activated external modules manually, make sure to load their configuration files in all virtual host configurations. All base and extension modules are described in detail in the Apache documentation. Only a brief description of the most important modules is available here.
Refer to http: This module is enabled by default. The authentication modules provide different authentication methods: Autoindex generates directory listings when no index file for example, index. The look and feel of these indexes is configurable. However, directory listings are disabled by default via the Options directive—overwrite this setting in your virtual host configuration. Using this module, Apache can be configured to compress given file types on the fly before delivering them.
It also provides an automatic redirect to the correct URL when a directory request does not contain a trailing slash. Environment variables can be set or unset or passed from the shell that invoked the httpd process. Provides a comprehensive overview of the server configuration under http: For security reasons, you should always limit access to this URL.
By default only localhost is allowed to access this URL. With this module, you can configure the look of the Apache log files. Necessary for content negotiation. Sets environment variables based on details of the client's request, such as the browser string the client sends, or the client's IP address. Enables encrypted connections between Web server and clients.
Provides information on server activity and performance under http: By default, only localhost is allowed to access this URL.
The UserDir directive must be specified in the configuration. Prefork MPM.
Worker MPM. The prefork MPM implements a non-threaded, preforking Web server. It makes the Web server behave similarly to Apache version 1. In this version it isolates each request and handles it by forking a separate child process. Thus problematic requests cannot affect others, avoiding a lockup of the Web server. While providing stability with this process-based approach, the prefork MPM consumes more system resources than its counterpart, the worker MPM.
The worker MPM provides a multi-threaded Web server. The advantage of a thread over a process is its lower resource consumption. Instead of only forking child processes, the worker MPM serves requests by using threads with server processes. The preforked child processes are multi-threaded.
This approach makes Apache perform better by consuming fewer system resources than the prefork MPM. One major disadvantage is the stability of the worker MPM: In the worst case, this may result in a server crash. Especially when using the Common Gateway Interface CGI with Apache under heavy load, internal server errors might occur because of threads being unable to communicate with system resources.
Another argument against using the worker MPM with Apache is that not all available Apache modules are thread-safe and thus cannot be used with the worker MPM. Not all available PHP modules are thread-safe. Find the module's documentation in the listed directory. It also enables HTTP traffic monitoring and real-time analysis. Apache can be extended by advanced users by writing custom modules. To develop modules for Apache or compile third-party modules, the package apache2-devel is required along with the corresponding development tools.
Other options of apxs2 are described in the apxs2 1 man page. CGI scripts can be written in any programming language. Usually, script languages such as PHP are used. Both modules are enabled by default. Allowing the server to execute CGI scripts is a potential security hole. This location is already configured to execute CGI scripts. Tells the server to treat files with the extensions. Adjust according to your needs.
The Require directive controls the default access state. In this case, access is granted to the specified directory without limitation. For more information on authentication and authorization, see http: This header is sent to the client, so it understands what kind of content it receives.
Secondly, the script's output must be something the client, usually a Web browser, understands—HTML usually, or plain text or images, for example. It outputs the content of some environment variables as plain text. Edit the file to have! Files accessible by the Web server should be owned by the user root. Because the Web server runs with a different user, the CGI scripts must be world-executable and world-readable. Change into the CGI directory and use the command chmod test.
Now call http: If you do not see the output of the test program but an error message instead, check the following:.
Application Development with Apache. Nick Kew. Chapter 2 The Apache Platform and Architecture. Chapter 3 The Apache Portable Runtime. Chapter 4 Programming Techniques and Caveats. Chapter 5 Writing a Content Generator. Access Authentication and Authorization.
Chapter 8 Filter Modules. Chapter 10 Extending the API. Chapter 11 The Apache Database Framework. Chapter 12 Module Debugging. Contributor License Agreements. Chapter 9 Configuration for Modules. Chapter 1 Applications Development with Apache.