[英]start rails server automatically after reboot
I'd like my rails server to start automatically after every reboot, so I added the following to my .bashrc file 我希望我的rails服务器在每次重启后自动启动,所以我将以下内容添加到我的.bashrc文件中
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. 因此,我需要在每次重启后使用“gem install sqlite3”安装sqlite3后我自己做超级用户,然后才能启动rails服务器而不会出现问题。
$ 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 谢谢
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
. 我在CentOS 6上使用Rails 4,Ruby 2.1也遇到了同样的问题。如果你不熟悉bash脚本和rc,profile系统 - 设置passenger
速度和速度都快得多。
Also, there are other reasons why you would go for passenger, including security and performance ( www.phusionpassenger.com ) 此外,还有其他原因可供您选择乘客,包括安全和性能 (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): 安装Apache(html守护程序)和依赖包(如果你还没有):
yum install httpd curl-devel httpd-devel yum install httpd curl-devel httpd-devel
Get Apache to start on boot: 让Apache开始启动:
chkconfig httpd on chkconfig httpd on
Install Phusion Passenger and dependency packages: 安装Phusion Passenger和依赖包:
gem install passenger 宝石安装乘客
yum install curl-devel httpd-devel yum install curl-devel httpd-devel
Compile the environment: 编译环境:
passenger-install-apache2-module 乘客安装-Apache2的模块
Edit the Apache config file in etc/httpd/conf/httpd.conf 编辑etc / httpd / conf / httpd.conf中的Apache配置文件
Uncomment the line containing NameVirtualHost *:80
towards the end 取消注释包含NameVirtualHost *:80
到最后
Paste the output from point 4) anywhere at the end of the file, eg: 将点4)的输出粘贴到文件末尾的任何位置,例如:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so 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 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 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. 总共花了30分钟,包括httpd.conf的几次试错,以确保一切正常。
Note that installation requires at least 1 GB RAM on your machine. 请注意,安装需要至少1 GB的RAM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.