重启后自动启动服务器导轨 [英] start rails server automatically after reboot
问题描述
我想我的rails服务器每次重新启动后自动启动,所以我增加了以下到我的.bashrc文件
RVM 1.9.2使用
CD /家庭/用户/的myapp
轨道服务器
就这样,服务器不会自动重新启动后开始,我必须手动启动它。
此外,当我登录到启动服务器,我看到以下消息
使用/usr/local/rvm/gems/ruby-1.9.2-p290
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby:符号查找错误:/usr/local/rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/ LIB / sqlite3的/ sqlite3_native.so:未定义的符号:sqlite3_initialize
因此,我需要使用宝石安装sqlite3的后,我让自己超级用户每次重新启动后安装sqlite3的,也只有这样我就可以开始Rails服务器没有问题。
$猫的/ etc / * - 释放
CentOS版本5.8(决赛)$轨-v
3.1.1的Rails$红宝石-v
红宝石1.9.2p290(2011-07-09改版32553)的i686-linux下]
任何人都可以请帮我解决这个问题?谢谢
安装Apache和乘客
他们将在一个更安全和更系统的方式在服务器启动你的App照顾,什么是现在或多或少的标准。
我不得不使用Rails 4和Ruby 2.1同样的问题在CentOS 6.如果你不熟悉的bash脚本和RC,型材系统 - 它的速度更快,更容易安装乘客
。
另外,还有一些其他的原因,你会去的乘客,包括安全和性能(www.phusionpassenger.com)
下面是一个快速如何做的什么了我介绍的宝石。
-
安装Apache(HTML守护进程)和依赖包(如果没有他们的话):
百胜安装的httpd卷曲DEVEL的httpd-DEVEL
块引用> -
获得Apache在引导时启动:
chkconfig的httpd的上
块引用> -
安装的Phusion乘客和依赖包:
创业板安装客运结果
百胜安装卷曲DEVEL的httpd-DEVEL
块引用> -
编译环境:
乘客安装-Apache2的模块
块引用> -
编辑等在Apache的配置文件/的httpd / conf目录/ httpd.conf文件
-
取消注释包含行
了NameVirtualHost *:80
接近尾声 -
在文件的结尾粘贴的任何地方,从4点输出),例如:
的LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
<虚拟主机*:80>
服务器名称1.2.3.4#www.whatever.com
的DocumentRoot的/ var / WWW /导轨/公共#的路径Rails应用程序
<目录/ var / WWW /导轨/公共>
所有的AllowOverride
选项-MultiViews
< /目录>
< /虚拟主机>
块引用> -
我花了30分钟,共有包括与httpd.conf中得到的一切权利几个试的错误。
请注意,安装需要你的机器上至少有1 GB RAM。
I'd like my rails server to start automatically after every reboot, so I added the following to my .bashrc file
rvm use 1.9.2
cd /home/user/myapp
rails server
With that, the server never starts automatically after a reboot, and I have to start it manually.
Also, when I login to start the server, I see the following message
Using /usr/local/rvm/gems/ruby-1.9.2-p290
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby: symbol lookup error: /usr/local/rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_initialize
As a consequence, I need to install sqlite3 after every reboot using "gem install sqlite3" after I make myself superuser, and only then I can start the rails server without issues.
$ cat /etc/*-release
CentOS release 5.8 (Final)
$ rails -v
Rails 3.1.1
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Anyone can please help me overcome this issue? Thanks
Install Apache and Passenger
They will take care of starting your App with the server in a safer and more systematic way and what is now more or less a standard.
I had the same issue with Rails 4, Ruby 2.1 on CentOS 6. If you're not familiar with bash scripts and the rc, profiles system - it's much faster and easier to setup passenger
.
Also, there are other reasons why you would go for passenger, including security and performance ( www.phusionpassenger.com )
Here is a quick how-to of what it took me to introduce the gem.
Install Apache (html daemon) and dependency packages (if you don't have them already):
yum install httpd curl-devel httpd-devel
Get Apache to start on boot:
chkconfig httpd on
Install Phusion Passenger and dependency packages:
gem install passenger
yum install curl-devel httpd-develCompile the environment:
passenger-install-apache2-module
Edit the Apache config file in etc/httpd/conf/httpd.conf
Uncomment the line containing
NameVirtualHost *:80
towards the endPaste the output from point 4) anywhere at the end of the file, eg:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
<VirtualHost *:80> ServerName 1.2.3.4 # www.whatever.com DocumentRoot /var/www/rails/public # the path to your rails app <Directory /var/www/rails/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
Took me 30 minutes in total, including several trial-errors with the httpd.conf to get everything right.
Note that installation requires at least 1 GB RAM on your machine.
这篇关于重启后自动启动服务器导轨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!