1. Download httpd, apr, apr-util source packages
httpd source package
http://httpd.apache.org/download.cgi#apache24
apr and apr-util source packages
http://apr.apache.org/download.cgi
2. Compile httpd
1. Decompress the three software packages, decompress apr and apt-util into the httpd-2.4.25/srclib/ directory, remove the version number after decompressing apr and apr-util, and store srclib as shown below:
2. Install dependent software
yum install -y zlib-devel pcre pcre-devel apr apr-devel
3. Enter the httpd source package directory to compile
./configure --prefix=/usr/local/httpd --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre make && make install
4. Modify the configuration file httpd.conf
Find the ServerName line, remove the comment and modify it as follows:
ServerName localhost
3. Compress the compiled code
tar -cvf /usr/local/src/httpd-2.4.25.tar.gz /usr/local/httpd/
Fourth, Centos 7 writes httpd.servie script file name is httpd.service
[Unit] Description=httpd After=httpd.target [Service] Type=forking ExecStart=/etc/init.d/httpd start ExecReload=/etc/init.d/httpd restart ExecStop=/etc/init.d/nginx stop PrivateTmp=true [Install] WantedBy=multi-user.target
5. Copy a file /usr/loca/httpd/bin/apachectl as httpd, and add " # chkconfig: 345 33 33" at the beginning of the file, and put it in a random place temporarily. When you automate later, you need the beginning of the file The content is as follows
#!/bin/sh # chkconfig: - 33 33 # Licensed to the Apache Software Foundation (ASF) under one or more
Six, ansible automatic scripting
1. Create a file in the following directory. The path is customized here. I write it in /etc/ansible/httpd-install/
Among them, httpd-2.4.25.tar.gz is the compressed package of compiled httpd,
httpd is the httpd file that is copied and processed in the fifth step
httpd.service is the file made in the fourth step, which is used by Centos7. If it is not Centos7, this file is not required.
2. Create the file roles/http/tasks/main.yml file
--- # The file specified by src is the file under http/files - name: Copy Httpd Software copy: src=httpd-2.4.25.tar.gz dest=/tmp/httpd-2.4.25.tar.gz owner=root group=root - name: Uncompression Httpd Software shell: tar -xvf /tmp/httpd-2.4.25.tar.gz -C /usr/local/ - name: copy apachectl to /etc/init.d copy: src=httpd dest=/etc/init.d/httpd owner=root group=root - name: copy http start service copy: src=httpd.service dest=/usr/lib/systemd/ owner=root group=root - name: Install initializtion require software yum: name={{ item }} state=installed with_items: - zlib-devel - pcre-devel - apr-devel - name: start httpd service: name=httpd state=restarted - name: Delete Httpd Compression files shell: rm -rf /tmp/httpd-2.4.25.tar.gz3. Create the file install.yml
--- - hosts: dbserver remote_user: root gather_facts: True roles: - http4. Configure the /etc/ansible/hosts file
[dbserver] rs-db1.tianjun.com5. Run the installation under /etc/ansible/httpd-install
ansible-playbook install.yml
If you think the writing is good, welcome to reward: