以前使用 nginx 可以在浏览器中访问根目录 我现在有个目录，希望开启一个单独的 webServer, 然后可以在浏览器中通过 webServer 来访问，这个目录里的所有文件。 怎么做？ 最好能自动生成目录页面。 还有那位大牛能给一些 Rack 配置文件的资料。 感谢
ruby -run -ehttpd . -p8000
@fsword 谢谢 参数的解释 Obviously, ruby is the normal Ruby interpreter. The -r switch requires a file in the load path, in this case Ruby’s lib directory. In this case, it’s loading a file called un.rb so that it looks like -run when taken as a whole. (It could be written as -r un as well.) This is similar to ubygems.rb which you may have seen as ruby -rubygems. That seems like an ugly solution, but it’s elegant in its own way. This naming hack is only really an option for files in Ruby itself, anyway. As you can see above, httpd is just a method, which is executed by -e. The DocumentRoot argument . is just taken as a standard argument using ARGV, which I found surprising. Finally, the port is set using the setup method, which in turn calls out to the built in OptionParser.
ruby -run -e cp -- [OPTION] SOURCE DEST ruby -run -e ln -- [OPTION] TARGET LINK_NAME ruby -run -e mv -- [OPTION] SOURCE DEST ruby -run -e rm -- [OPTION] FILE ruby -run -e mkdir -- [OPTION] DIRS ruby -run -e rmdir -- [OPTION] DIRS ruby -run -e install -- [OPTION] SOURCE DEST ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE ruby -run -e touch -- [OPTION] FILE ruby -run -e wait_writable -- [OPTION] FILE ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION] ruby -run -e httpd -- [OPTION] DocumentRoot ruby -run -e help [COMMAND] 这个 un.rb 名字起得真怪