第一次尝试使用rails部署应用程序 - 我正在尝试运行一个rails应用程序,目前正在给我403.我正在使用ubuntu和nginx。我有两个服务器块设置,我首先使用节点应用程序测试运行正常,现在一个域运行正常作为节点应用程序,但我正在尝试设置另一个作为一个轨道应用程序,给予403。
我使用了这两个教程的组合:
我尝试在755
目录和/home/deploy
中设置/var/www/
permision,但没有运气。
其他猜测 -
index index.html index.htm
?default_server deferred;
有关(虽然我尝试删除但没有影响)以下是我的相关文件,可能有问题,请告诉我其他人是否有帮助 -
rails app,有问题:/etc/nginx/sites-enabled/centers
server {
listen 80;
listen [::]:80;
root /home/deploy/apps/mll/current/public;
index index.html index.htm;
server_name myrailssite.com;
location / {
try_files $uri $uri/ =404;
}
}
节点应用,按照/etc/nginx/sites-enabled/nodeapp
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/nodeapp/html;
index index.html index.htm;
server_name 162.243.199.170;
location / {
try_files $uri $uri/ =404;
}
}
nginx.conf
upstream puma {
server unix:///home/deploy/apps/mll/shared/tmp/sockets/mll-puma.sock;
}
server {
listen 80 default_server deferred;
server_name myrailssite.com;
root /home/deploy/apps/mll/current/public;
access_log /home/deploy/apps/mll/current/log/nginx.access.log;
error_log /home/deploy/apps/mll/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://mll-puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
权限:
deploy@banana:/usr/bin$ namei -l /var/www/centers/
f: /var/www/centers/
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxrwxr-x root root centers
deploy@banana:/usr/bin$ namei -l /home/deploy/apps/mll/current/public/
f: /home/deploy/apps/mll/current/public/
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x deploy deploy deploy
drwxr-xr-x deploy deploy apps
drwxr-xr-x deploy deploy mll
lrwxrwxrwx deploy deploy current -> /home/deploy/apps/mll/releases/20160415005003
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x deploy deploy deploy
drwxr-xr-x deploy deploy apps
drwxr-xr-x deploy deploy mll
drwxr-xr-x deploy deploy releases
drwxrwxr-x deploy deploy 20160415005003
drwxrwxr-x deploy deploy public
答案 0 :(得分:0)
我的应用程序https://www.wiki11.com也遇到了同样的问题。
您的问题即将发生,因为nginx正在尝试将index.html
文件搜索到/home/deploy/apps/mll/current/public
,但该文件中没有该文件。
为了解决这个问题,您需要使用nginx添加乘客。
要遵循的说明。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
添加Passenger APT存储库
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
安装passenger和nginx
sudo apt-get install -y nginx-extras passenger
现在启动nginx webserver。
sudo service nginx start
接下来,我们需要更新Nginx配置,将Passenger指向我们正在使用的Ruby版本。
sudo vim /etc/nginx/nginx.conf
添加或取消注释
include /etc/nginx/passenger.conf;
保存并关闭nginx.conf。然后打开/etc/nginx/passenger.conf
sudo vim /etc/nginx/passenger.conf
如果您使用的是.rbenv,那么
passenger_ruby /home/deploy/.rbenv/shims/ruby;
或者如果您使用的是rvm,那么
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.5.0/ruby;
或者,如果您使用的是系统红宝石,那么
passenger_ruby /usr/bin/ruby;
接下来,重启nginx服务器
sudo service nginx restart
将passenger_enabled on;
添加到已启用网站的中心或已启用网站的/ nodeapp文件中。
server {
listen 80;
listen [::]:80;
root /home/deploy/apps/mll/current/public;
index index.html index.htm;
server_name myrailssite.com;
passenger_enabled on;
location / {
try_files $uri $uri/ =404;
}
}
再次重新启动nginx服务器sudo service nginx restart
。希望它应该有用。
有关详细信息,请关注, https://www.phusionpassenger.com/library/install/nginx/install/oss/xenial/