gpt4 book ai didi

ruby-on-rails-4 - 权限被拒绝 @ rb_sysopen - 日志/application.log (Errno::EACCES)

转载 作者:行者123 更新时间:2023-12-02 20:21:09 25 4
gpt4 key购买 nike

您好,我正在使用 docker 使用 phusion/passenger 图像部署我的 Rails 应用程序。这是我的 Dockerfile:

FROM phusion/passenger-ruby22:0.9.19

# set correct environment variables
ENV HOME /root
ENV RAILS_ENV production

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# Expose Nginx HTTP service
EXPOSE 80

# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down

# Remove the default site
RUN rm /etc/nginx/sites-enabled/default

# Add the nginx site and config
ADD nginx.conf /etc/nginx/sites-enabled/nginx.conf
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf

# Let ensure these packages are already installed
# otherwise install them anyways
RUN apt-get update && apt-get install -y build-essential \
nodejs \
libpq-dev

# bundle gem and cache them
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN gem install bundler
RUN bundle install

# Add rails app
ADD . /home/app/webapp
WORKDIR /home/app/webapp


RUN touch log/delayed_job.log log/production.log log/

RUN chown -R app:app /home/app/webapp
RUN RAILS_ENV=production rake assets:precompile

# Clean up APT and bundler when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

我遇到了 tmplog 文件的权限问题。

web_1 | [ 2016-07-19 08:45:12.6653 31/7ff812726700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/app/webapp: An error occurred while starting up the preloader.
web_1 | Error ID: 42930e85
web_1 | Error details saved to: /tmp/passenger-error-9DeJ86.html
web_1 | Message from application: Permission denied @ rb_sysopen - log/logentries.log (Errno::EACCES)
web_1 | /usr/lib/ruby/2.2.0/logger.rb:628:in `initialize'
web_1 | /usr/lib/ruby/2.2.0/logger.rb:628:in `open'
web_1 | /usr/lib/ruby/2.2.0/logger.rb:628:in `open_logfile'
web_1 | /usr/lib/ruby/2.2.0/logger.rb:584:in `initialize'
web_1 | /usr/lib/ruby/2.2.0/logger.rb:318:in `new'
web_1 | /usr/lib/ruby/2.2.0/logger.rb:318:in `initialize'
web_1 | /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `new'
web_1 | /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `initialize'

我试着给 chmod -R 665/775/777 log/ 仍然没有解决问题。

谢谢

最佳答案

重新安排你的行 RUN RAILS_ENV=production rake assets:precompile 然后 RUN chown -R app:app/home/app/webapp(在你的 rake 任务之后)所以, 应该是这样的:

RUN RAILS_ENV=production rake assets:precompile
运行 chown -R app:app/home/app/webapp

关于ruby-on-rails-4 - 权限被拒绝 @ rb_sysopen - 日志/application.log (Errno::EACCES),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38453813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com