在Plesk 11.5服务器上为Phalcon配置Nginx

时间:2014-11-05 07:55:41

标签: php nginx plesk phalcon phalcon-routing

我一直在Phalcon的本地开发环境(Vagrant + Virtualbox)上开展项目。它运作得很好,我的开发时间确实减少了。

现在我想将这个项目放在Plesk 11.5 nginx环境中,我遇到了在Plesk中为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;
    }
}

我删除了"服务器{}"因为在Plesk nginx配置中不允许这些。但是,它只是不起作用。该应用程序的主页显示完美,因此Phalcon运行良好,但路由不起作用:/ search只提供404,它在我的本地环境中使用此配置。

我应该在Plesk中做些什么来改变它?

感谢您提前的时间!

1 个答案:

答案 0 :(得分:0)

首先,检查是由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 ?>