Compile and install Apache and modules in Linux
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
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
$ Httpd-2.4.12 cd
$./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.
Compile Apache Dependencies
APR 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 the portability of Apache. 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
$ Apr-1.5.2 cd
$./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
$ Apr-util-1.5.3 cd
$./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr
$ Make & make install
Compile and install pcre
$ Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
$ Tar-zxf pcre-8.37.tar.gz
$ Pcre-8.37 cd
$./Configure -- prefix =/usr/local/pcre
$ Make & make install
Recompile Apache
After 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
Compile the Apache module
The following uses mod_concatx as an example to describe how to compile the Apache module. The procedure is simple. 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 http://apmod.googlecode.com/svn/trunk/mod_concatx/mod_concatx.c
$ Ln-s/usr/local/apache/bin/apxs/usr/local/bin/apxs
$ Apxs-c mod_concatx.c
Compile and install the mod_concatx Module
$ Apxs-iac mod_concatx.c
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!
Solution to Apache failure
1. Port 80 is occupied
$ Netstat-anp | grep: 80
Find the Pid used by the port and kill it.
2. the firewall disables port 80 by default.
$ Vi/etc/sysconfig/iptables
Add one or more records
-A RH-Firewall-1-INPUT-p tcp-m state -- state NEW-m tcp -- dport 80-j ACCEPT
After saving, restart the firewall.
$ Service iptables restart
Install a Web Server on Ubuntu Server 14.04 (Linux + Apache + MySQL + PHP)
Install and configure the PHP environment in Linux (Apache2)
How to enable Apache Rewrite in Ubuntu
Key points after upgrading Apache 14.04 to 2.2 in Ubuntu 2.4
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment
Apache details: click here
Apache: click here
This article permanently updates the link address: