centos6.9编译安装httpd2.4
实验环境准备:[*]官网http://www.apache.org/下载源代码httpd2.4,以及相关依赖包apr-1.6.2,apr-util-1.6.0
[*]准备没有安装过httpd任何版本的centos6.9系统
安装开发包
1
2
3
]#yum install openssl-devel -y
]#yum install pcre-devel -y
]#yum install expat-devel -y
上传源代码并解压缩
1
2
3
4
5
]#cd /app
app]#rz
app]#tar xvf apr-1.6.2.tar.gz
app]#tar xvf apr-util-1.6.0.tar.gz
app]#tar xvf httpd-2.4.27.tar.bz2
编译安装依赖包
1
2
3
4
5
6
app]#cd apr-1.6.2
apr-1.6.2]./configure --prefix=/app/apr <===指定目录
apr-1.6.2]make & make install
apr-util-1.6.0]#cd apr-util-1.6.0
apr-util-1.6.0]#./configure --prefix=/app/apr-util --with-apr=/app/apr<===apr-util依赖apr包,所以要先安装apr包
apr-util-1.6.0]#make & make install
编译安装httpd2.4
1
2
3
]#cd /app/httpd-2.4.27
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
httpd-2.4.27]#make & make install
创建apache用户
1
]#useradd -r -m -d /var/www -s /sbin/nologin apache
修改相关配置
1.配置文件
1
2
3
4
5
]#vim /app/httpd24/conf/httpd.conf <===需要修改的四项
user apache
group apache
Documentroot /var/www/html
<directory /var/www/html>
2.配置环境变量
1
2
]#vim /etc/profile.d/httpd24.sh
export PATH=/app/httpd24/bin:$PATH
3.自定义启动脚本
1
2
3
4
5
6
]#scp /etc/init.d/httpd 192.168.32.10://etc/init.d/httpd24<===参考httpd2.2的脚本。从其他主机拷贝一份,192.168.32.10为本机;
]#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/httpd}
4.添加开机启动,并启动httpd24
1
2
3
4
5
6
7
8
9
10
]#chkconfig–add httpd24
]#service httpd24 start
]#ss -tan <===80端口已监听
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 64 :::873 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 32 *:21 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 ::1:25 :::*
测试
1
2
]#echo httpd24 > /etc/www/html/index.html
]#service httpd24 reload
上面的方法编译了三次,比较繁琐,其实也可以只用一次编译。
方法二:
1
2
3
4
5
]#cp -av apr-1.6.2/app/httpd-2.4.27/srclib/apr
]#cp -av apr-util-1.6.0 /app/httpd-2.4.27/srclib/apr-util <===2个依赖包解压缩后复制到指定目录并改名
]#cd httpd-2.4.27/
httpd-2.4.27]#./configure --prefix=/usr/local/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
<===注意这里要修改--with-included-apr
其余配置和第一种方法相同,这里就不在赘述。
页:
[1]