Centos6.9 compile and install httpd2.4
Environment:
Centos6.9
Apr-1.6.2.tar.gz
Apr-util-1.6.0.tar.gz
Httpd-2.4.27.tar.bz2
1. Install the development package Group
[root@CentOS6 /app]$ yum groupinstall "Development tools"[root@CentOS6 /app]$ yum install openssl-devel pcre-devel expat-devel
Ii. Download and decompress the Software Package
[root@CentOS6 /app]$tar xvf apr-1.6.2.tar.gz [root@CentOS6 /app]$tar xvf apr-util-1.6.0.tar.gz[root@CentOS6 /app]$tar xvf httpd-2.4.27.tar.bz2
Iii. Compilation and installation 1) apr
[root@CentOS6 /app]$cd apr-1.6.2[root@CentOS6 /apr-1.6.2]$./configure --prefix=/app/apr[root@CentOS6 /apr-1.6.2]$make -j 4 & make install
2) apr-util
[root@CentOS6 /app]$cd /app/apr-util-1.6.0 [root@CentOS6 /apr-util-1.6.0]$./configure --prefix=/app/apr-util --with-apr=/app/apr[root@CentOS6 /apr-util-1.6.0]$make -j 4 & make install
3) httpd2.4 ① create an account
[root@CentOS6 /app]$useradd -r -d /app/website -s /sbin/nologin apache
② Compile and install
[root@CentOS6 /app]$cd /app/httpd-2.4.27[root@CentOS6 /httpd-2.4.27]$./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/app/apr/ --with-apr-util=/app/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork[root@CentOS6 /httpd-2.4.27]$make -j 4 & make install
4. Configure 1) configure the httpd service
[root@CentOS6 /httpd-2.4.27]$vim /app/httpd24/conf/httpd.confuser apachegroup apacheDocumentroot /app/website<directory /app/website>
2) configure the PATH variable
[root@CentOS6 /httpd-2.4.27]$vim /etc/profile.d/httpd24.shexport PATH=/app/httpd24/bin:$PATH
3) configure the service script
[root@CentOS6 /httpd-2.4.27]$vim /etc/init.d/httpd24apachectl=/app/httpd24/bin/apachectlhttpd=${HTTPD-/app/httpd24/bin/httpd}pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
4) Add a service script and set startup.
[root@CentOS6 /app]$chkconfig --add httpd24[root@CentOS6 /app]$chkconfig --list httpd24httpd24 0:off 1:off 2:off 3:off 4:off 5:off 6:off[root@CentOS6 /app]$chkconfig httpd24 on
5) create a home site folder and start the service
[root@CentOS6 /app]$mkdir /app/website[root@CentOS6 /app]$echo /app/website/index.html > /app/website/index.html[root@CentOS6 /app]$service httpd24 start[root@CentOS6 /app]$ss -tnl|grep 80LISTEN 0 128 :::80 :::*
V. Test
[root@CentOS6 /app]$curl 172.18.46.6This is a test web page