欢迎光临
我们一直在努力

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

本站教程收集整理的这篇文章主要介绍了Shell 自动化安装Apache,并配置虚拟主机,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

(一)Apache安装思路

(1) 安装必要组件

wget openssl* gcc

@H_262_7@

(2)关闭防火墙和Selinux@H_262_7@

service iptables stop setenforce 0

@H_262_7@

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

@H_262_7@

(4)预编译 编译 安装Apache

预编译时,添加必要组件

–enable 美国高防vps so –enable rewrite –enable

@H_262_7@

(5)

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

这句话的#注释行

@H_262_7@

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

@H_262_7@

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

@H_262_7@

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

@H_262_7@

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

@H_262_7@

二 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

@H_698_0@make

@H_698_0@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>

@H_262_7@

<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

@H_698_0@mkdir -p /$APACHE_DIR2/htdocs/jf1

@H_698_0@mkdir -p /$APACHE_DIR2/htdocs/jf2

@H_698_0@mkdir -p /$APACHE_DIR2/logs/jf1

@H_698_0@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,并配置虚拟主机全部内容,希望文章能够帮你解决Shell 自动化安装Apache,并配置虚拟主机所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。