Introduction to Apache HTTP Server
The most famous and functional web server in Linux is Apache HTTP Server (APACHE ).
Apache HTTP Server is one of the most famous open-source projects of the Apache Software Foundation. It can run on most operating systems.
The main official website versions are 2.2 and 2.4. Centos 6 uses Version 2.2 and centos 7 uses version 2.4.
Most versions 2.2 are deployed in the current production environment, but version 2.4 has many new features. The following is a brief description:
(1) MPM can be dynamically loaded during runtime
In version 2.4, mpm can be programmed into a load-able module. During running, you only need to configure what MPM to use.
(2) event MPM supported
Officially supports event mpm, which was previously tested.
(3) Better asynchronous read/write support
(4) use different log levels in each module and Directory
(5) You can use <if>, <elseif>, and <else> configurations for each request.
(6) Enhanced expression Analyzer
(7) keepalivetimeout can be controlled in milliseconds
(8) The namevirtualhost command is no longer required
(9) User-Defined variables can be used in configuration
(10) Use less memory than Version 2.2
(11) added many new modules, such as mod_proxy_fcgi, mode_ratelimit, mod_request, and mod_remoteip. At the same time, many modules are also enhanced.
(12) changes in access control
2.2 Configuration:
Order deny, allow
Deny from all
2.4 Configuration:
Require all denied
2.2 Configuration:
Order allow, deny
Allow from all
2.4 Configuration:
Require all granted
2.2 Configuration:
Order deny, allow
Deny from all
Allow from example.org
2.4 Configuration:
Require host example.org
As v2.4 introduces so many new features, it is also necessary to install v2.4 in the production environment.
Compile and install
Preparations
Download httpd-2.4.10.tar.bz2 from the official website
The lab environment is centos 6.5. Version 2.2 is installed by default and v2.2 is stopped.
[[Email protected] named] # service httpd stop
[[Email protected] named] # chkconfig httpd off
[[Email protected] named] # chkconfig -- list httpd
Httpd 0: off 1: off 2: off 3: off 4: off 5: off 6: Off
[[Email protected] ~] # Tar xf httpd-2.4.10.tar.bz2
APR Installation
Httpd depends on Apr (Apache Portable Runtime), and version 2.4 depends on a newer version of APR, which must be 1.4 or later. Centos 6 is installed with 1.3.9
Download apr-1.5.1.tar.bz2and apr-util-1.5.3.tar.bz2 from http://apr.apache.org.
[[Email protected] ~] # Tar xf apr-1.5.1.tar.bz2
[[Email protected] ~] # Tar xf apr-util-1.5.3.tar.bz2
[[Email protected] ~] # Cd apr-1.5.1
[[Email protected] apr-1.5.1] #./configure -- prefix =/usr/local/apr15
[[Email protected] apr-1.5.1] # Make & make install
[[Email protected] ~] # Cd ~ Apr-util-1.5.3
[[Email protected] apr-util-1.5.3] #./configure -- prefix =/usr/local/aprutil15 -- With-Apr =/usr/local/apr15/
[[Email protected] apr-util-1.5.3] # Make & make install
Install httpd
Common configure options
| Name |
Description |
Value |
| -- Prefix |
The installation directory of the program. It is installed in/usr/local/apache2 by default. |
/Usr/local/apache24 |
| -- Sysconfdir |
Configuration file directory |
/Etc/httpd24 |
| -- Enable-so |
Enable DSO |
|
| -- Enable-Modules |
List of modules separated by blank characters, which can also be "all" | "most" | "few" | "NONE" | "reallyall" |
Most |
| -- Enable-SSL |
SSL/TLS support (mod_ssl) |
|
| -- Enable-CGI |
CGI supported |
|
| -- Enable-Rewrite |
Server rewrite |
|
| -- With-PCRE |
Use the PCRE Library |
|
| -- With-Apr |
Specify the APR path |
/Usr/local/apr15/ |
| -- With-Apr-util |
Specify the APR-util path |
/Usr/local/aprutil15/ |
| -- With-z |
Use zlib library |
|
| -- Enable-MPMs-shared |
The MPM module dynamically loads the list separated by blank characters, which can be all |
All |
| -- With-MPM = mpm |
Default processing model used by Apache, mpm = {event | worker | prefork | winnt} |
Event |
[[Email protected] ~] # Cd httpd-2.4.10
[[Email protected] httpd-2.4.10] #. /configure -- prefix =/usr/local/apache24 -- sysconfdir =/etc/httpd24 -- enable-so -- enable-SSL -- enable-CGI -- enable-Rewrite -- With-z -- -PCRE -- With-Apr =/usr/local/apr15/-- With-Apr-util =/usr/local/aprutil15/-- enable-MPMs-shared = all -- With-mpm = event -- enable-modules = most
[[Email protected] httpd-2.4.10] # Make & make install
Installation directory and file description
| /Etc/httpd24 |
Configure the main directory |
| /Etc/httpd24/extra |
Additional configuration directory |
| /Etc/httpd24/httpd. conf |
Main configuration file |
| /Usr/local/apache24/htdocs |
Site root directory |
| /Usr/local/apache24/Error |
Preset error document directory |
| /Usr/local/apache24/cgi-bin |
CGI directory |
| /Usr/local/apache24/include |
Header file directory for secondary development, which can be exported if necessary |
| /Usr/local/apache24/man |
Help manual, export required |
| /Usr/local/apache24/modules |
DSO Module Directory |
| /Usr/local/apache24/bin |
Executable File directory |
| /Usr/local/apache24/logs |
Log directory |
Export bin directory
[[Email protected] ~] # Cd/etc/profile. d/
[[Email protected] profile. d] # Vim httpd24.sh
Path =/usr/local/apache24/bin: $ path
Export path
Then restart the connection session.
Export man directory
Add one in/etc/man. config
Manpath/usr/local/apache24/man
To take effect
Export the header file directory
[[Email protected]/] # ln-S/usr/local/apache24/include // usr/include/Apache
Apachectl
Apachectl is a shell script in/usr/local/apache24/bin. It can be used to control the startup, shutdown, restart, elegant restart, and elegant shutdown of httpd.
The so-called elegance means that the connection will not be terminated immediately if there is a connection before it is restarted or closed.
Start the first time
[[Email protected] ~] # Apachectl start
[[Email protected] ~] # SS-tnlp | grep: 80
Listen 0 128: 80: * Users :( ("httpd", 2308, 4), ("httpd", 2309,4), ("httpd", 2310,4 ), ("httpd", 2311,4 ))
[[Email protected] ~] # Httpd-D dump_modules
Loaded modules:
Core_module (static)
So_module (static)
Http_module (static)
Authn_file_module (shared)
Authn_core_module (shared)
Authz_host_module (shared)
Authz_groupfile_module (shared)
Authz_user_module (shared)
Authz_core_module (shared)
Access_compat_module (shared)
Auth_basic_module (shared)
Reqtimeout_module (shared)
Filter_module (shared)
Mime_module (shared)
Log_config_module (shared)
Env_module (shared)
Headers_module (shared)
Setenvif_module (shared)
Version_module (shared)
Mpm_event_module (shared)
Unixd_module (shared)
Status_module (shared)
Autoindex_module (shared)
Dir_module (shared)
Alias_module (shared)
Test the browser.
650) This. width = 650; "Title =" image "style =" border-top: 0px; border-Right: 0px; border-bottom: 0px; border-left: 0px; display: inline "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201408/10/6716920_1407678526xQNw.png "" 660 "Height =" 380 "/>
Lab
Virtual Host
Server-status
User-Based Access Control
HTTPS
To be continued ......