shuaiwei588 发表于 2018-11-23 07:52:58

源码包编译安装Apache搭建虚拟Web主机

安装Apache源码包[h源码包编译安装Apache搭建虚拟Web主机


安装Apache源码包根据源码包安装四步骤,先安装gcc工具
挂载光盘安装gcc
1.挂载光盘配置yum库
# cd /misc/cd/Server/
You have new mail in /var/spool/mail/root
# cd /etc/yum.repos.d/
You have new mail in /var/spool/mail/root
# ls
rhel-debuginfo.repo
# cp rhel-debuginfo.repo rhel-server.repo
# ls
rhel-debuginfo.reporhel-server.repo
# vim rhel-server.repo

name=Red Hat Enterprise Linux S
baseurl=file:///misc/cd/Server/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# yum -y install gcc*    //安装源码包需要安装gcc
# yum clean all

Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning up Everything
# yum list | wc -l               //yum库安装完毕
3347

# ls Desktop///VMware-tools工具拖拽到桌面或挂载到指定的路径
httpd-2.2.25.tar.gz

# tar -zxf Desktop/httpd-2.2.25.tar.gz -C /usr/local/
# cd /usr/local/
# ls
awstatsetc    httpd-2.2.25lib    libexecshare
bin      gamesinclude       lib64sbin   src
# cd httpd-2.2.25/
You have new mail in /var/spool/mail/root
2.源码包安装

# ./configure             //进入软件包执行安装第一步
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands

# echo $?   //测试上一步是否安装成功,如果是0就是对的
0
# make      //执行编译
libmod_negotiation.la modules/mappers/libmod_dir.la modules/mappers/libmod_actions.la modules/mappers/libmod_userdir.la modules/mappers/libmod_alias.la modules/mappers/libmod_so.la server/mpm/prefork/libprefork.la os/unix/libos.la -lm /usr/local/httpd-2.2.25/srclib/pcre/libpcre.la /usr/local/httpd-2.2.25/srclib/apr-util/libaprutil-1.la /usr/local/httpd-2.2.25/srclib/apr-util/xml/expat/libexpat.la /usr/local/httpd-2.2.25/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread -ldl

make: Leaving directory `/usr/local/httpd-2.2.25'

# echo $?
0
# make install   //执行make install将相关文件部署到系统
mkdir /usr/local/apache2/man

mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make: Leaving directory `/usr/local/httpd-2.2.25'
You have new mail in /var/spool/mail/root
# echo $?
0
# ls
ABOUT_APACHE   configure       libhttpd.dep   os
acinclude.m4   configure.in    libhttpd.dsp   README
Apache.dsw   docs            libhttpd.mak   README.platforms
build          emacs-style   LICENSE      README-win32.txt
BuildAll.dsp   httpd          【Makefile】    ROADMAP
BuildBin.dsp   httpd.dep       Makefile.in    server
buildconf      httpd.dsp       Makefile.win   srclib
buildmark.o    httpd.mak       modules      support
CHANGES      httpd.spec      modules.c      test
config.layoutinclude         modules.lo   VERSIONING
config.log   INSTALL         modules.o
config.nice    InstallBin.dspNOTICE
config.statusLAYOUT          NWGNUmakefile

# cd apache2/bin/
# ls
ab         apr-1-configapxs      dbmmanageenvvars-std   htdbm   htpasswdhttxt2dbm   rotatelogs
apachectlapu-1-configcheckgidenvvars    htcachecleanhtdigesthttpd   logresolve
# pwd
/usr/local/apache2/bin
# /usr/local/apache2/bin/apachectl start    //用绝对路径执行apachect1启动
3.源码包安装成功,开始搭建DNS服务器:
安装bind bind-chroot caching-nameserver软件:
#cd /misc/cd/Server/
#rpm -ivh bind-9.3.6-20.P1.el5_8.5.x86_64.rpm bind-chroot-9.3.6-20.P1.el5_8.5.x86_64.rpm caching-nameserver-9.3.6-20.P1.el5_8.5.x86_64.rpm
# rpm -q bind bind-chroot caching-nameserver
bind-9.3.6-20.P1.el5_8.5
bind-chroot-9.3.6-20.P1.el5_8.5
caching-nameserver-9.3.6-20.P1.el5_8.5
# # cd /var/named/chroot/etc/
You have new mail in /var/spool/mail/root
# ls
localtime                      rndc.key
named.caching-nameserver.confnamed.rfc1912.zones
#cp -p named.caching-nameserver.conf named.conf
# vim named.conf
// caching-nameserver package upgrade.
//
options {
      listen-on port 53 { 192.168.10.90; };   //本机ip地址
      directory       "/var/named";
      dump-file       "/var/named/data/cache_dump.db";
      statistics-file "/var/named/data/named_stats.txt";
      memstatistics-file "/var/named/data/named_mem_stats.txt";
      allow-query   { any; };
      allow-query-cache { any; };
};
logging {
      channel default_debug {
                file "data/named.run";
                severity dynamic;
      };
};
view localhost_resolver {
      match-clients      { any; };
      match-destinations { any; };
      recursion yes;
      include "/etc/named.rfc1912.zones";
};
:%s/localhost/any/gc

# vim named.rfc1912.zones
//一般搭建DNS服务器只需配置正向解析:
zone "tarena.com" IN {
      type master;
      file "tarena.com.zone";
      masters { 192.168.10.1; };
};

# named-checkconf named.conf named.rfc1912.zones
# cd ../var/named/
data            named.broadcastnamed.local
localdomain.zonenamed.ca         named.zero
localhost.zone    named.ip6.localslaves
# cp -p named.local tarena.com.zone
# vim tarena.com.zone
$TTL    86400
@       IN      SOA   tarena.com. root.tarena.com.(
                                    2014030701 ; Serial
                                    28800      ; Refresh
                                    14400      ; Retry
                                    3600000    ; Expire
                                    86400 )    ; Minimum
      IN      NS   dns1.tarena.com.
dns1    IN      A       192.168.10.1
www   IN      A       192.168.10.1
bbs   IN      A       192.168.10.1
~                                                                              
~                                                   

# named-checkzone tarena.com tarena.com.zone
zone tarena.com/IN: loaded serial 2014030701
OK
# service named restart
停止 named:                                             [确定]
启动 named:                                             [确定]

# nslookup www.tarena.com
Server:         192.168.10.1
Address:      192.168.10.1#53

Name:   www.tarena.com
Address: 192.168.10.1

# nslookup bbs.tarena.com
Server:         192.168.10.1
Address:      192.168.10.1#53

Name:   bbs.tarena.com
Address: 192.168.10.1

# mkdir -p /data/wed/{www,bbs}   //创建一个html程序目录
# cd /data/web/
# ls
bbswww
# vim www/index.html    //写入一个html程序
www.tarena.com
# vim bbs/index.html
bbs.tarena.com

# cd /usr/local/apache2/conf
# ls
extrahttpd.confmagicmime.typesoriginal
# pwd
/usr/local/apache2/conf
# cd extra/
# ls
httpd-autoindex.confhttpd-languages.conf         httpd-ssl.conf
httpd-dav.conf      httpd-manual.conf            httpd-userdir.conf
httpd-default.conf    httpd-mpm.conf               httpd-vhosts.conf
httpd-info.conf       httpd-multilang-errordoc.conf
# vim httpd-vhosts.conf   //进入虚拟主机配置文件
NameVirtualHost *:80


    DocumentRoot "/data/web/www"
    ServerName www.tarena.com
    ErrorLog "logs/dummy-www.tarena.com-error_log"
    CustomLog "logs/dummy-www.tarena.com-access_log" common



    DocumentRoot "/data/web/bbs"   //网站的根路径
    ServerName bbs.tarena.com      //网站名称
    ErrorLog "logs/dummy-bbs.tarena.com-error_log"//网站错误日志路径
    CustomLog "logs/dummy-bbs.tarena.com-access_log" common


# cd ../
# ls
extrahttpd.confmagicmime.typesoriginal
# pwd
/usr/local/apache2/conf
# vim httpd.conf    //http主配置文件
.
.
114 #
115
116   Options FollowSymLinks
117   AllowOverride None
118   Order deny,allow
119   Allow from all
120
121
.
.
163 # DirectoryIndex: sets the file that Apache will serve if a directory
164 # is requested.
165 #
166
167   DirectoryIndex index.html
168
395 # Virtual hosts
396 Include conf/extra/httpd-vhosts.conf//删除前面#

#/usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start
cp /usr/local/apache2/bin/apachect1 /etc/init.d/
cd /etc/init.d/
mv apachect1 apache
head -n 5 apache








页: [1]
查看完整版本: 源码包编译安装Apache搭建虚拟Web主机