(一)Apache安裝思路html
(1) 安裝必要組件linux
wget openssl* gccapache
(2)關閉防火牆和Selinux
vim
service iptables stop setenforce 0bash
(3)下載Apache源碼文件,並解壓ide
(4)預編譯 編譯 安裝Apache網站
預編譯時,添加必要組件this
--enable so --enable rewrite --enable spa
(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.gztar -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.confecho "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