【问题标题】:Configuring Nginx for Phalcon on a Plesk 11.5 server在 Plesk 11.5 服务器上为 Phalcon 配置 Nginx
【发布时间】:2015-01-01 08:18:47
【问题描述】:

我一直在使用 Phalcon 在本地开发环境(Vagrant + Virtualbox)中开展一个项目。它真的很好用,我的开发时间真的减少了。

现在我想在 Plesk 11.5 nginx 环境中上线这个项目,我遇到了在 Plesk for Phalcon 中配置 Nginx 的问题。我对 Nginx 也很陌生。

我有以下 Nginx 配置:

server {

    listen   80;
    server_name localhost.dev;

    index index.php index.html index.htm;
    set $root_path '/var/www/httpdocs';
    root $root_path;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

我删除了“server {}”,因为这些在 Plesk nginx 配置中是不允许的。但是,它只是行不通。应用程序的主页完美显示,因此 Phalcon 运行良好,但路由不起作用:/search 仅给出 404,它在我的本地环境中使用此配置工作。

我应该在 Plesk 中进行哪些更改才能完成这项工作?

提前感谢您的宝贵时间!

【问题讨论】:

    标签: php nginx plesk phalcon phalcon-routing


    【解决方案1】:

    首先检查 PHP-FPM 或 Apache 对您的域进行的 PHP 处理。

    如果您使用 nginx 就像 apache 的反向代理和 apache 处理的 PHP 一样,您只需将 Phalcon bootstrap index.php 和 .htaccess 放入 /var/www/vhosts/domain.tld/httpdocs 和所有其他应用程序文件到 /var/www/vhosts/domain.tld (我已经在这种配置上成功运行了 Phalcon 教程)

    对于 PHP-FPM,最简单的方法是定义 custom virtual host template

    mkdir -p /usr/local/psa/admin/conf/templates/custom/domain
    cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/
    

    在 /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php 中为您的域名创建条件,只需回显整个完整配置,例如:

    <?php if $VAR->domain->asciiName == 'your-domain.tld' ?>
    
        plain text of your full nginx config here
    
    <?php   else: ?>
    
       plesk default instruction for all other domains
    
    <?php endif ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-24
      • 2014-06-19
      • 1970-01-01
      • 2017-05-12
      • 2017-11-21
      • 1970-01-01
      • 2017-03-16
      • 2018-05-30
      相关资源
      最近更新 更多