1

I've been working on a project with Phalcon in local development environment (Vagrant + Virtualbox). It just works great and my development time really decreased.

Now I would like to put this project online in a Plesk 11.5 nginx environment and I run into the problem of configuring Nginx in Plesk for Phalcon. I'm also quite new to Nginx.

I have the following Nginx configuration:

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;
    }
}

I removed the "server {}" because those are not allowed in Plesk nginx configuration. However, it just doesn't work. The homepage of the application is shown perfectly, so Phalcon is running just fine, but the routing doesn't work: /search just gives a 404 where it does work in my local envoronment with this configuration.

What should I change in Plesk to make this work?

Thank you for your time in advance!

4

1 回答 1

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 的情况下,最简单的方法是定义自定义虚拟主机模板

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 ?>
于 2014-11-09T11:46:55.590 回答