Symfony2部署错误500

时间:2015-03-29 17:16:44

标签: php symfony deployment

我因为一个奇怪的错误而挣扎了好几天。到目前为止,我设法创建一个工作的应用程序,一切都在本地工作正常。我尝试部署我的应用,但我收到以下消息:

  

内部服务器错误

     

服务器遇到内部错误或配置错误   无法完成您的请求。

由于这是我的第一次部署,我完全不知道在哪里看。我搜索了一段时间,使用了调试器,使用Insight修复了所有主要和关键错误,但我仍然得到相同的错误消息。

最大的问题是我根本没有记录。我给了app / cache和app / logs的所有访问权限,但是没有在服务器上创建日志文件。

修改

以下是Apache日志

[Sun Mar 29 18:35:26.944078 2015] [:error] [pid 83621] [client 127.0.0.1:59365] PHP Notice:  Undefined index: user in /Volumes/Data/nfs/zfs-student-2/users/2013_paris/ptran/mamp/apps/AOFVH/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 1758
[Sun Mar 29 18:35:26.944155 2015] [:error] [pid 83621] [client 127.0.0.1:59365] PHP Warning:  Invalid argument supplied for foreach() in /Volumes/Data/nfs/zfs-student-2/users/2013_paris/ptran/mamp/apps/AOFVH/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 1763
[Sun Mar 29 18:35:26.954155 2015] [:error] [pid 83621] [client 127.0.0.1:59365] PHP Notice:  Undefined index: user in /Volumes/Data/nfs/zfs-student-2/users/2013_paris/ptran/mamp/apps/AOFVH/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php on line 183
[Sun Mar 29 18:35:26.954175 2015] [:error] [pid 83621] [client 127.0.0.1:59365] PHP Fatal error:  Call to a member function setValue() on a non-object in /Volumes/Data/nfs/zfs-student-2/users/2013_paris/ptran/mamp/apps/AOFVH/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php on line 183

1 个答案:

答案 0 :(得分:1)

我得到了它,这是我的经验:

Upload the whole project folder to the server.
Enter www.your-website.com/project-name/web/config.php.
It should say: "This script is only accessible from localhost".
Open this web site: http://www.whatismyip.com, it should show you your public IP address, copy it.
Open the config.php from the admin panel (like cPanel) and edit that config.php:

if(!in_array(@ $ _ SERVER [' REMOTE_ADDR'],数组(' 127.0.0.1',' :: 1',/ 你的IP /))){     标题(' HTTP / 1.0 403 Forbidden');     死('此脚本只能从localhost访问。');
}

Refresh your config.php file, the page will tell you if your system is missing some required conditions like: PHP version, APC extension, giving /cache and /log folders permissions to write on, etc.
After you provide the required conditions you'll see a form of configuring you project to connect to a database if you have one, this step is pretty simple.
Open the link www.your-website.com/project-name/web/app_dev.php, it'll help you get started with Symfony2 project.
In case you got in app_dev.php this message: You are not allowed to access this file... just do the same thing to app_dev.php as you did in steps 4 and 5 (add your public IP address to the array).
Note of Hakan Deryal (comment): If you don't have a fix IP address, you need to do this last step each time you get a new IP adrdress from the DHCP. So to solve that, open the app_dev.php and comment out the line die('You are not allowed to.., however this is not a recommended way because you're disabling the built-in security of the file.
One thing stopped me and may stop you too, the server I deployed the project on, was case-sensitive (unlike the localhost on my computer), so it kept telling me that the template (Index.html.php for example) does not exist, however it does exist, but I did return $this->render('...:index.html.php') with small i in DefaultController.php. So render the exact template (file) name with the same letters cases.

现在一切进展顺利,我希望能帮到你。