Uninstall the httpd provided by centos and upgrade it to the latest version 2.4.10.

Source: Internet
Author: User
Tags apache log
Notes on centos compilation and installation of Apache 2.4.6
  • Author per pixel
  • Font Size
 

The Apache version of the server was 2.2.x before. In view of the inertia of the centos update software, I think Apache 2.4 may not necessarily appear in centos until 2014. I am not going to wait, compile and install it.

Upgrading to 2.4 from 2.2. Simply put, Apache cannot be started if the previous 2.2.x configuration is used.

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 the official website:

wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.6.tar.gzwget http://mirror.esocc.com/apache//apr/apr-1.4.8.tar.gzwget http://mirror.esocc.com/apache//apr/apr-util-1.5.2.tar.gz

Decompress:

tar -xvf httpd-2.4.6.tar.gztar -xvf apr-1.4.8.tar.gztar -xvf apr-util-1.5.2.tar.gz

One-point file operation:

mv apr-1.4.8 httpd-2.4.6/srclib/aprmv apr-util-1.5.2 httpd-2.4.6/srclib/apr-utilcd httpd-2.4.4

Compile command:

./configure --with-included-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, or simply-- Enable-MPMs-shared = all. In this way, the event, worker, and prefork will be installed in modular mode, and the configuration of which to use will be completed in httpd. conf.

After compilation:

makemake 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/modules authz_core_module modules/modules userdir_module modules/mod_userdir.soloadmodule dir_module modules/mod_dir.soloadmodule 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. do not enable them: loadmodule filter_module modules/mod_filter.soloadmodule deflate_module modules/mod_deflate.soloadmodule 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 the httpd-default.conf for timeout, keepalive
Configuration of Apache MPM httpd-mpm.conf this is very important, performance optimization basically depends on this file
Configure the httpd-userdir.conf for the website directory
Configure the httpd-vhosts.conf for the VM

After you confirm all the configurations, you can delete the previous Apache on the server. At least I did this ...:

service httpd stopyum 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 httpdchkconfig httpd on

In the last step, start the compiled Apache 2.4.6:

service httpd start

Done.

Apache is done, but PHP 5.5 installed through the Remi-test source Yum cannot be used, because it depends on the httpd package and is uninstalled together to compile PHP, next.

Simple AB tests the performance differences between Apache 2.2 and Apache 2.4:

  • Static content, 2.4 wins;
  • Dynamic Content, there is no big difference between Apache 2.4 and 2.2...

Uninstall the httpd provided by centos and upgrade it to the latest version 2.4.10.

Related Article

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.