Compile and install Apache 2.4.7 on CentOS

Source: Internet
Author: User
Tags apache log

Compile and install Apache 2.4.7 on CentOS

Learn about the Linux server and compile the latest Apache 2.4.7 server. The server is CentOS.

Prepare for Centos compilation and installation of Apache 2.4:
Yum groupinstall "Development tools"

Previously, the server was installed with Apache by yum install httpd, so some dependencies may be solved. During the compilation and installation process, only two extra devel packages, yum, were required:
Yum install zlib-devel pcre-devel

Download from official website:/usr/local/src/
Wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.7.tar.gz
Wget http://apache.dataguru.cn/apr/apr-1.5.0.tar.gz
Wget http://apache.dataguru.cn/apr/apr-util-1.5.3.tar.gz

Decompress:
Tar-xvf httpd-2.4.7.tar.gz
Tar-xvf apr-1.5.0.tar.gz
Tar-xvf apr-util-1.5.3.tar.gz

One-point file operation:
Music apr-1.5.0 httpd-2.4.7/srclib/apr
Mv apr-util-1.5.3 httpd-2.4.6/srclib/apr-util
Cd httpd-2.4.7


Compile command:
./Configure -- with-Permission ded-apr -- enable-nonportable-atomics = yes -- with-z

Surprisingly simple, because the default -- enable-mod-shared = most, modular installation, and then go to httpd. the conf file determines whether to enable the module. Therefore, the enable-deflate -- enable-rewrite -- enable-blablabla and so on are completely unnecessary.

Event mpm is installed by default. If worker is used, -- with-mpm = worker is required, or -- enable-mpms-shared = all, in this way, the event, worker, and prefork will be installed in a modular manner. configuration in conf.

After compilation:
Make
Make install

After the installation is complete, everything is in the/usr/local/apache2 directory. The most important thing is conf/httpd. conf. configure it on your own.

On the load module, I tried to streamline it as much as possible and only enabled the following:
Required:
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so

Set timeout:
LoadModule reqtimeout_module modules/mod_reqtimeout.so

The following three functions are enabled in combination with Google mod_pagespeed:
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

Apache log:
LoadModule log_config_module modules/mod_log_config.so

Specify Apache users and groups:
LoadModule unixd_module modules/mod_unixd.so

To use phpMyAdmin:
LoadModule alias_module modules/mod_alias.so

Wordpress and joomla should use:
LoadModule rewrite_module modules/mod_rewrite.so

There are also many configuration files under/usr/local/apache2/conf/extra. in httpd. conf, you can choose whether to load them. The parts I load include:
Configure timeout and keepalive
Httpd-default.conf

Configure the apache mpm
Httpd-mpm.conf
This is very important. This file is basically used for performance optimization.

Configure
Httpd-userdir.conf

Configure
Httpd-vhosts.conf

After you confirm all the configurations, you can delete the previous apache on the server. At least I did this ...:
Service httpd stop
Yum remove httpd

Copy the newly compiled and installed Apache 2.4.6 in place:
Cp/usr/local/apache2/bin/apachectl/etc/init. d/httpd

Edit the/etc/init. d/httpd file in the first line #! Add two rows under/bin/sh:
# Chkconfig: 35 85 15
# Description: Activates/Deactivates Apache 2.4.6

Add Apache to boot and start automatically:
Chkconfig -- add httpd
Chkconfig httpd on

In the last step, start the compiled Apache 2.4.7:
Service httpd start

If you want to access from the Internet, you also need to set a firewall. Otherwise, the Internet cannot be accessed. By default, linux only enables port 22, so port 80 must be enabled:

Vi/etc/sysconfig/iptables
# Here is the firewall settings. Add the following line of code under port 22. To enable port 8080, you only need to change port 80 to port 8080.
-A input-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT

After the editor is complete, you only need to restart the firewall. The command is:

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)

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

Apache details: click here
Apache: click here

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.