准备安装包三个:
[root@centos7 ]#mkdir httpd2.4//创建httpd2.4目录
[root@centos7 src]#mv *.bz2 httpd2.4/ //把下载的安装包放到httpd2.4里面
[root@centos7 httpd2.4]#ls
apr-1.6.3.tar.bz2
httpd-2.4.29.tar.bz2
apr-util-1.6.1.tar.bz2
安装开发包组
[root@centos7 httpd2.4]#yum groupinstall "development tools"
[root@centos6 httpd2.4]#yum install openssl-devel pcre-devel expat-devel
解压缩
[root@centos6 httpd2.4]#tar xvf apr-1.6.3.tar.bz2
[root@centos6 httpd2.4]#tar xvf apr-util-1.6.1.tar.bz2
[root@centos6 httpd2.4]#tar xvf httpd-2.4.29.tar.bz2
安装编译
apr-1.6.2
apr-util-1.6.1
httpd2.4
apr-1.6.2
[root@centos6 httpd2.4]#cd apr-1.6.2
[root@centos6 apr-1.6.2]#./configure --prefix=/app/apr
[root@centos6 apr-1.6.2]#make && make install
apr-util-1.6.1
[root@centos6 httpd2.4]#cd apr-1.6.2
[root@centos6 apr-util-1.6.1]#./configure --prefix=/app/apr-util --with-apr=/app/apr/
[root@centos6 apr-util-1.6.1]#make && make install
httpd2.4
[root@centos6 httpd2.4]#cd httpd-2.4.29
[root@centos6 httpd-2.4.29]#./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.29]#make && make install
配置文件
[root@centos6 httpd-2.4.29]#cd /app/httpd24/
[root@centos6 httpd24]#cd bin/
环境变量
[root@centos6 bin]#echo "PATH=/app/httpd24/bin/:$PATH" > /etc/profile.d/httpd24.sh
[root@centos6 bin]#. /etc/profile.d/httpd24.sh
修改httpd默认启动用户daemon改为apache
[root@centos7 bin]#vim /app/httpd24/conf/httpd.conf
User apache //170行处
Group apache
[root@centos7 bin]#useradd -r -s /sbin/nologin apache //创建apache 系统用户
启动并查看端口
[root@centos6 bin]#apachectl start
[root@centos6 bin]#ss -ntl |grep 80
LISTEN 0 128 :::80 :::*
主站点在
[root@centos6 httpd24]#vim /app/httpd24/htdocs/index.html
设置开机启动
第一种方法
[root@centos6 httpd24]#echo "/app/httpd24/bin/apachectl start" > /etc/rc.d/rc.local
第二种方法
[root@centos6 ~]#cp /etc/init.d/httpd /etc/init.d/httpd24
[root@centos6 ~]#vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl //42行处
httpd=${HTTPD-/app/httpd24/bin/httpd}
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
修改上面几个路径信息
[root@centos6 ~]#ll /etc/init.d/httpd24
-rwxr-xr-x 1 root root 3507 Jan 30 22:14 /etc/init.d/httpd24
[root@centos6 ~]#chkconfig --add httpd24
[root@centos6 ~]#chkconfig httpd24 on
[root@centos6 ~]#chkconfig --list |grep httpd
httpd24 0:off 1:off 2:on 3:on 4:on 5:on 6:off