Shell 自动化安装Apache,并配置虚拟主机
2017-11-17 09:44
330 查看
(一)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文件
(10)启动Apache验证配置结果
二 Shell 安装Apache 实战演练
验证配置结果是否正确
(1)查看Apache进程是否启动 ps -ef |grep vsftpd
(2)查看80端口是否监听 netstat -ntl |grep 80
(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文件
(10)启动Apache验证配置结果
二 Shell 安装Apache 实战演练
#! /bin/bash #2017年11月13日15:10:43 #atuo apache v1 #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 <VirtualHost *: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 </VirtualHost> <VirtualHost *:80> 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 </VirtualHost> ">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 |
#! /bin/bash #2017年11月13日15:10:43 #atuo apache v2 #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 |
(1)查看Apache进程是否启动 ps -ef |grep vsftpd
(2)查看80端口是否监听 netstat -ntl |grep 80
相关文章推荐
- apache安装、配置虚拟主机、配置日志
- Ubuntu Linux Apache虚拟主机的安装配置
- 在RHEL5下构建LAMP网站服务平台之编译安装Apache与配置基于域名的虚拟Web主机
- 从源代码编译安装Apache-httpd-2.4.23及虚拟主机和反向代理的配置
- Windows环境下Apache的安装与虚拟主机, 虚拟目录的配置
- CentOS7 初次安装记录(五)配置 apache 虚拟主机
- 55 ip 域名以及dns 56.Apache安装及虚拟主机配置 ...23
- Apache 安装和虚拟主机的配置
- Apache2.2.17源码编译安装以及配置虚拟主机
- ubuntu下apt-get安装apache的虚拟主机的配置
- (转)Apache安装常见配置(修改主目录、首页文件、建立虚拟主机等)
- centos7编译安装apache后添加用户认证和配置虚拟主机
- 在Red Hat Linux5下构建LAMP网站服务平台之编译安装Apache与配置基于域名的虚拟Web主机
- centos7.2 利用yum安装配置apache2.4多虚拟主机
- linux系统之apache基本配置及语言支持及虚拟主机 访问控制
- Apache22中配置虚拟主机(Apache VirtualHost)
- 在apache下配置虚拟主机
- APACHE中如何在同一个IP配置两个虚拟主机
- 在Apache中配置基于主机名的虚拟主机
- Apache 配置虚拟主机三种方式