Shell 自动化安装Apache,并配置虚拟主机
#! /bin/bash #2017年11月13日15:10:43#atuo apachev1
#by author daqi
##############
yum install vim -y
yum install wget -y
yum install gcc -y
yum install openssl* -y
yum install lrzsz -y
service iptables stop
setenforce 0
下载Apache配置文件
wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.2.34.tar.gz tar -xzf httpd-2.2.34.tar.gz解压Apache
cd httpd-2.2.34
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl
make
make install 预编译 编译 安装
cd /usr/local/apache2/conf
把Include conf/extra/httpd-vhosts.conf ,这句话加入到httpd.conf配置文件中
echo "Include conf/extra/httpd-vhosts.conf">>httpd.conf echo "NameVirtualHost *:80
ServerAdmin daqi@eastmoney.com
DocumentRoot "/usr/local/apache2/htdocs/jf1"
ServerName www.jf1.com
ErrorLog "logs/jf1/error_log"
CustomLog "logs/jf1/access_log" common
ServerAdmin daqi@eastmoney.com
DocumentRoot "/usr/local/apache2/htdocs/jf2"
ServerName www.jf2.com
ErrorLog "logs/jf2/error_log"
CustomLog "logs/jf2/access_log" common
">extra/httpd-vhosts.conf配置虚拟主机
mkdir -p /usr/local/apache2/htdocs/jf1 创建发布目录
mkdir -p /usr/local/apache2/htdocs/jf2
mkdir -p /usr/local/apache2/logs/jf1 创建日志目录
mkdir -p /usr/local/apache2/logs/jf2
echo "
this is jf1 test page
">/usr/local/apache2/htdocs/jf1/index.html 在发布目录下创建index文件
echo "
this is jf2 test page
">/usr/local/apache2/htdocs/jf2/index.html
页:
[1]