Compile and install Apache httpd 2.4 in Linux

Source: Internet
Author: User

Compile and install Apache httpd 2.4 in Linux

Apache is the world's No. 1 Web server software. It can run on almost all widely used computer platforms. Because of its wide use of cross-platform and security, it is one of the most popular Web server software. The current Apache version is 2.4. This document describes how to install Apache httpd in the source code based on CentOS 6.5.

I. Advantages of compilation and Installation
The compilation and installation of source code is generally composed of three steps: configuration (configure), usually dependent on the gcc compiler, binutils, glibc. Configure software features, check the compilation environment, and generate Makefile compilation (make install). Advantages: custom software features optimize compilation parameters, improve Performance solve unnecessary dependencies between software easy to clean up and uninstall configure is an executable script, it has many options, in the source code path to be installed using the command. /configure -- help outputs a detailed list of options. Common options -- prefix: This option is used to configure the installation path. If this option is not configured, the executable file after installation is put in/usr/local/bin by default, by default, the library files are stored in/usr/local/lib, the configuration files are stored in/usr/local/etc by default, and other resource files are stored in/usr/local/share. If you configure -- prefix, for example :. /configure -- prefix =/usr/local/test can put all the resource files in the path of/usr/local/test without clutter. Another benefit of using the-prefix option is to uninstall or port the software. When a software installation is no longer needed, you only need to delete the installation directory to clean the software; to transplant software, you only need to copy the entire directory to another machine (the same operating system ). Of course, to uninstall the program, you can also use make uninstall in the original make directory, provided that the make file has specified uninstall.
Ii. httpd version
Version: httpd-1.3 httpd-2.0 httpd-2.2 httpd-2.4
Iii. New Features of httpd 2.4
1) MPM supports run-time loading -- enable-mpms-shared = all -- with-mpm = prefork | worker | event2) supports event MPM3) asynchronous read/write support 4) support different log levels for each module and directory 5) support per-request (that is, support
 
  
,
  
   
, And
   
    
Conditional judgment) (6) Enhanced expression analyzer; (7) Support for keepalive timeout in milliseconds; (8) NameVirtualHost is no longer required for virtual hosts Based on FQDN (Domain Name); (9) user-Defined variables are supported. Some modules are added: mod_proxy_fcgi, mod_ratelimit, mod_request, and mod_remoteip. Some configuration mechanisms are modified: order, allow, and deny are no longer supported to implement IP-based access control;
   
  
 
Iv. Compile and install httpd 2.4
1. Dependency httpd depends on apr. apr-util apr is called apache portable runtime, can realize httpd cross-platform run httpd-2.4 according to 1.4 + and above 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 installation # yum install gcc # yum install pcre-devel # tar xf apr-1.5.0.tar.bz2 # cd apr-1.5.0 #. /configure -- prefix =/usr/local/apr (-- prefix specifies the directory where apr is installed) # 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 The following are several major configuration items -- sysconfdir =/etc/ httpd24 specifies the configuration file path -- enable-so startup module dynamic installation and uninstallation -- enable-ssl compilation ssl module -- enable-cgi supports cgi mechanism (allows the static web server to parse a dynamic request) protocol) -- enable-rewrite supports url rewriting -- Author: Leshami -- with-zlib supports data packet Compression -- Blog: http://blog.csdn.net/leshami -- with-pcre supports regular expressions -- with-apr =/usr/local/apr specifies the directory of the dependent apr -- with-apr-util =/usr/local/apr-util /Specify the directory of the dependent apr-util -- enable-modules = most enabled module -- enable-mpms-shared = all modules compiled in shared mode -- with-mpm = prefork specify httpd works in the 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/httpd24 \ -- enable-so \ -- enable-ssl \ -- enable-cgi \ -- enable-rewrite \ -- with-zlib \ -- with-pcre \-- with-mpm = prefork \ -- enable-modules = most \ -- enable-mpms-shared = all # make install
5. Configure http2.4 to start and stop
1. Modify the port number to make it different from Version 2.2. You can run it at the same time. The modification is as follows # cat/etc/httpd24/httpd. conf | grep Listen | grep-v ^ # Listen 80802, start and stop #/usr/local/apache/bin/apachectl start # netstat-nltp | grep 80 tcp 0 ::: 8080: * LISTEN 17365/httpd #/usr/local/apache/bin/apachectl status Not Found The requested URL/server-status was not found on this server. by modifying httpd. conf, add the following configuration # grep server-stat/etc/httpd24/httpd. conf-A5  SetHandler server-status # Order deny, allow # Deny from all Allow from 192.168.21.157 192.168.21.10 #/Usr/local/apache/bin/apachectl restart #/usr/local/apache/bin/apachectl status Apache Server Status for localhost (via 127.0.0.1) Server Version: apache/2.4.9 (Unix) Server MPM: prefork .......... #/usr/local/apache/bin/apachectl stop3. to configure the self-starting file, you can copy the Startup File of Version 2.2 and modify the relevant path to run version 2.4 as a separate service, note that the pid File Location of the Startup file should be configured to be consistent with the pid location shown in/usr/local/apache/bin/apachectl-V to view the pid location #/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 26, 27c26, 27 <if [-f/etc/sysconfig/httpd]; then <. /etc/sysconfig/httpd ---> if [-f/etc/httpd24]; then>. /etc/httpd24 42, 46c42, 46 <apachectl =/usr/sbin/apachectl 
Vi. Configure man Manual
 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 # curl http://192.168.21.10:8080 
It works!

This is a apached 2.4.9 version

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.