1

我为所有网站运行 nginx+php-fpm。有些是drupal,有些是独立的,有些也使用varnish。一切都很好。

我正在安装第一个 symfony2 站点——没有清漆,只有 nginx。

安装 symfony 后,

 ✔  Symfony 2.6.5 was successfully installed. Now you can:

我第一次检查 php 网络服务器

cd ./symfony
php app/console server:run

@导航至:

http://127.0.0.1:8000

我懂了

==> "Symfony - Welcome"

&@导航到:

http://127.0.0.1:8000/config.php

我懂了

==> "Your configuration looks good to run Symfony."

接下来我切换到 nginx 配置。

测试非php

echo blah > web/test.txt

@导航至:

https://symfony.lan/test.txt

我懂了

"blah"

接下来,我添加到 web/config.php

...
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
+    '192.168.1.10',
+    '2001:xxx:xxxx:xxx::10'  
))) {
    header('HTTP/1.0 403 Forbidden');
    exit('This script is only accessible from localhost.');
}
...

如果我导航到:

https://symfony.lan/config.php

我进入浏览器

==> "Symfony - Welcome"

但是@ nav 只是:

https://symfony.lan

我进入浏览器

Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused. 

在我的日志中

==> /var/log/nginx/symfony.access.log <==
2001:xxx:xxxx:xxx::10 - - [23/Mar/2015:07:38:04 -0700] GET / HTTP/1.1 "404" 288 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0" "-"

对于我遵循的 nginx 配置

http://wiki.nginx.org/Symfony

我的 nginx 配置基本上是逐字记录的

server {
    server_name www.symfony.lan;
    return 301 $scheme://symfony.lan$request_uri;
}

server {
    server_name symfony.lan;
    listen [2001:xxx:xxxx:xxx::10]:80;
    listen 192.168.1.10:80;
    rewrite ^(.*) https://symfony.lan$1 permanent;
    break;
}

server {
    server_name symfony.lan;
    listen [2001:xxx:xxxx:xxx::10]:443 ssl spdy;
    listen 192.168.1.10:443 ssl spdy;

    root        /svr/www/symfony.lan/symfony/web;
    access_log  /var/log/nginx/symfony.access.log   main;
    error_log   /var/log/nginx/symfony.error.log    info;
    rewrite_log off;
    autoindex  on;

    ssl on;
    include ssl.conf;
    ssl_verify_client off;
    ssl_certificate "ssldir/symfony.lan.crt";
    ssl_trusted_certificate "ssldir/symfony.lan.crt";
    ssl_certificate_key "ssldir/symfony.lan.key";

    add_header Strict-Transport-Security "max-age=315360000; includeSubdomains";
    add_header X-Frame-Options DENY;

    rewrite ^/app\.php/?(.*)$ /$1 permanent;

    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }

    location ~ ^/(app|app_dev|config)\.php(/|$) {
        fastcgi_pass phpfpm;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS on;
    }

}

虽然在其他帖子中被引用为可能的修复,但执行 @web root

php app/console cache:clear  --env=prod
php app/console cache:warmup --env=prod

在这里什么都没有解决。

这是 Symony 或 Nginx、我的配置或应用程序的问题吗?

我需要具体更改哪些内容才能使第一页正常工作?

4

0 回答 0