yxsailing 发表于 2017-1-6 10:22:20

Fedora8中Apache服务的配置

开放源代码的Apache(阿帕奇)服务器起初由Illinois大学Urbana-Champaign的国家高级计算程序中心开发,后来Apache被开放源代码团体的成员不断地发展和加强。开始时,Apache只是Netscape网页服务器(现在是Sun ONE)的之外的开放源代码选择。渐渐地,它开始在功能和速度上超越其他Web服务器。由于Apache服务器拥有牢靠可信的美誉,因此从1995年1月以来,Apache一直是Internet上最流行的Web服务器。
/etc/httpd/conf/httpd.conf文件:
1. 全局环境设置 2.主要的服务器设置 3.虚拟主机 三部分
### Section 1: Global Environment
1.设置相对根目录的路径
ServerRoot "/etc/httpd"
2.设置Apache监听的IP地址和端口号
Listen 80
### Section 2: 'Main' server configuration
3.设置网络管理员的E—mail地址
ServerAdmin adminMail@163.com
4.设置服务器主机名称
ServerName 192.168.1.6:80
5.设置主目录的路径
DocumentRoot "/var/www/html"
6设置默认文档
DirectoryIndex index.html index.html.var index.htm
7设置日志文件
(1)ErrorLog logs/error_log
(2)CustomLog logs/access_log combined
8.设置默认字符集
AddDefaultCharset UTF-8
一、 安装
# rpm -q httpd-2.2.6-3.i386
httpd-2.2.6-3
# cd /etc/httpd/conf
# ls
httpd.confmagic
***************************************************************
二、 配置没有虚拟主机的
# cd /var/www/html/
建立index.html
index.html内容
# more index.htm
<head>
      <title>www.jw.com</title>
</head>
<body>
www.jiwei.com
www.jiwei.com
</body>
******************************************
修改httpd.conf
# cd /etc/httpd/conf
# vi httpd.conf
Listen 80
#ServerName www.example.com:80
ServerName www.jw.com:80
DocumentRoot "/var/www/html"
DirectoryIndex index.html index.html.var index.htm
# /etc/rc.d/init.d/named start
启动 named:                                             [确定]
# /etc/rc.d/init.d/httpd restart
停止 httpd:                                             [失败]
启动 httpd:                                             [确定]
**************************************************
三、 建立虚拟主机所用Web页面
建立/var/www/wwwjwcom/index.htm
<head>
      <title>wwwjwcom<title>
</head>
<body>
wwwjwcomwwwjwcomwwwjwcomwwwjwcom wwwjwcom wwwjwcom
</body>
******************
建立/var/www/bbs/index.htm
<head>
      <title>bbs/title>
</head>
<body>
bbs bbsbbsbbsbbsbbsbbsbbsbbsbbsbbsbbs
</body>
******************
建立/var/www/blog/index.htm
<head>
      <title>blog</title>
</head>
<body>
blogblogblog   blogblogblogblog blog
</body>
******************************************************************
四、 多主机头
***********
NameVirtualHost 192.168.1.6:80      注:修改
<VirtualHost 192.168.1.6:80>      注:修改
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/wwwjwcom/   注:修改
    ServerName www.jw.com      注:修改
   ErrorLog logs/dummy-host.example.com-error_log
   CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost bbs.jw.com:80>      注:修改
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/bbs      注:修改
    ServerName bbs.jw.com      注:修改
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost blog.jw.com:80>   注:修改
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/blog   注:修改
    ServerName blog.jw.com      注:修改
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
*********************************************************************
五、 多IP地址
********
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth1
IPADDR=192.168.1.6
修改:
IPADDR=192.168.1.8
# /etc/rc.d/init.d/network restart
正在关闭接口 eth0:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0:                                          [确定]
弹出界面 eth1:                                          [确定]
NameVirtualHost 192.168.1.6:80
<VirtualHost 192.168.1.6:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/wwwjwcom/注:修改
    ServerName www.jw.com注:修改
   ErrorLog logs/dummy-host.example.com-error_log
   CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 192.168.1.8:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/bbs/注:修改
    ServerName bbs.jw.com注:修改
   ErrorLog logs/dummy-host.example.com-error_log
   CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
六、 重新启动
# /etc/rc.d/init.d/httpd restart
停止 httpd:                                             [确定]
启动 httpd:                                             [确定]
页: [1]
查看完整版本: Fedora8中Apache服务的配置