lighttpd 使用虚拟主机出现错误求大神解

系统环境:CentOS 6.9 64 bit 两台
主机地址分别为:
192.168.200.101 (安装lighttpd+虚拟主机)
192.168.200.102 (客户端)
虚拟主机:单个服务器上托管多个域名的实现,简单理解 单个IP对应多个域名

具体操作步骤
官方下载lighttpd软件

http://www.lighttpd.net

上传到linux主机中,本次使用的是lighttpd-1.4.41.tar.gz版本

/etc/init.d/iptables stop
setenforce 0

tar -xf lighttpd-1.4.41.tar.gz
cd lighttpd-1.4.50/
./configure --prefix=/usr/local/ lighttpd

configure: error: pcre-config not found, install the pcre-devel package
提示这个错误安装pcre-devel解决
yum -y install pcre-devel

make && make install
cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
mkdir /etc/lighttpd
cp doc/config/lighttpd.conf /etc/lighttpd/lighttpd.conf
cp -R doc/config/conf.d/ doc/config/*.conf doc/config/vhosts.d/ /etc/lighttpd/
cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
chmod +x /etc/init.d/lighttpd
vim /etc/init.d/lighttpd
29 lighttpd="/usr/local/lighttpd/sbin/lighttpd"

groupadd lighttpd
useradd -M -s /sbin/nologin -g lighttpd lighttpd
vim /etc/lighttpd/lighttpd.conf
16 var.log_root = "/var/log/lighttpd"
17 var.server_root = "/srv/www"
18 var.state_dir = "/var/run"
19 var.home_dir = "/var/lib/lighttpd"
20 var.conf_dir = "/etc/lighttpd"server.use-ipv4 = "enable"
115 server.document-root = "/lighttpd/html"

mkdir –p /var/log/lighttpd /srv/www /var/run /var/lib/lighttpd /etc/lighttpd /lighttpd/html
chown lighttpd:lighttpd /var/log/lighttpd /srv/www /var/run /var/lib/lighttpd /etc/lighttpd /lighttpd/html

echo "1111111111111" > /lighttpd/html/index.html
/etc/init.d/lighttpd start

客户机测试
Curl http://192.168.200.101

基于域名的虚拟主机
vim /etc/lighttpd/lighttpd.com
467 $HTTP["host"] == "www.benet.com" {
468 server.name = "www.benet.com"
469 server.document-root = "/www/vhosts/www.benet.com"
470 server.errorlog = "/www/vhosts/www.benet.com/error.log"
471 accesslog.filename = "/www/vhosts/www.benet.com/access.log"
472 }
473 $HTTP["host"] == "ftp.accp.com" {
474 server.name = "ftp.accp.com"
475 server.document-root = "/www/vhosts/ftp.accp.com"
476 server.errorlog = "/www/vhosts/ftp.accp.com/error.log"
477 accesslog.filename = "/www/vhosts/ftp.accp.com/access.log"
478 }

mkdir -p /www/vhosts/www.benet.com /www/vhosts/ftp.accp.com
chown lighttpd:lighttpd /www/vhosts/www.benet.com
chown lighttpd:lighttpd /www/vhosts/ftp.accp.com
echo www.benet..com > /www/vhosts/benet.com/index.html
echo "www.accp.com" > /www/vhosts/ftp.accp.com/index.html
service lighttpd restart

使用客户端
vim /etc/hosts
192.168.200.101 www.benet.com
192.168.200.101 ftp.accp.com
curl http://www.benet.com
curl http://ftp.accp.com

基于端口虚拟主机
vim /etc/lighttpd/lighttpd.com
$SERVER["socket"] == "192.168.200.101:8080" {
server.document-root = "/var/www/aaa/"
server.errorlog = "/var/log/lighttpd/aaa-error.log"
accesslog.filename = "/var/log/lighttpd/aaa-access.log"
}

mkdir /var/www/aaa
chown lighttpd:lighttpd /var/www/aaa
echo "www.aaa.com" > /var/www/aaa/index.html

Service lighttpd restart
lighttpd 使用虚拟主机出现错误求大神解

我的问题在这里 ,知道是哪里配置错了

访问的时候是没有问题的
使用客户机访问
curl http://192.168.200.101:8080
curl -I http://192.168.200.101:8080
HTTP/1.1 200 OK
Content-Type: text/html
Accept-Ranges: bytes
ETag: "2966177319"
Last-Modified: Tue, 14 Aug 2018 19:21:02 GMT
Content-Length: 12
Date: Tue, 14 Aug 2018 19:27:01 GMT
Server: lighttpd/1.4.41

转载于:https://blog.51cto.com/13929859/2161591

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值