简体   繁体   中英

Error 500 on Symfony2 deployment

I've been struggling for a few days on a weird error. So far, I managed to create a working app, everything works fine on local. I tried to deploy my app, but I'm getting the following message :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Since this is my very first deployment, I have absolutely no idea on where to look at. I searched for a while, used debugger, fixed every major and critical errors using Insight, but I'm stil getting the same error message.

The biggest problem is that I get no logs at all. I gave all access rights on app/cache and app/logs, but no log files are created on the server.

EDIT

Here are the Apache logs

[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

I got it to work, this is my experience:

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'], array('127.0.0.1', '::1', / your IP here /))) { header('HTTP/1.0 403 Forbidden'); die('This script is only accessible from 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.

Now everything is going well, I hope that helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM