Nginx: Please reinstall Phusion Passenger or fix your ‘passenger_root’ directive

Please edit your Nginx configuration file (probably /opt/nginx/conf/nginx.conf),
and set the passenger_root and passenger_ruby configuration options in the
‘http’ block, like this:

  http {
      …
      passenger_root /usr/local/rvm/gems/ruby-2.1.5@rails4.1.8/gems/passenger-4.0.53;
      passenger_ruby /usr/local/rvm/gems/ruby-2.1.5@rails4.1.8/wrappers/ruby;
      …
  }

Rails gem安装速度太慢

由于国内网络原因(你懂的),导致 rubygems.org 存放在 Amazon S3 上面的资源文件间歇性连接失败。所以你会与遇到 gem install rack 或 bundle install 的时候半天没有响应,具体可以用 gem install rails -V 来查看执行过程。

HOW?

  1. $ gem sources --remove https://rubygems.org/
  2. $ gem sources -a http://ruby.taobao.org/
  3. $ gem sources -l
  4. *** CURRENT SOURCES ***
  5. http://ruby.taobao.org
  6. # 请确保只有 ruby.taobao.org
  7. $ gem install rails

如果是用 Bundle (Rails 项目)

  1. $ vi Gemfile
  2. source 'http://ruby.taobao.org/'
  3. gem 'rails', '3.2.12'
  4. ...

RVM 改用淘宝下载源, 提高 Ruby 安装速度

FOR MAC

  1. $ sed -i .bak 's!ftp.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db

FOR LINUX

  1. $ sed -i 's!ftp.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db




Rails升级到4.0

$ gem update --system
$ gem update
$ gem install nokogiri
$ gem install rails
$ rails -v


1
$ rvm get head

1
2
3
4
$ rvm upgrade 2.0.0
Are you sure you wish to upgrade from ruby-2.0.0-p0 to ruby-2.0.0-p195? (Y/n): y
Installing new ruby ruby-2.0.0-p195
Searching for binary rubies, this might take some time.

Can’t connect to MySQL server on (61)

1. 检查3306端口是否开放。

netstat -an | grep 3306
结果:
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN

从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。

第二步:修改配置文件

修改文件 /etc/mysql/my.cnf文件
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address  = 127.0.0.1
把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。

第三步:

使用创建的用户登录一下,成功。



Nginx 500 Internal Server Error

1. 查看Nginx日志。

/opt/nginx/logs/error.log

2. 根据发生错误的时间,查询得到错误明细。
2014/11/20 11:04:48 [alert] 18697#0: *1 Cannot stat ‘/root/testapp/config.ru; This error means that the Nginx worker process (PID 18697, running as UID 65534) does not have permission to access this file. Please read the manual to learn how to fix this problem: section ‘Troubleshooting’ -> ‘Upon accessing the web app, Nginx reports a “Permission denied” error'; Extra info, client: 209.239.123.82, server: www.productgaga.com, request: “GET / HTTP/1.1″, host: “www.productgaga.com”

3. 查看运行Nginx的用户。

可以看到,用户是nobody.
root@iZ23d4xlsbjZ:~# ps -ef|grep nginx
root     18693     1  0 11:04 ?        00:00:00 nginx: master process /usr/sbin/nginx
nobody   18694 18693  0 11:04 ?        00:00:00 nginx: worker process
nobody   18695 18693  0 11:04 ?        00:00:00 nginx: worker process
nobody   18696 18693  0 11:04 ?        00:00:00 nginx: worker process
nobody   18697 18693  0 11:04 ?        00:00:00 nginx: worker process
nobody   18698 18693  0 11:04 ?        00:00:00 nginx: worker process
nobody   18699 18693  0 11:04 ?        00:00:00 nginx: worker process
root     19159 18019  0 11:18 pts/0    00:00:00 grep –color=auto nginx
4. 解决方案。

You need to relax permissions to that the Nginx worker process can access your application directory, by making the directory group- and world-executable:

sudo chmod g+x,o+x /root/pgg

You also need to ensure that all parent directories are also executable by the Nginx process:

sudo chmod g+x,o+x /root