【发布时间】:2023-05-15 03:54:01
【问题描述】:
我一直在尝试在共享主机服务器上部署 symfony2,但我不断收到500 response。
web/目录下的所有文件都已放到public_html目录下。
其他目录 [app , bin , src 和 vendor] 已被置于更高一级。
我的目录结构如下:
| -- /app
| -- /bin
| -- /src
| -- /vendor
| -- /public_html
在将文件上传到服务器之前,我确实手动清除了缓存。
app.php
<?php
use Symfony\Component\HttpFoundation\Request;
use Sonata\PageBundle\Request\RequestFactory;
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
.htaccess
DirectoryIndex app.php
#DirectoryIndex app_dev.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
#RewriteRule ^app_dev\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteCond %{REQUEST_FILENAME} -f
#RewriteRule ^(.*)$ app_dev.php [QSA,L]
RewriteRule ^(.*)$ app.php [QSA,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
#RewriteRule .? %{ENV:BASE}app_dev.php [L]
RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
composer.json
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "public_html",
"symfony-assets-install": "symlink",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.8-dev"
}
}
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="web directory">
<match url=".*" ignoreCase="false" />
<action type="Rewrite" url="public_html/{R:0}" appendQueryString="true" />
</rule>
<rule name="app_php handling" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/public_html/app.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
-
我的猜测是检查权限,但如果你检查日志你应该知道更多。
-
文件夹
app/logs为空,文件夹www_logs不包含任何最近的日志。 -
检查你的服务器日志,而不是 symfony 的
-
@vladkras,服务器日志位于
www_logs,但没有任何最近可用的日志。 -
我发现的唯一错误日志是这样的:
[Fri May 26 19:02:28 2017] [error] [client xxx.xxx.xxx.xxx] File does not exist: /usr/www/users/ccacomkppe/public_html [Fri May 26 19:02:29 2017] [error] [client xxx.xxx.xxx.xxx] File does not exist: /usr/www/users/ccacomkppe/public_html [Fri May 26 19:02:29 2017] [error] [client xxx.xxx.xxx.xxx] File does not exist: /usr/www/users/ccacomkppe/public_html
标签: php apache .htaccess symfony