2014-11-05 61 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 ?>