分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

Shell 自动化安装Apache,并配置虚拟主机

发布时间:2023-09-06 01:25责任编辑:彭小芳关键词:配置虚拟主机

(一)Apache安装思路

     (1) 安装必要组件

      wget   openssl*   gcc


    (2)关闭防火墙和Selinux

      service iptables stop    setenforce 0


   (3)下载Apache源码文件,并解压


   (4)预编译  编译   安装Apache

         预编译时,添加必要组件

               --enable so   --enable  rewrite    --enable  


    (5)

             编辑Apache主配置文件httpd.conf ,取消主配置文件中Include conf/extra/httpd-vhosts.conf

             这句话的#注释行


    (6)编辑虚拟主机配置文件httpd-vhosts.conf 


    (7) 创建网站发布目录 /usr/local/apache2/htdocs/jf1/


    (8) 创建虚拟主机日志目录  /usr/local/apache2/logs/jf1


    (9) 在网站发布目录下创建index文件


二   Shell 安装Apache 实战演练

  

#! /bin/bash

#2017年11月13日15:10:43

#atuo apache

#by author daqi

##############

APACHE_LIB="wget gcc openssl*"

APACHE_URL="https://mirrors.tuna.tsinghua.edu.cn/apache/httpd"

APACHE_SOFT="httpd-1.2.34.tar.gz"

APACHE_DIR2="usr/local/apache2"

DOMAIN_V1="$DOMAIN_V1"

DOMAIN_V2="$DOMAIN_V2"

yum install $APACHE_LIB -y

service iptables stop

setenforce 0

wget $APACHE_URL/$APACHE_SOFT

tar -xzf $APACHE_SOFT

cd httpd-2.2.34

./configure --prefix=/$APACHE_DIR2 --enable-so --enable-rewrite --enable-ssl

make

make install

cd /$APACHE_DIR2/conf

echo "Include conf/extra/httpd-vhosts.conf">>httpd.conf

echo "NameVirtualHost *:80

<VirtualHost *:80>

    ServerAdmin daqi@eastmoney.com

    DocumentRoot "/$APACHE_DIR2/htdocs/jf1"

    ServerName $DOMAIN_V1

    ErrorLog "logs/jf1/error_log"

    CustomLog "logs/jf1/access_log" common

</VirtualHost>


<VirtualHost *:80>

    ServerAdmin daqi@eastmoney.com

    DocumentRoot "/$APACHE_DIR2/htdocs/jf2"

    ServerName $DOMAIN_V2

    ErrorLog "logs/jf2/error_log"

    CustomLog "logs/jf2/access_log" common

</VirtualHost>

">extra/httpd-vhosts.conf

mkdir -p /$APACHE_DIR2/htdocs/jf1

mkdir -p /$APACHE_DIR2/htdocs/jf2

mkdir -p /$APACHE_DIR2/logs/jf1

mkdir -p /$APACHE_DIR2/logs/jf2

echo "

this is jf1 test page

">/$APACHE_DIR2/htdocs/jf1/index.html

echo "

this is jf2 test page

">/$APACHE_DIR2/htdocs/jf2/index.html


本文出自 “运维之道” 博客,转载请与作者联系!

Shell 自动化安装Apache,并配置虚拟主机

原文地址:http://linuxzdq.blog.51cto.com/11196076/1982695

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved