CentOS 6.10源码编译及使用ansible编译安装httpd2.4.39

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.10源码编译及使用ansible编译安装httpd2.4.39相关的知识,希望对你有一定的参考价值。

一、编译安装
编译环境准备
主机 系统
A centos6.10

编译所需的httpd、apr、apr-util

apr-1.7.0.tar.gz
apr-util-1.6.1.tar.gz
httpd-2.4.39.tar.gz

1.安装编译所需要的软件

yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof tcpdump wget ntpdate net-tools iotop bc zip unzip nfs-utils expat-devel -y

2.解压所有压缩包

[[email protected] ~]# tar -xf apr-util-1.6.1.tar.gz 
[[email protected] ~]# tar -xf apr-1.7.0.tar.gz 
[[email protected] ~]# tar -xf httpd-2.4.39.tar.gz 

3.将apr及apr-util复制到httpd-2.4.39/srclib目录中

[[email protected] ~]# cp -a apr-1.7.0 httpd-2.4.39/srclib/apr
[[email protected] ~]# cp -a apr-util-1.6.1 httpd-2.4.39/srclib/apr-util

4.编译httpd

[[email protected] ~]# cd httpd-2.4.39
[[email protected] httpd-2.4.39]# ./configure  --prefix=/app/httpd24  --enable-so  --enable-ssl  --enable-cgi --enable-rewrite  --with-zlib  --with-pcre  --with-included-apr=/root/httpd-2.4.39/srclib/  --enable-modules=most  --enable-mpms-shared=all  --with-mpm=prefork

5.安装

[[email protected] ~]# make && make install

6.为httpd创建系统用户

[[email protected] ~]# useradd -r -s /sbin/nologin apache

7.修改配置文件,将httpd运行的用户和组改为apache

[[email protected] ~]# vim /app/httpd24/conf/httpd.conf 
User apache
Group apache

8.配置环境变量

[[email protected] ~]# echo "PATH=/app/httpd24/bin:$PATH" > /etc/profile.d/httpd24.sh

9.设置为开机启动

[[email protected] ~]# vim /etc/rc.d/rc.local 
/app/httpd24/bin/apachectl start

ansible编译安装httpd2.4


创建app目录
[[email protected] ~]# ansible ws -m file -a "path=/app state=directory"
解压httpd
[[email protected] ~]# ansible ws -m unarchive -a ‘src=~/httpd-2.4.39.tar.gz  dest=/app copy=yes‘
解压apr-util
[[email protected] ~]# ansible ws -m unarchive -a ‘src=~/apr-util-1.6.1.tar.gz  dest=/app/httpd-2.4.39/srclib/ copy=yes‘
解压apr
[[email protected] ~]# ansible ws -m file -a "src=/app/httpd-2.4.39/srclib/apr-1.7.0 dest=/app/httpd-2.4.39/srclib
创建apr-util软连接
[[email protected] ~]# ansible ws -m file -a "src=/app/httpd-2.4.39/srclib/apr-util-1.6.1 dest=/app/httpd-2.4.39/srclib/apr-util state=link"
创建apr软连接
[[email protected] ~]# ansible ws -m file -a "src=/app/httpd-2.4.39/srclib/apr-1.7.0 dest=/app/httpd-2.4.39/srclib/apr state=link"
编译
[[email protected] ~]# ansible ws -m shell -a "/app/httpd-2.4.39/configure  --prefix=/app/httpd24  --enable-so  --enable-ssl  --enable-cgi --enable-rewrite  --with-zlib  --with-pcre  --with-included-apr=/root/httpd-2.4.39/srclib/  --enable-modules=most  --enable-mpms-shared=all  --with-mpm=prefork"
安装
[[email protected] ~]# ansible ws -m shell -a "make && make install"
创建apache用户
[[email protected] ~]# ansible ws -m user -a "name=apache  system=yes shell=/sbin/nologin create_home=no "
配置开机启动
[[email protected] ~]# ansible ws -m lineinfile -a ‘path=/etc/rc.d/rc.local insertafter="^touch.*" line="/app/httpd24/bin/apachectl start"‘
为rc.local设置执行权限
[[email protected] ~]# ansible ws -m file -a "path=/etc/rc.d/rc.local mode=755 "
复制配置文件
[[email protected] ~]# ansible ws -m copy -a ‘src=/root/httpd.conf dest=/app/httpd24/conf/httpd.conf‘
添加环境变量配置文件
[[email protected] ~]# ansible ws -m copy -a ‘src=/root/httpd.sh dest=/etc/profile.d/httpd.sh‘
读取环境变量
[[email protected] ~]# ansible ws -m shell -a ‘source /etc/profile.d/httpd.sh‘
启动服务
[[email protected] ~]# ansible ws -m shell -a ‘apachectl start‘

以上是关于CentOS 6.10源码编译及使用ansible编译安装httpd2.4.39的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 6.10 服务管理

linux centos 6.10 编译安装mysql5.6.40版本,数据库主从

CentOS 6.x (6.10) 到 CentOS 7.x

青蛙学Linux—CentOS 6.10的安装

Vagrant Box 镜像准备:Packer 打包 Centos 6.10 系统

Vagrant Box 镜像准备:Packer 打包 Centos 6.10 系统