我为所有网站运行nginx + php-fpm。有些是drupal,有些是独立的,有些也使用清漆。一切都很棒。
我正在安装第一个symfony2网站 - 没有清漆,只有nginx。
安装symfony后,
✔ Symfony 2.6.5 was successfully installed. Now you can:
我首先检查php web-server
cd ./symfony
php app/console server:run
@ nav to:
http://127.0.0.1:8000
我看到了
==> "Symfony - Welcome"
&安培; @ nav to:
http://127.0.0.1:8000/config.php
我看到了
==> "Your configuration looks good to run Symfony."
接下来我切换到nginx配置。
测试非php
echo blah > web/test.txt
@ nav to:
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,我的配置或应用程序的问题?
我需要更改哪些内容才能使第1页正常工作?