在ISPConfig3上运行Symfony2

Pet*_*ter 15 php nginx symfony ispconfig

整个ISPConfig的安装,配置以及所涉及的一切都是一条艰难的道路.随着颠簸和瘀伤我终于得到了完整的包装运行我想要的方式.

那些颠簸和瘀伤可能是因为我对Linux(Debian Wheezy)缺乏经验.

但是,现在一切都已设置好,我已经到了安装Symfony2的地步.与ISPConfig的所有其他方面一样,这并不像它应该去的那样.

我的问题:

  • 我不知道如何从Web GUI为symfony2配置nginx
  • 运行symfony时,它不会重定向到app.php
  • 当我直接去app.php它会给我一个500

日志告诉我该app目录无法访问存在问题open_basedir().

我实际上正在寻找的是如何配置这整个事情的一点指导.

随意询问其他信息.我很乐意更新我的问题.

提前致谢.

Nginx网站conf

server {
        listen ...:80;

        listen ...:443 ssl;
        ssl_protocols ...
        ssl_certificate ...
        ssl_certificate_key ...;

        server_name mydomain.tld;

        root   /var/www/mydomain.tld/web;



        index index.html index.htm index.php index.cgi index.pl index.xhtml;


        location ~ \.shtml$ {
            ssi on;
        }


        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
        error_page 502 /error/502.html;
        error_page 503 /error/503.html;
        recursive_error_pages on;
        location = /error/400.html {

            internal;
        }
        location = /error/401.html {

            internal;
        }
        location = /error/403.html {

            internal;
        }
        location = /error/404.html {

            internal;
        }
        location = /error/405.html {

            internal;
        }
        location = /error/500.html {

            internal;
        }
        location = /error/502.html {

            internal;
        }
        location = /error/503.html {

            internal;
        }

        error_log /var/log/ispconfig/httpd/mydomain.tld/error.log;
        access_log /var/log/ispconfig/httpd/mydomain.tld/access.log combined;

        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php5-fpm/web3.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

}
Run Code Online (Sandbox Code Playgroud)

我想指出,这种配置是由ISPConfig自动生成的,并且可能应该从Web GUI进行编辑.

编辑

我通过将所有symfony文件夹添加到以下内容来修复内部服务器错误:

ISPConfig Web > Sites > mydomain.tld > Options > PHP open_basedir
Run Code Online (Sandbox Code Playgroud)

iqu*_*ito 7

配置缺少实际的PHP中继.如果您使用以下三个块交换位置@php块,它应该可以工作:

location / {
  try_files $uri @php;
}

location app.php {
  try_files @php =404;
}

location @php {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/lib/php5-fpm/web3.sock;
    fastcgi_param  SCRIPT_NAME  app.php;
    fastcgi_param  SCRIPT_FILENAME  app.php;
    fastcgi_intercept_errors on;
}
Run Code Online (Sandbox Code Playgroud)

第一个块尝试在给定的根目录中找到所请求的文件,这意味着/var/www/mydomain.tld/web-现在所有Symfony资产都可以工作并返回,因为它们都在web目录中.如果找不到该文件,则调用PHP.

如果直接请求/app.php,则使用第二个块 - 而不是传递该文件,我们使用PHP处理它.

第三个块配置PHP - 前两个块总是引用此块,因此任何未直接找到的文件都由PHP处理.Symfony只有一个前端控制器app.php,所以我们只是将所有请求发送到该入口点.

使用此设置,它应该是非常安全的,因为PHP只处理app.php.对于测试环境,您可以使用app_dev.php而不是app.php(只需更改@php块中的文件名) - 但永远不会用于生产并且不会保护测试环境.