开发者

Apache: how to config ip address without SeverName?

I want to set my own sever to run my ruby on rails project(with passenger plugin). I use Apache2 on Ubuntu11.04(sever version).

It's my first time to use Apache and I have read some documen开发者_如何学Pythonts.

All the docs ask me to set SeverName,such as Apache doc and ubuntu docs.

Unfortunately, I don't have a domain name, can I just set IP address and use IP address to access this sever? If it's ok, how should I do?

It's the config sample given by passenger:

<VirtualHost *:80>
   ServerName www.yourhost.com
   DocumentRoot /somewhere/public
   <Directory /somewhere/public>
      AllowOverride all
      Options -MultiViews
   </Directory>
</VirtualHost>

Thanks!


Comment out the line:

# NameVirtualHost *:80

Comment out any <VirtualHost> blocks.

Find the line:

DocumentRoot "/var/www/html" # or whatever your config uses for the overall apache document root.

Change it to your rails application's root.

DocumentRoot "/somewhere/public"

Then add your other config settings to a <Directory> block.

<Directory /somewhere/public>
  AllowOverride all
  Options -MultiViews
</Directory>

I haven't tested this for sure, but you should be able to get to it by only visiting the IP address. Make sure you have Passenger installed, have run passenger-install-apache2-module, and have added the appropriate module loading lines to your apache config.


/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>
  1. In server name:select ur virtual name...u can choose anything
  2. In document root and directory,give your rails project path
  3. Select rails environment in RailsEnv

/etc/hosts

127.0.0.1 example.com

  1. Put server name in virtual host-127.0.0.1 is the localhost

  • Then just go to your browser and type example.com

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜