2014-11-05 62 views
1

我一直在使用Phalcon在本地开发环境(Vagrant + Virtualbox)中开发项目。它工作得很好,我的开发时间真的减少了。在Plesk 11.5服务器上为Phalcon配置Nginx

现在我想把这个项目放到一个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运行得很好,但路由不起作用:/搜索只是提供了一个404,在我的本地环境中使用该配置工作。

我应该在Plesk中更改哪些内容才能完成此项工作?

谢谢您提前预约!

回答

0

首先检查PHP是否由PHP-FPM或Apache处理。

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

在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为y创建条件我们的域名只是回声完整的配置,如:

<?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 ?>