Ruby on rails Apache:如何在没有服务器名的情况下配置ip地址?
我想设置自己的服务器来运行RubyonRails项目(带有乘客插件)。我在Ubuntu11.04(服务器版本)上使用Apache2 这是我第一次使用Apache,我已经阅读了一些文档 所有文档都要求我设置服务器名,例如和 不幸的是,我没有域名,我可以设置IP地址并使用IP地址访问此服务器吗? 如果可以的话,我该怎么办 这是乘客给出的配置示例:Ruby on rails Apache:如何在没有服务器名的情况下配置ip地址?,ruby-on-rails,apache,ip,passenger,ubuntu-11.04,Ruby On Rails,Apache,Ip,Passenger,Ubuntu 11.04,我想设置自己的服务器来运行RubyonRails项目(带有乘客插件)。我在Ubuntu11.04(服务器版本)上使用Apache2 这是我第一次使用Apache,我已经阅读了一些文档 所有文档都要求我设置服务器名,例如和 不幸的是,我没有域名,我可以设置IP地址并使用IP地址访问此服务器吗? 如果可以的话,我该怎么办 这是乘客给出的配置示例: <VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /some
<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public
<Directory /somewhere/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
服务器名www.yourhost.com
DocumentRoot/某处/公共
允许超越所有
选项-多视图
谢谢 /etc/apache2/httpd.conf
<VirtualHost *:80>
ServerName example.com
DocumentRoot /home/urpc-name/RailsApps/anything/public
<Directory /home/webonise/RailsApps/anything/public>
RailsEnv development
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
ServerName example.com
DocumentRoot/home/urpc name/RailsApps/anything/public
RailsEnv开发
允许超越所有
选项-多视图
- 然后只需转到浏览器并键入example.com
# NameVirtualHost *:80
DocumentRoot "/var/www/html" # or whatever your config uses for the overall apache document root.
注释掉所有
块
查找行:
# NameVirtualHost *:80
DocumentRoot "/var/www/html" # or whatever your config uses for the overall apache document root.
将其更改为rails应用程序的根目录
DocumentRoot "/somewhere/public"
然后将其他配置设置添加到
块中
<Directory /somewhere/public>
AllowOverride all
Options -MultiViews
</Directory>
允许超越所有
选项-多视图
我还没有测试过这个,但你应该能够得到它只访问IP地址。确保已安装Passenger,已运行
Passenger-install-apache2-module
,并已将适当的模块加载行添加到apache配置中。这是一个仅在LAN上访问的网络服务器,还是您正试图从internet访问它?如果服务器上只有一个站点/应用程序,则无需进行基于名称的虚拟托管,并且从IP地址为应用程序提供服务将很容易。但是,如果服务器将为其他站点/应用程序提供服务,则更难让服务器识别IP地址仅用于该应用程序。但最终,无论您是在局域网上使用它,还是在互联网上使用它,设置服务器名都要容易得多。域名注册很便宜。我想在互联网上使用它。。。。有没有在互联网上使用IP地址的解决方案?无论如何,谢谢你的建议!谢谢你的建议!然而,我认为它只能在本地机器上工作,对吗?我想让它可以在互联网上访问。有什么建议吗?