1 overview
Currently CENTOS7 default installation is HTTPD2.4, but CENTOS6 on the default is installed HTTPD2.2,CENTOS6 if you want to install HTTPD2.4, you need to compile the installation implementation, in general, centOS7 by default is installed httpd2.4, Unless you are compiling a special module yourself, it is recommended to see a service pack that installs httpd2.4 with Yum.
Compile and install HTTPD2.4 need to involve APR, this article will introduce the APR basic concept, and introduce two methods of compiling HTTPD2.4 on CENTOS6, as well as compiling and installing on Centos7 HTTPD2.4
2 Apr Concept
Apache Project, Apache supports cross-platform, but Windows and Linux have different system invocation mechanisms
Apr will deal with the problem between different systems, the application developer is facing the APR interface, not the operating system interface development
APR is for Apache project software.
. APR (Apache Portable Run-time
The Libraries,apache Portable runtime provides an underlying support interface library for upper-level applications that can be used across multiple operating system platforms. In earlier versions of Apache, the application itself must be able to handle the details of a variety of specific operating system platforms and PIN
Invoke different handler functions on different platforms
With the further development of Apache, the Apache organization decided to separate and evolve these generic functions into a new project. In this way, the development of APR is isolated from Apache, and Apache uses only Apr. Currently APR is mainly used by Apache, due to the good portability of APR, so some need to transplant C program also began to use APR, open source projects such as flood loader tester for server stress testing, the project is not only applicable to Apache,http ://httpd.apache.org/test/flood
3 CENTOS6 on Compile HTTPD2.4
Method One
Environment: centos6.9 apr-1.6.2.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.27.tar.bz2
The APR version needs to be above 1.4
#1 Install package group yum -y groupinstall "Development tools" yum -y install openssl-devel pcre-devel expat-devel #2 Create an account Mkdir /app/websiteuseradd -r -d /app/website -s /sbin/nologin apache #3 Unzip the installation package TAR&NBSP;XVF apr-1.6.2.tar.gz -c /usr/localtar xvf apr-util-1.6.0.tar.gz - c /usr/localtar xvf httpd-2.4.27.tar.bz2 -c /usr/local#4 Compiling aprcd /usr/local/apr-1.6.2./configure --prefix=/usr/local/apr make & make install#5 compiling apr-utilcd /usr/local/apr-util-1.6.2./configure --prefix=/usr/local/apr-util - -with-apr=/usr/local/apr make & make install#6 compiling httpd24cd /usr/local/ httpd-2.4.27 ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ -- Enable-modules=most --enable-mpms-shared=all --with-mpm=prefork make & make install#7 Modifying configuration Files vim /app/httpd24/conf/httpd.confuser apachegroup apachedocumentroot /app/website<directory /app/website> #8 Import the compiled httpd24 execution file path to the path variable vim /etc/profile.d/httpd24.shpath=/app/httpd24/bin: $PATH # execute . /etc/profile.d/httpd24.sh#9 after saving Copy httpd scripts from other machines for related modifications SCP&NBSP;172.18.50.61:/ETC/INIT.D/HTTPD&NBSP;/ETC/INIT.D/HTTPD24VIM&NBSP;/ETC/INIT.D /httpd24apachectl=/app/httpd24/bin/apachectlhttpd=${httpd-/app/httpd24/bin/httpd}pidfile=${pidfile-/app/ HTTPD24/LOGS/HTTPD24.PID}LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD24} #保存后, execute the following statement chkconfig --add httpd24chkconfig httpd24 onservice httpd24 start# so you can use service to view the startup service, 7 the startup script is binary, Can not be implemented by the user to write the shell service startup script, #这个是6和7的区别, because the7 when executing Service httpd restart, another statement is redirected, # redirecting to /bin/systemctl Restart httpd.service the execution of chkconfig httpd on ,# is redirected to another statement execution,note: forwarding request to ' Systemctl enable httpd.service '. # is not executed through the httpd startup script. So on 7 if you want to boot, compile and install the,# will be in/etc/rc.d/rc.local write /app/httpd24/bin/apachectl start# this statement, Enable boot up. At the same time compile the installed HTTP24, on 7 because there is no httpd this script, #所以必须通过apachectl来控制httpd24这个服务. #10 Create a primary site file mkdir /app/websiteecho "i am sunny in cent65e under / App/website " > /app/website/index.html#11 test # Start service service httpd24 restart# or apachectl start# Enter the HTTP link in the browser, such as http://172.18.50.65/
Method 2
Instead of compiling APR and apr-util independently, put this package under the/usr/local/httpd-2.4.27/srclib path and rename the Service Pack directory to APR and Apr-util, the key parameter at compile time is--with-included-apr, For Unified compilation
That is, the 4,5,6 in method one is synthesized in three steps as follows, and the other step is the same
Cp-r/usr/local/apr-1.6.2/usr/local/httpd-2.4.27/srclib/aprcp-r/usr/local/apr-util-1.6.0/usr/local/httpd-2.4.27 /srclib/apr-utilcd/usr/local/httpd-2.4.27/srclib/apr./configure--prefix=/app/httpd24--enable-so--enable-ssl-- enable-cgi--enable-rewrite--with-zlib--with-pcre--with-included-apr--enable-modules=most--enable-mpms-shared= All--with-mpm=prefork
4 CENTOS7 source code compilation httpd2.4
If the APR and Apr-util on the centOS7 are already above version 1.4, do not compile Apr and apr-util, if the machine does not have APR and Apr-util or version low, refer to the CentOS6 method to compile and install Apr and Apr-util
#1 Install the compilation package group yum groupinstall "Development tools" Yum -y install apr-devel apr-util-devel openssl-devel pcre-devel #2 Create account Mkdir /app/websiteuseradd -r -d /app/website -s /sbin/nologin apache #3 Unpack the package tar xvf apr-1.6.2.tar.gz -C /usr/localtar xvf apr-util-1.6.0.tar.gz -c /usr/localtar xvf httpd-2.4.27.tar.bz2 -c /usr/local #4 Compile installation cd /usr/local/src/httpd-2.4.27/./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=preforkmake && make install#5 Modifying configuration Files Vim /app/httpd24/conf/httpd.confuser apachegroup apache#6 Execute file path for compiled HTTPD24Import PATH variable vim /etc/profile.d/httpd24.shpath=/app/httpd24/bin: $PATH # Save after execute . /etc/profile.d/ httpd24.sh "#7 vim /etc/rc.d/rc.local/app/httpd24/bin/apachectl startchmod +x /etc/rc.d/rc.local# Note that here and CENTOS6 are not the same, can not create their own httpd files, so, only through apachectl this tool to control httpd#8 test # Start Service Apachectl -k start# here and centOS6 syntax is different, need to add the option-k# in the browser to enter the HTTP link, such as http://172.18.50.65/
This article is from the "Sunshine Ops" blog, please be sure to keep this source http://ghbsunny.blog.51cto.com/7759574/1970607
HTTP Compiler Installation HTTPD2.4