在 Ubuntu 12.04 上安装 Yaws 服务器(使用云服务)

Lee*_*res 5 server amazon-ec2

我正在尝试让 Yaws Web 服务器在云服务 (Amazon AWS) 上运行。我已经在服务器上编译并安装了一个本地副本。我的问题是在端口 8000 或端口 80 上运行时,我无法让 Yaws 运行。

我在 yaws.conf 中有以下配置:

port = 8000
listen = 0.0.0.0
docroot = /home/ubuntu/yaws/www/test
dir_listings = true
Run Code Online (Sandbox Code Playgroud)

这会产生以下成功的启动/结果:

Eshell V5.8.5 (abort with ^G)

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Using config file /home/ubuntu/yaws.conf

=INFO REPORT==== 16-Sep-2012::17:21:06 === Ctlfile : /home/ubuntu/.yaws/yaws/default/CTL

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Listening to 0.0.0.0:8000 for <3> virtual servers: - http://domU-12-31-39-0B-1A-F6:8000 under /home/ubuntu/yaws/www/trial -

=INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Listening to 0.0.0.0:4443 for <1> virtual servers: -
Run Code Online (Sandbox Code Playgroud)

当我尝试访问 url (http://ec2-72-44-47-235.compute-1.amazonaws.com) 时,它永远无法连接。我曾尝试使用 paping 检查端口 80 或 8000 是否打开(http://code.google.com/p/paping/),但出现“无法解析主机”错误,因此显然某些内容不是在职的。

我还尝试将 yaws.conf 设置为端口 80,如下所示:

port = 8000
listen = 0.0.0.0
docroot = /home/ubuntu/yaws/www/test
dir_listings = true
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

=ERROR REPORT==== 16-Sep-2012::17:24:47 === Yaws: Failed to listen 0.0.0.0:80 : {error,eacces}

=ERROR REPORT==== 16-Sep-2012::17:24:47 === Can't listen to socket: {error,eacces}         
=ERROR REPORT==== 16-Sep-2012::17:24:47 === Top proc died, terminate gserv =ERROR REPORT==== 16-Sep-2012::17:24:47 === Top proc died, terminate gserv =INFO REPORT==== 16-Sep-2012::17:24:47 === application: yaws exited: {shutdown,{yaws_app,start,[normal,[]]}} type: permanent {"Kernel pid terminated",application_controller," {application_start_failure,yaws,>>>>>>{shutdown,>{yaws_app,start,[normal,[]]}}}"}
Run Code Online (Sandbox Code Playgroud)

我还使用 iptables 打开了端口 80。运行 sudo iptables -L 给出以下输出:

Chain INPUT (policy ACCEPT) target prot opt source destination
ACCEPT tcp -- ip-192-168-2-0.ec2.internal ip-192-168-2-16.ec2.internal tcp dpt:http      
ACCEPT tcp -- 0.0.0.0 anywhere tcp dpt:http ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT tcp -- anywhere anywhere tcp dpt:http

Chain FORWARD (policy ACCEPT) target prot opt source destination

Chain OUTPUT (policy ACCEPT) target prot opt source destination
Run Code Online (Sandbox Code Playgroud)

另外,我去了亚马逊AWS配置区的安全组面板,将80、8000、8080端口添加到ip source 0.0.0.0

请注意:如果您现在尝试访问虚拟服务器的 URL,它可能无法连接,因为我当前没有运行 yaws 守护程序。当我通过 yaws 或 yaws -i 运行 yaws 时,我已经对其进行了测试

谢谢你的耐心

Eli*_*gan 2

克莱夫·范·希尔滕 (Clive van Hilten)发表了一条评论,该评论提供了该问题的最佳可用答案。他说的(稍作修改)是:

我对雅司病一无所知,但阅读上面的输出我注意到以下几点:

  1. 您的文档根目录是Eshell 报告:/home/ubuntu/yaws/www/test

    =INFO REPORT==== 16-Sep-2012::17:21:06 === Yaws: Listening to 0.0.0.0:8000 for <3> virtual servers: - http://domU-12-31-39-0B-1A-F6:8000 under /home/ubuntu/yaws/www/trial -
    
    Run Code Online (Sandbox Code Playgroud)

    请注意test您的docroottrialEshell 输出中的 。

  2. 您声明“我还使用 iptables 打开了端口 80 ”。但你的端口号yaws.conf8000,不是80

看来解决这些差异可能会很好地解决问题。