设为首页 收藏本站
查看: 1292|回复: 0

[经验分享] 源码包编译安装Apache搭建虚拟Web主机

[复制链接]

尚未签到

发表于 2018-11-23 07:52:58 | 显示全部楼层 |阅读模式
安装Apache源码包[h源码包编译安装Apache搭建虚拟Web主机


安装Apache源码包[httpd-2.2.25.tar.gz]根据源码包安装四步骤,先安装gcc工具
挂载光盘安装gcc
1.挂载光盘配置yum库
[root@localhost ~]# cd /misc/cd/Server/
You have new mail in /var/spool/mail/root
[root@localhost Server]# cd /etc/yum.repos.d/
You have new mail in /var/spool/mail/root
[root@localhost yum.repos.d]# ls
rhel-debuginfo.repo
[root@localhost yum.repos.d]# cp rhel-debuginfo.repo rhel-server.repo
[root@localhost yum.repos.d]# ls
rhel-debuginfo.repo  rhel-server.repo
[root@localhost yum.repos.d]# vim rhel-server.repo
[rhel-server]
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

[root@localhost yum.repos.d]# yum -y install gcc*    //安装源码包需要安装gcc
[root@localhost yum.repos.d]# 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
[root@localhost yum.repos.d]# yum list | wc -l               //yum库安装完毕
3347

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

[root@localhost ~]# tar -zxf Desktop/httpd-2.2.25.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
awstats  etc    httpd-2.2.25  lib    libexec  share
bin      games  include       lib64  sbin     src
[root@localhost local]# cd httpd-2.2.25/
You have new mail in /var/spool/mail/root
2.源码包安装

[root@localhost httpd-2.2.25]# ./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

[root@localhost httpd-2.2.25]# echo $?     //测试上一步是否安装成功,如果是0就是对的
0
[root@localhost httpd-2.2.25]# 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[1]: Leaving directory `/usr/local/httpd-2.2.25'

[root@localhost httpd-2.2.25]# echo $?
0
[root@localhost httpd-2.2.25]# 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[1]: Leaving directory `/usr/local/httpd-2.2.25'
You have new mail in /var/spool/mail/root
[root@localhost httpd-2.2.25]# echo $?
0
[root@localhost httpd-2.2.25]# 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.layout  include         modules.lo     VERSIONING
config.log     INSTALL         modules.o
config.nice    InstallBin.dsp  NOTICE
config.status  LAYOUT          NWGNUmakefile

[root@localhost local]# cd apache2/bin/
[root@localhost bin]# ls
ab         apr-1-config  apxs      dbmmanage  envvars-std   htdbm     htpasswd  httxt2dbm   rotatelogs
apachectl  apu-1-config  checkgid  envvars    htcacheclean  htdigest  httpd     logresolve
[root@localhost bin]# pwd
/usr/local/apache2/bin
[root@localhost bin]# /usr/local/apache2/bin/apachectl start    //用绝对路径执行apachect1启动
3.源码包安装成功,开始搭建DNS服务器:
安装bind bind-chroot caching-nameserver软件:
[root@localhost ~]#cd /misc/cd/Server/
[root@localhost 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
[root@localhost Server]# 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
[root@localhost Server]# [root@localhost ~]# cd /var/named/chroot/etc/
You have new mail in /var/spool/mail/root
[root@localhost etc]# ls
localtime                      rndc.key
named.caching-nameserver.conf  named.rfc1912.zones
[root@localhost etc]#cp -p named.caching-nameserver.conf named.conf
[root@localhost etc]# 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

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

[root@localhost etc]# named-checkconf named.conf named.rfc1912.zones
[root@localhost etc]# cd ../var/named/
data              named.broadcast  named.local
localdomain.zone  named.ca         named.zero
localhost.zone    named.ip6.local  slaves
[root@localhost named]# cp -p named.local tarena.com.zone
[root@localhost named]# 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
~                                                                              
~                                                   

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

[root@localhost 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

[root@localhost named]# nslookup bbs.tarena.com
Server:         192.168.10.1
Address:        192.168.10.1#53

Name:   bbs.tarena.com
Address: 192.168.10.1

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

[root@localhost ~]# cd /usr/local/apache2/conf
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# pwd
/usr/local/apache2/conf
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
httpd-autoindex.conf  httpd-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
[root@localhost extra]# 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


[root@localhost extra]# cd ../
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# pwd
/usr/local/apache2/conf
[root@localhost 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//删除前面#

[root@localhost conf]#/usr/local/apache2/bin/apachectl stop
[root@localhost conf]#/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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-638418-1-1.html 上篇帖子: Apache+tomcat结合 下篇帖子: apache 日志切割在centos 和ubuntu中的设置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表