内容简介:编译环境准备编译所需的httpd、apr、apr-util1.安装编译所需要的软件
一、编译安装
编译环境准备
主机 | 系统 |
---|---|
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.解压所有压缩包
[root@CentOS6 ~]# tar -xf apr-util-1.6.1.tar.gz [root@CentOS6 ~]# tar -xf apr-1.7.0.tar.gz [root@CentOS6 ~]# tar -xf httpd-2.4.39.tar.gz
3.将apr及apr-util复制到httpd-2.4.39/srclib目录中
[root@CentOS6 ~]# cp -a apr-1.7.0 httpd-2.4.39/srclib/apr [root@CentOS6 ~]# cp -a apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
4.编译httpd
[root@CentOS6 ~]# cd httpd-2.4.39 [root@CentOS6 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.安装
[root@CentOS6 ~]# make && make install
6.为httpd创建系统用户
[root@CentOS6 ~]# useradd -r -s /sbin/nologin apache
7.修改配置文件,将httpd运行的用户和组改为apache
[root@CentOS6 ~]# vim /app/httpd24/conf/httpd.conf User apache Group apache
8.配置环境变量
[root@CentOS6 ~]# echo "PATH=/app/httpd24/bin:$PATH" > /etc/profile.d/httpd24.sh
9.设置为开机启动
[root@CentOS6 ~]# vim /etc/rc.d/rc.local /app/httpd24/bin/apachectl start
ansible-playbook编译安装httpd2.4
ansible 编译安装httpd
一、创建角色目录结构
[root@localhost data]# mkdir -pv roles/httpd2.4/{tasks,files,vars,templates,handlers} mkdir: created directory ‘roles’ mkdir: created directory ‘roles/httpd2.4’ mkdir: created directory ‘roles/httpd2.4/tasks’ mkdir: created directory ‘roles/httpd2.4/files’ mkdir: created directory ‘roles/httpd2.4/vars’ mkdir: created directory ‘roles/httpd2.4/templates’ mkdir: created directory ‘roles/httpd2.4/handlers’
二、创建task
进入tasks目录
[root@localhost ~]# cd /data/roles/httpd2.4/tasks/
1.为httpserver创建安装目录
[root@localhost tasks]# vim createdir.yaml - name: Create dir file: path=/app state=directory
2.解压httpd,apr,apr-util到远程主机
[root@localhost tasks]# vim ungzhttpd.yaml - name: ungz httpd24 unarchive: src=httpd.tar.gz dest=/app copy=yes - name: ungz apr to srclib unarchive: src=apr.tar.gz dest=/app/httpd-2.4.39/srclib copy=yes - name: ungz apr-util to srclib unarchive: src=apr-util.tar.gz dest=/app/httpd-2.4.39/srclib copy=yes
3.对解压后的apr.tar.gz及apr-util.tar.gz做软连接
[root@localhost tasks]# vim links.yaml - name: link apr-util file: src=/app/httpd-2.4.39/srclib/apr-util-1.6.1 dest=/app/httpd-2.4.39/srclib/apr-util state=link - name: link apr file: src=/app/httpd-2.4.39/srclib/apr-1.7.0 dest=/app/httpd-2.4.39/srclib/apr state=link
4.编译httpd
[root@localhost tasks]# vim configure.yaml - name: configer httpd shell: /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
5.make
[root@localhost tasks]# vim make.yaml - name: make shell: make
6.make install
[root@localhost tasks]# vim install.yaml - name: install shell: make install
7.设置开机自启
[root@localhost tasks]# vim chkconf.yaml - name: chkconfig lineinfile: path=/etc/rc.d/rc.local insertafter="^touch.*" line="/app/httpd24/bin/apachectl start"
8.添加apache用户
[root@localhost tasks]# vim useradd.yaml - name: add user user: name=apache system=yes shell=/sbin/nologin create_home=no
9.调用模板文件生成环境变量及httpd配置文件
[root@localhost tasks]# vim template.yaml - name: httpd config template: src=httpd.conf.j2 dest=/app/httpd24/conf/httpd.conf - name: Path template: src=httpd.sh.j2 dest=/etc/profile.d/httpd.sh
10.读取环境变量
[root@localhost tasks]# vim source.yaml - name: source path shell: source /etc/profile.d/httpd.sh
11.启动服务
[root@localhost tasks]# vim service.yaml - name: start service shell: apachectl start
12.创建main.yaml
[root@localhost tasks]# vim main.yaml - include: createdir.yaml - include: ungzhttpd.yaml - include: links.yaml - include: configure.yaml - include: make.yaml - include: install.yaml - include: chkconf.yaml - include: useradd.yaml - include: template.yaml - include: source.yaml - include: service.yaml
三、创建playbook
[root@localhost data]# vim role_httpd.yaml [root@localhost tasks]# cd /data [root@localhost data]# vim role_httpd.yaml --- - hosts: all roles: - role: httpd2.4
四、目录结构
[root@localhost data]# tree /data /data ├── role_httpd.yaml └── roles └── httpd2.4 ├── files #此目录下存放所有需要解压的包,注意去掉版本号 │ ├── apr.tar.gz │ ├── apr-util.tar.gz │ └── httpd.tar.gz ├── handlers ├── tasks │ ├── chkconf.yaml │ ├── configure.yaml │ ├── createdir.yaml │ ├── install.yaml │ ├── links.yaml │ ├── main.yaml │ ├── make.yaml │ ├── service.yaml │ ├── source.yaml │ ├── template.yaml │ ├── ungzhttpd.yaml │ └── useradd.yaml ├── templates #此目录下存放配置文件和环境变量的模板文件 │ ├── httpd.conf.j2 │ └── httpd.sh.j2 └── vars
五、执行playbook
[root@localhost ansible]# ansible-playbook role_httpd.yaml
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Golang源码探索(一) 编译和调试源码
- 写Java这么久,JDK源码编译过没?编译JDK源码踩坑纪实 原 荐
- JVM源码分析-JVM源码编译与调试
- 使用源码编译Hadoop
- Runtime源码编译
- 下载编译AOSP源码
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
松本行弘的程序世界
松本行弘 / 柳德燕、李黎明、夏倩、张文旭 / 人民邮电出版社 / 2011-8 / 75.00元
《松本行弘的程序世界》是探索程序设计思想和方法的经典之作。作者从全局的角度,利用大量的程序示例及图表,深刻阐述了Ruby编程语言的设计理念,并以独特的视角考察了与编程相关的各种技术。阅读《松本行弘的程序世界》不仅可以深入了解编程领域各个要素之间的关系,而且能够学到大师的思考方法。 《松本行弘的程序世界》面向各层次程序设计人员和编程爱好者,也可以供相关技术人员参考。一起来看看 《松本行弘的程序世界》 这本书的介绍吧!