Compile and install httpd2.4

Source: Internet
Author: User

When using the RPM package to install httpd, if the features provided by the RPM package do not meet our requirements, or the RPM package of the old version has a vulnerability, You need to manually compile and install httpd. Take version 2.4 as an example, describes the compilation and Installation Process of httpd2.4.


I. Preparations before installation:

# Yum groupinstall "development tools"

# Yum groupinstall "server platform development"

The preceding two development packages depend on the compilation and installation of many applications, so they must be installed in advance.

# Yum install mod_ssl; If httpd supports the SSL function, you need to install the mod_ssl module.

# Yum install PCRE-devel; To implement URL rewriting, install the PCRE-devel package.

The httpd program depends on two packages: Apr and APR-util. Apr refers to the Portable Runtime Environment of Apache, which is similar to the virtual machine required for running Apache. different platforms require different APR versions, different httpd versions also use different APR versions. The default APR version installed on centos Linux is 1.3.9, the httpd2.4 version depends on Apr version 1.4 or above. Therefore, you must install the new version of APR and APR-util in advance.

Take the latest version of apr1.5.1 as an example to compile and install APR:

# Tar xf apr-1.5.1.tar.bz2

# Cd apr-1.5.1

#./Configure -- prefix =/usr/local/apr-1.5.1; to be installed in the new path, do not override the older version of APR

# Make & make install

To compile the version of the installation apr-util-1.5.3, follow these steps:

# Tar xf apr-util-1.5.3.tar.bz2

# Cd apr-util-1.5.3

#./Configure -- prefix =/usr/local/apr-1.5.3 -- With-Apr =/usr/local/apr-1.5.1

Compile and install httpd-2.4.10

# Tar xf httpd-2.4.10.tar.bz2

# Cd httpd-2.4.10

#. /Configure -- prefix =/usr/local/Apache -- sysconfdir =/etc/httpd24 -- enable-so -- enable-SSL -- enable-CGI -- enable-Rewrite -- With-zlib -- -PCRE -- With-Apr =/usr/local/apr1.5.1/-- With-Apr-util =/usr/local/apr-util-1.5.3/-- enable-MPMs-shared = all -- With-mpm = event -- enable-modules = most

# Make & make install

After the installation is complete, add the executable program path in the/usr/local/Apache/bin directory to the path environment variable:

# Vim/etc/profile. d/httpd24.sh

Export Path =/usr/local/Apache/bin: $ path; add this line in the httpd24.sh File

# Source/etc/profile. d/httpd24.sh

Export help document:

# Vim/etc/man. config

Manpath/usr/local/Apache/docs; add this line in the man. config file

Start the service. Before starting the new HTTPd service, you need to check whether the old version of the HTTPd service has been started. If it has been started, stop the service and start it again:

# Apachectl

Effect after startup

650) This. length = 650; "src =" http://s3.51cto.com/wyfs02/M02/45/8E/wKioL1PoulCDtQQeAACLYLgqewI814.jpg "Title =" 2014-08-11 13_31_55-172.16.103.2.jpg "alt =" break "/> In the httpd-2.2 version, switching the MPM module of the httpd appliance is modified in the script configuration file of the program, however, 2.4 provides the dynamic loading function. You can directly modify the loadmodule option of the device in the configuration file and enable the corresponding configuration file of the module. 650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/8E/wKioL1PouymiCzjsAAEZ0oNttnU988.jpg "Title =" 2014-08-11 14_36_09-root @ sueking _ etc_httpd24-xshell 4.jpg" alt = "weight"/> 650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/8D/wKiom1Pouhmxxk85AABmULcPIvc001.jpg "Title =" 2014-08-11 14_30_36-root @ sueking _ etc_httpd24-xshell 4.jpg" alt = "wkiom1pouhmxxk85aabmulcpivc001.jpg"/>


Use of httpd-2.4 version:

IP-based Access Control:

Allow access from all hosts: require all granted

Deny Access to All Hosts: require all deny

To control access to a specific Host:

Require IP ipaddr

Require not IP ipaddr

If an IP address cannot be accessed, You need to define the IP address in <requireall>... </requireall>.

You can use a CIDR block or a separate IP address to use ipaddr. CIDR blocks can be used in the following ways:

192.168.1.0/24 or Ctrip 192.168.1.

Access Control Based on Host Name:

Require host hostname

Require not host hostname

To use the name-based VM function, first comment out the DocumentRoot line of the central host and enable the virtual hosts function:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/45/90/wKioL1PowVmTwcXGAACdtzXRmXY392.jpg "Title =" 2014-08-11 21_07_12-root @ sueking _~ -Xshell 4.jpg" alt = "wkiol1powvmtwcxgaacdtzxrmxy392.jpg"/> then edit the VM definition in the/etc/httpd24/extra/httpd-vhosts.conf file:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/45/90/wKiom1PowxrQTJWEAAE_mERJJDg092.jpg "Title =" 2014-08-11 21_19_29-root @ sueking _~ -Xshell 4.jpg" alt = "wkiom1powxrqtjweaae_merjjdg092.jpg"/> after you specify DocumentRoot in the virtual host definition, you must provide the access permission for this directory to define the file that allows access to the root directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.