Compile and install Apache and modules in Linux, and use linuxapache
Apache is one of the most popular Web server software. It supports multiple platforms, allows you to quickly build web Services, and is stable and reliable. It can be expanded through simple APIs, you can integrate PHP, Python, and other language interpreters. This article explains how to compile Apache in linux and how to compile the Apache module.
Compile Apache in linux to download the Apache source code. The compilation process is as follows:
$ Wget http://apache.fayea.com//httpd/httpd-2.4.12.tar.gz$ tar-zxf httpd-2.4.12.tar.gz $ cd httpd-2.4.12 $./Configure -- prefix =/usr/local/apache/$ make & make install |
The following error may occur during compilation:
$. /Configure -- prefix =/usr/local/apache/checking for chosen layout... apachechecking for working mkdir-p... yeschecking for grep that handles long lines and-e... /bin/grepchecking for egrep... /bin/grep-Echecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuconfigure: configure: logging ing Apache Portable Runtime library... configure: checking for APR... noconfigure: error: APR not found. please read the documentation. |
This is because Apache compilation depends on apr, and it cannot be installed normally without finding apr. In addition, Apache depends on apr-util and pcre.
Compiling Apache depends on APR, which is a Portable Runtime Library of Apache. It encapsulates all operating system calls to implement the use of operating system resources by Apache internal components and improve Apache portability. APR and Apache are separated to avoid different processing for different platforms during Apache development. Apr-util is equivalent to the APR tool set. PCRE is a regular perl library.
Compile and install APR
$ Wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz$ tar-zxf apr-1.5.2.tar.gz $ cd apr-1.5.2 $./configure -- prefix =/usr/local/apr $ make & make install |
Compile and install apr-util
$ Wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz$ tar-zxf apr-util-1.5.3.tar.gz $ cd apr-util-1.5.3 $. /configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr $ make & make install |
Compile and install pcre
$ Wget tar-zxf pcre-8.37.tar.gz $ cd pcre-8.37 $./configure -- prefix =/usr/local/pcre $ make & make install |
Recompile ApacheAfter installing Apache dependencies, add several more parameters during compilation to re-compile Apache
$. /Configure -- prefix =/usr/local/apache/\ -- with-apr =/usr/local/apr \ -- with-apr-util =/usr/local/apr-util \ -- with-pcre =/usr/local/pcre $ make & make install |
The following describes how to compile the Apache module by taking mod_concatx as an example. Mod_concatx is an apache module that can be used to merge multiple js/css files, effectively improving js/css loading speed.
Compile the mod_concatx Module
$ Wget javasln-s/usr/local/apache/bin/apxs/usr/local/bin/apxs $ apxs-c mod_concatx.c |
Compile and install the mod_concatx Module
This compilation method will automatically install the Apache module. After the installation is successful, you can find mod_concatx.so in the directory of the Apache module, and the mod_concatx module information will be added to the conf/httpd. conf configuration.
Start Apache
$/Usr/local/apache/bin/httpd-k start |
Note: After Apache is started, services will run in the future. To disable Apache, run the following command:
$/Usr/local/apache/bin/httpd-k stop |
View the loaded Apache module
$/Usr/local/apache/bin/httpd-M Loaded Modules: Core_module (static) So_module (static) Http_module (static) Mpm_event_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) Unixd_module (shared) Status_module (shared) Autoindex_module (shared) Dir_module (shared) Alias_module (shared) Concatx_module (shared) |
It indicates that mod_concatx has been loaded!
Reference: http://blog.csdn.net/mycwq/article/details/46426261