Why do I have to restart apache to properly refresh a Ruby on Rails view in the browser?

浪尽此生 提交于 2019-12-02 08:17:24

Apache's a perfectly good choice for development.

Just install Passenger (mod_rails)...and follow the instructions...

I set it up for each site so that /etc/hosts contains

127.0.0.1 myapp

I use Apache virtual hosts with an entry like so - in /etc/apache2/sites-available/myapp

<VirtualHost *:80>
  ServerName myapp
  DocumentRoot /path/to/myapp/public
  RailsEnv development
  RailsAllowModRewrite off
    <directory "/path/to/myapp/public">
      Order allow,deny
      Allow from all
    </directory>
</VirtualHost>

Enable and restart

sudo a2ensite myapp
sudo /etc/init.d/apache2 restart

That way, there's no running script/server ... it's just always running in dev mode - just point your browser to http://myapp

Don't use apache for development mode. Use script/server and install the mongrel gem (sudo gem install mongrel). Mongrel is faster than WEBrick and dumps the development log to the console in which it runs. It makes development decent.

Apache is not a good choice for development in cases like Rails, because you will indeed need to restart the server every time you change code. Rails ships with its own development server that you can start by executing (IIRC) script/server. It's much more suitable for development, as it needn't be restarted after every little change.

I'm using Apache with Passenger (aka modrails) for development purposes, and it works fine here. Just make sure to use Rails in development mode by setting "RailsEnv development" in your httpd.conf.

I use Apache with mod_fcgid. I found that going

$ touch ${MYAPP}/tmp/restart.txt

every time I want the app reloaded works for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!