第三部:编译安装httpd2.4
[root@centos6 apr-util-1.6.1]# cd ..
[root@centos6 httpd2.4]# cd httpd-2.4.29
[root@centos6 httpd2.4]#./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 -j 4 && make install
[root@centos6 httpd-2.4.29]# cd /app
[root@centos6 app]# ls
apr apr-ut httpd24
第四步:环境变量。
[root@centos6 httpd24]# cd bin
[root@centos6 bin]# ls
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs
[root@centos6 bin]# echo ‘PATH=/app/httpd24/bin/:$PATH‘ > /etc/profile.d/httpd24.sh
[root@centos6 bin]# . /etc/profile.d/httpd24.sh
[root@centos6 bin]# apachectl start
第五步:用户和组
(这里注意:如果是最小化安装,apache 用户是没有的,要手工进行创建。
[root@centos6 bin]# getent passwd apache
apache:x:48:48:Apache:/var/www:/sbin/nologin
创建的方法是:
useradd -r -s /sbin/nologin apache
[root@centos6 bin]#ss -ntlp
第六部:配置文件
[root@centos6 bin]# cd /root/httpd2.4/
[root@centos6 httpd2.4]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.29
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.29.tar.bz2
[root@centos6 httpd2.4]# cd httpd-2.4.29/
[root@centos6 httpd-2.4.29]# ls
apr-1.6.3 apr-util-1.6.1 httpd-2.4.29
apr-1.6.3.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.29.tar.bz2
[root@centos6 httpd2.4]# cd httpd-2.4.29/
[root@centos6 httpd-2.4.29]# cd /app/httpd24/conf/
[root@centos6 conf]# ls
extra httpd.conf magic mime.types original
[root@centos6 conf]# vim /app/httpd24/conf/httpd.conf
user apache
group apache
[root@centos6 conf]# apachectl restart (重启服务)
[root@centos6 conf]# ps aux
现在就可以试试啦:
[root@centos7 ~]# curl 192.168.10.107
<html><body><h1>It works!</h1></body></html>
它的路径放在:
[root@centos6 ~]# cd /app/httpd24/
[root@centos6 httpd24]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@centos6 httpd24]# cd htdocs
[root@centos6 htdocs]# ls
index.html
第七步:开机脚本。
设为开机启动:
[root@centos6 conf]# echo "/app/httpd24/bin/apachectl start" >> /etc/rc.d/rc.local
开机重启。
最好写脚本:
cp /etc/init.d/httpd /etc/init.d/httpd24
vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
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
读写执行的权限。
chkconfig --add httpd24
chkconfig httpd24 on
service httpd24 start
reboot
vim /etc/rc.d/rc.local
/app/httpd24/bin/apachectl start 就可以删啦。
原文地址:http://blog.51cto.com/13466315/2091959