我花了很多时间,只是卡住了:(
应用无法正常运行,日志显示:
根(https://cennik.leczymed.pl)的403禁止错误
2019/02/08 21:46:19 [错误] 4743#4743:禁止* 2目录索引“ / var / www / html / cennik / public /”,客户端:XXX.XXX.XXX.XXX ,服务器:cennik.leczymed.pl,请求:“ GET / HTTP / 2.0”,主机:“ cennik.leczymed.pl”
404
2019/02/08 21:46:25 [错误] 4743#4743:* 2 open()“ / var / www / html / cennik / public / rtg”失败(2:无此类文件或目录),客户端:XXX.XXX.XXX.XXX,服务器:cennik.leczymed.pl,请求:“ GET / rtg HTTP / 2.0”,主机:“ cennik.leczymed.pl”
我的配置:
/etc/nginx/sites-available/cennik.conf
server {
listen 80;
server_name cennik.leczymed.pl;
include snippets/letsencrypt.conf;
return 301 https://cennik.leczymed.pl$request_uri;
}
server {
listen 443 ssl http2;
server_name cennik.leczymed.pl;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/html/cennik/public;
# log files
access_log /var/log/nginx/cennik.leczymed.pl.access.log;
error_log /var/log/nginx/cennik.leczymed.pl.error.log;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /usr/bin/ruby2.5;
ssl_certificate /etc/letsencrypt/live/cennik.leczymed.pl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cennik.leczymed.pl/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/cennik.leczymed.pl/chain.pem;
include snippets/letsencrypt.conf;
include snippets/ssl.conf;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
}
所有应用程序文件都在 / var / www / html / cennik 目录中。
drwxr-xr-x 16 cennik cennik 4096 Feb 8 20:53 .
drwxr-xr-x 6 root root 4096 Feb 8 14:23 ..
drwxrwxr-x 10 cennik cennik 4096 Jul 27 2018 app
drwxr-xr-x 2 cennik cennik 4096 Jul 27 2018 bin
drwxr-xr-x 2 cennik cennik 4096 Feb 8 20:33 .bundle
drwx------ 5 cennik cennik 4096 Feb 8 20:48 config
-rw-rw-r-- 1 cennik cennik 130 Jul 27 2018 config.ru
drwx------ 2 cennik cennik 4096 Jul 27 2018 db
-rw-rw-r-- 1 cennik cennik 2371 Feb 8 19:58 Gemfile
-rw-r--r-- 1 cennik cennik 5544 Feb 8 20:42 Gemfile.lock
drwxrwxr-x 7 cennik cennik 4096 Feb 8 19:47 .git
-rw-rw-r-- 1 cennik cennik 687 Feb 8 19:47 .gitignore
drwxrwxr-x 4 cennik cennik 4096 Jul 27 2018 lib
drwxrwxr-x 2 cennik cennik 4096 Feb 8 20:53 log
drwxr-xr-x 2 cennik cennik 4096 Feb 8 20:53 node_modules
-rw-rw-r-- 1 cennik cennik 64 Jul 27 2018 package.json
drwxrwxrwx 3 cennik cennik 4096 Feb 8 20:54 public
-rw-rw-r-- 1 cennik cennik 227 Jul 27 2018 Rakefile
-rw-rw-r-- 1 cennik cennik 5 Jul 27 2018 .ruby-version
drwxrwxr-x 2 cennik cennik 4096 Jul 27 2018 storage
drwxrwxr-x 9 cennik cennik 4096 Jul 27 2018 test
drwxrwxr-x 6 cennik cennik 4096 Jul 27 2018 tmp
drwxrwxr-x 3 cennik cennik 4096 Feb 8 20:33 vendor
-rw-r--r-- 1 cennik cennik 86 Feb 8 20:53 yarn.lock
所有文件和目录的所有者均为 cennik 用户(如配方中所述)。
Rop应用程序中的目录 / public 具有所有特权(chmod 777)。
有什么想法的人吗?
++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++
更新:
passenger-config --ruby-command
passenger-config was invoked through the following Ruby interpreter:
Command: /usr/bin/ruby2.5
Version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
To use in Apache: PassengerRuby /usr/bin/ruby2.5
To use in Nginx : passenger_ruby /usr/bin/ruby2.5
To use with Standalone: /usr/bin/ruby2.5 /var/lib/gems/2.5.0/gems/passenger-6.0.1/bin/passenger start
The following Ruby interpreter was found first in $PATH:
Command: /home/artur/.rbenv/shims/ruby
Version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
To use in Apache: PassengerRuby /home/artur/.rbenv/shims/ruby
To use in Nginx : passenger_ruby /home/artur/.rbenv/shims/ruby
To use with Standalone: /home/artur/.rbenv/shims/ruby /var/lib/gems/2.5.0/gems/passenger-6.0.1/bin/passenger start
所以,我认为nginx配置 cennik.conf 声明了ruby目录的正确位置: /usr/bin/ruby2.5
还有其他解决方法吗?
************************更新********************** *********
好的。因此,我发现很少有可以帮助他人的事情。我的问题仅适用于从先前版本升级到18.04的Ubuntu。安装nginx不会覆盖nginx的conf(可以手动解决)。更大的问题是为Ubuntu 18.04提供的nginx软件包没有使用乘客支持进行编译。 因此,我现在正在寻找一种解决方案,该方法如何在其中编译带有乘客模块的nginx并仍将其用于我的systemctl函数-从源代码安装可以正常工作,但是您不能将其作为服务使用:(
我发现一些special receipe可以使Ubuntu软件包与编译过程中的更改相兼容,但是我为乘客提供正确附件的任何尝试都失败了。
有人可以帮助我吗?
答案 0 :(得分:2)
我将乘客添加到nginx中,此处乘客库的描述方式
看起来像尚未配置的“乘客”。当您使用RVM时,应该在另一个位置放置ruby可执行文件。要获取ruby路径,请转到应用程序根目录并运行以下命令并替换passenger_ruby
指令。
> cd /var/www/html/cennik
> passenger-config --ruby-command
# It shows output like this
passenger-config was invoked through the following Ruby interpreter:
Command: /home/deploy/.rvm/gems/ruby-2.3.5/wrappers/ruby
Version: ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
To use in Apache: PassengerRuby /home/deploy/.rvm/gems/ruby-2.3.5/wrappers/ruby
To use in Nginx : passenger_ruby /home/deploy/.rvm/gems/ruby-2.3.5/wrappers/ruby
To use with Standalone: /home/deploy/.rvm/gems/ruby-2.3.5/wrappers/ruby /usr/bin/passenger start
RoR应用程序中的目录/ public具有所有特权(chmod 777)。
制作公共目录可执行文件不是一个好主意。它可能包含用户上传的文件。只需将权限设置为755,并授予运行nginx(www-data)的用户或组权限即可。