Nginx和乘客根指令不适用于Capistrano 3。

时间:2018-11-29 20:44:04

标签: ruby-on-rails nginx capistrano passenger

在使用Capistrano 3进行部署时,我将部署到/home/dev/app-name/。 Cap创建目录结构/home/dev/app-name/current/

这是/home/dev/app-name/releases/20181129161818(当前版本)的符号链接。

此符号链接已损坏,不适用于Nginx和passenger。我知道这是因为这是我位于/etc/nginx/conf.d/app-name.conf的应用程序配置:

server {
  listen 80;
  server_name app-name.domain.com;

  passenger_enabled on;
  passenger_ruby /home/dev/.rvm/gems/ruby-2.5.1/wrappers/ruby;

    rails_env production;

    root /home/dev/app/app-name/releases/20181129161818/public/;
    #root /home/dev/app/app-name/current/public;
}

如果我注释掉路径root /home/dev/app/mullen-admin/releases/20181129161818/public/;sudo service nginx restart,则该应用正常运行。

如果我使用另一个root指令,则该应用程序已损坏,并且出现500服务器错误。

2018/11/29 15:31:43 [alert] 11278#0: *3 Cannot stat '/home/dev/app/app-name/current/passenger_wsgi.py': 
Permission denied (errno=13); This error means that the Nginx worker process (PID 11278, running as UID 1002) does not have permission to access this file. 
Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; 
Extra info, client: 10.194.234.100, server: app-name.domain.com, request: "GET /employees/sign_in HTTP/1.1", host: "app-name.domain.com"

我正在工作所在办公室的虚拟机上运行centos-release-7-5.1804.5.el7.centos.x86_64。我有一个sudouser dev用于ssh和部署。

请帮助!?我需要该应用程序在nginx root指令中以/ current正常工作,以便我可以部署并使更改生效。

1 个答案:

答案 0 :(得分:1)

我认为capistrano已经具有symlink指令:SQL databases

add_action( 'init', 'add_admin_tools_account_endpoint' );
function add_admin_tools_account_endpoint() {
    add_rewrite_endpoint( 'admin-tools', EP_PAGES );
}

add_filter ( 'woocommerce_account_menu_items', 'custom_account_menu_items', 10 );
function custom_account_menu_items( $menu_links ){
    if ( current_user_can('administrator') ) {
        $menu_links = array_slice( $menu_links, 0,3 , true )
        + array( 'admin-tools' => __('Admin tools') )
        + array_slice( $menu_links, 3, NULL, true );
    }
    return $menu_links;
}

add_action( 'woocommerce_account_admin-tools_endpoint', 'admin_tools_account_endpoint_content' );
function admin_tools_account_endpoint_content() {
    if ( current_user_can('administrator') ) {
        echo "<h3 style='text-align:center;'>Administration Tools</h3>
        <p style='text-align:center;'>Test of various functions.</p>";
    }
}

您的符号链接未损坏,您的权限是,并且您必须对齐它们(乘客无权创建文件)。部署后更改chmod:symlink

类似

ln -nfs release_path current_path

另外,根据您的配置,您可能希望例如执行chown而不是sudo