|
|
楼主 |
发表于 2013-5-19 09:56:02
|
显示全部楼层
本帖最后由 demo 于 2013-5-20 02:18 编辑
Install Apache Modules
One of Apache's prime strengths is its extreme customiz ability and flexibility. With its support for a large number of modules,there are few web serving tasks that Apache cannot fulfill.
By default,modules and their configuration files are installed in the/etc/apache2/mods-available/ directory. Generating a list of this directory will tell you what modules are installed. To enable a module listed in this directory, use the following command:Note that in the /etc/apache2/mods-available/ directory, files have a.load and .conf extension. Module names do not include the extension.
To disable a module that is currently enabled, use the inverse command:To get a list of available Apache modules modules in the Ubuntu repository use the following command:- apt-cache search libapache2*
复制代码 To install one of these modules use the command:- apt-get install [module-name]
复制代码 Modules should be enabled and ready to use following installation, thoughyou may have to apply additional configuration options to have accessto the modules' functionality. Consult theApache module documentationfor more information regarding the configuration of specific modules.
Configuration Options
One of the strengths, and obstacles, of Apache is the immense amount offlexibility offered in its configuration files. In the defaultinstallation of Apache 2 on Ubuntu, the main configuration islocated in the /etc/apache2/apache2.conf files, but Apacheconfiguration directives are loaded from files in a number of differentlocations, in a specific order. Configuration files are read in thefollowing order, with items specified later taking precedence overearlier and potentially conflicting options:
/etc/apache2/apache2.conf
Files with .load or .conf extensions in/etc/apache2/mods-enabled/ directory.
/etc/apache2/httpd.conf (Blank by default.)
/etc/apache2/ports.conf
Files within the /etc/apache2/conf.d/ directory.
Files within the /etc/apache2/sites-enabled/ directory.
Per-directory .htaccess files in the directory.
Remember, later files take precedence over earlier-cited files. Withina directory of included configuration files, files will be read inorder based on the sort of their file names.
Apache will follow symbolic links to read configuration files, soyou can create links in these directories and locations to files thatare actually located elsewhere in your file system.
Best practices for most installations dictate that we don't recommendmodifying the following default configuration files:/etc/apache2/httpd.conf, files in /etc/apache2/mods-enabled/,and in most cases /etc/apache2/apache2.conf. This is to avoidunnecessary confusion and unintended conflicts in the future.
Generally, as specified in our LAMP guidesand elsewhere, files that configure virtual hosts should be located in the/etc/apache2/sites-available/ directory (and symbolically linked tosites-enabled/ with the a2ensite tool. This allows for a clearand specific per-site configuration.
In practice, the vast majority of configuration options will probablybe located in site-specific virtual host configuration files.If you need to set a system-wide configuration option or aren't using virtualhosting, the best practice is to specify options in files createdbeneath the conf.d/ directory.
Multi-Processing Module
The default Apache configuration uses a tool called MPM-worker, this multi-processingmodule can handle a large number of requests quickly by utilizing multiple threads perworker process. However, this use of multiple threads is not compatible with some PHPextensions. When PHP is installed MPM-worker is replaced with MPM-prefork, which allowsApache to handle requests without threading for greater compatibility with some software.Furthermore, using MPM-prefork allows Apache to isolate requests in separate processesso that if one request fails for some reason, other requests will be unaffected.
For more complex setups, however, we recommend that you consider usingan alternate MPM module called "ITK." mpm-itk is quite similar toprefork, but it goes one step further and runs the processes for each siteunder a distinct user account. This is particularly useful insituations where you're hosting a number of distinct sites that youneed to isolate sites on the basis of user privileges.
Begin by installing the mpm-itk module:- apt-get install apache2-mpm-itk
复制代码 Now, in the <VirtualHost > entries for your sites (thesite-specific files in /etc/apache2/sites-available/) add the followingsub-block:
File excerpt:Apache Virtual Host Configuration
- <IfModule mpm_itk_module>
- AssignUserId webeditor webgroup
- </IfModule>
复制代码 In this example, webeditor is the name of the user of the specific site inquestion, and webgroup is the name of the particular group that"owns" the web server related files and processes. Remember that youmust create the user accounts and groups using the useraddcommand.
More Information
You may wish to consult the following resources for additionalinformation on this topic. While these are provided in the hope that they willbe useful, please note that we cannot vouch for the accuracy or timeliness ofexternally hosted materials.
|
|