Linux under Compile and install Apache HTTPD 2.4

Source: Internet
Author: User

Apache is the world's most used Web server software. It can run on almost all widely used computer platforms and is one of the most popular Web server-side software due to its widespread use across platforms and security. The current Apache version is 2.4, this article mainly describes the installation of Apache httpd based on the CentOS 6.5 source method.

First, the advantages of compiling and installing
源码的编译安装一般由3个步骤组成:    配置(configure),通常依赖gcc编译器,binutils,glibc。配置软件特性,检查编译环境,生成 Makefile文件    编译(make)    安装(make install)优势    自定义软件功能    优化编译参数,提高性能    解决不必要的软件间依赖    方便清理与卸载configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –-help输出详细的选项列表。常用的选项--prefix    该选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,    库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share    如果配置--prefix,如: ./configure --prefix=/usr/local/test    则可以把所有资源文件放在/usr/local/test的路径中,不会杂乱。    用了—prefix选项的另一个好处是卸载软件或移植软件。    当某个安装的软件不再需要时,只须简单的删除该安装目录,就可以把软件卸载得干干净净;    移植软件只需拷贝整个目录到另外一个机器即可(相同的操作系统)。    当然要卸载程序,也可以在原来的make目录下用一次make uninstall,但前提是make文件指定过uninstall。
Second, the httpd version
版本:    httpd-1.3    httpd-2.0    httpd-2.2    httpd-2.4
Iii. new features of httpd 2.4
1) MPM支持运行时装载    
Iv. compiling and installing HTTPD 2.4
1, dependent relationship httpd dependent on Apr, Apr-util Apr all called Apache Portable runtime, can realize httpd cross-platform operation httpd-2.4 dependent on 1.4+ and the above version of Apr apr-          1.5.0.TAR.BZ2 apr-util-1.5.3.tar.bz2 httpd-2.4.9.tar.bz2 pcre-devel package Openssl-devel2, compile and install # yum Install gcc # yum install pcre-devel # tar XF apr-1.5.0.tar.bz2 # cd apr-1.5.0 #./configure--prefi X=/USR/LOCAL/APR (--prefix specified Apr installed directory) # make # make install # tar XF apr-util-1.5.3.tar.bz2 # CD APR-UTIL-1 .5.3 #./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr # tar XF httpd-2.4.9.tar.bz2 below are a few main The configuration item you want--sysconfdir=/etc/httpd24 specifying the configuration file path--enable-so Start-up module dynamic loading and unloading--enable-ssl compiling the SSL module--ENABLE-CGI supports CGI mechanisms (a protocol that enables a static Web server to parse dynamic requests)--enable-rewrite Support URL rewrite--Author : leshami --with-zlib Support Packet Compression--Blog: http://blog.csdn.net/leshami    --with-pcre support for regular expressions--with-apr=/usr/local/apr indicates the directory where the dependent Apr resides --with-apr-util=/usr/local/apr-util/ indicates the directory where the dependent apr-util resides--enable-modules=most enabled Modules--enable-mpms-shared=all modules compiled in a shared manner--with-mpm=prefork indicates that httpd works as Prefork# CD httpd-2.4.9 #./configure--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --prefix=/usr/local/apache --sysconfdir=/etc/httpd--enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with-pcre--with-mpm=prefork--enable-modules=most--enable-mpms-shared=all# make # Make Install
V. Configuration http2.4 start and stop
1, modify the port number to modify the port number so that2.2The version uses different ports and can be run at the same time, modified as follows# cat/etc/httpd24/httpd.conf |grep Listen |grep-v ^#Listen80802, Start and stop#/usr/local/apache/bin/apachectl Start    # Netstat-nltp|grepTcp0      0:::8080:::* LISTEN17365/httpd#/USR/LOCAL/APACHE/BIN/APACHECTL StatusNot Found the requested Url/server-status was notFound onThis server. By modifying the httpd.conf, add the following configuration# grep Server-stat/etc/httpd24/httpd.conf-a5<Location/server-status> SetHandler Server-status# Order Deny,allow        # Deny from allAllow from 192.168.. 157 192.168.. Ten</Location>#/usr/local/apache/bin/apachectl Restart    #/USR/LOCAL/APACHE/BIN/APACHECTL StatusApache Server Status forlocalhost (via127.0. 0. 1) Server version:apache/2.4. 9(Unix) Server mpm:prefork .....#/usr/local/apache/bin/apachectl Stop3, the configuration self-boot file can be copied by2.2Version of the boot file, modifying the associated path will2.4Version as a standalone service, such as bet startup file pid file location to be configured with/usr/Local/APACHE/BIN/APACHECTL-V See PID position consistent view PID position#/usr/local/apache/bin/apachectl-v|grep PID-D default_pidlog="Logs/httpd.pid"        # cp/etc/init.d/httpd/etc/init.d/httpd24        # vi/etc/init.d/httpd24        # diff/etc/init.d/httpd/etc/init.d/httpd24             -, -C26, -<if[-F/ETC/SYSCONFIG/HTTPD]; Then<. /etc/sysconfig/httpd--->if[-F/ETC/HTTPD24]; Then>. /etc/httpd24 the, $C42, $< Apachectl=/usr/sbin/apachectl < HTTPD=${HTTPD-/USR/SBIN/HTTPD} < PROG=HTTPD &L T pidfile=${pidfile-/var/Run/httpd/httpd.pid} < LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD}---> apachectl=/usr/Local/apache/bin/apachectl > httpd=${httpd-/usr/Local/APACHE/BIN/HTTPD} > Prog=httpd24 > pidfile=${pidfile-/usr/Local/apache/logs/httpd.pid} > lockfile=${lockfile-/var/lock/subsys/httpd24}# service HTTPD24 startStarting httpd24: [OK]# service HTTPD24 statusHTTPD (PID15641) is Running...# Netstat-nltp|grepTcp0      0::: the:::* LISTEN15677/httpd# # #2. version httpd 2Tcp0      0:::8080:::* LISTEN15641/httpd# # #2. version httpd 4Service scripts can be generated by copying the Apachectl file# cp/usr/local/apache/bin/apachectl/etc/init.d/httpd249        # service httpd249 start        # service httpd249 statusElinks:connection refused# # #该方式无法查看到状态[[email protected] bin]# Netstat-nltp|grepTcp0      0:::8080:::* LISTEN15999/HTTPD finally add the configuration file to the service, the following is HTTP24 as an example# chkconfig--add httpd24        # chkconfig Httpd24 on
Vi. Configuring the Man Handbook
    vi /etc/man.config    MANPATH /usr/local/apache/man
Vii. Verification
# echo "This is a apached 2.4.9 version">>/usr/local/apache/htdocs/index.html    <html><body><h1>It works!</h1></body></html> This is a apached 2.4.9 version

Linux under Compile and install Apache HTTPD 2.4

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.