我在CakePHP 3
开发了一个应用程序。它在localhost
服务器上工作正常,但当我将其上传到共享主机时,它开始提供500 Internal server error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at admin@main-hosting.eu to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
我在谷歌上尝试了所有解决方案,但没有任何帮助。 然后我找到了php错误日志,并在其中找到了这些行。
[19-Jun-2016 18:29:08 UTC] PHP Fatal error: Uncaught Error: Class 'Cake\Routing\DispatcherFactory' not found in /home/username/public_html/webroot/index.php:33
Stack trace:
#0 {main}
thrown in /home/username/public_html/webroot/index.php on line 33
/webroot/index.php的内容是
<?php
/**
* The Front Controller for handling every request
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
// for built-in server
if (php_sapi_name() === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
$url = parse_url(urldecode($_SERVER['REQUEST_URI']));
$file = __DIR__ . $url['path'];
if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
return false;
}
}
require dirname(__DIR__) . '/config/bootstrap.php';
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Routing\DispatcherFactory;
$dispatcher = DispatcherFactory::create(); // Line 33
$dispatcher->dispatch(
Request::createFromGlobals(),
new Response()
);
这里有什么问题?
答案 0 :(得分:1)
如果您使用的是共享主机,请检查文件和文件夹权限:
644表示文件的所有者可以读取和写入文件,并且该文件的组所有者可以读取该文件,并且其他人都可以读取。
755是一回事,它只是为每个人设置了执行位。需要执行位才能切换到目录。这就是目录通常设置为755的原因。
希望这对你有用......