Error 500 on Symfony2 deployment - php

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.

Related

Access Telegram-CLI using php

I want to access the Telegram-CLI using PHP.
I'm compiled Telegram-CLI and loged in to my account, and its works like a charm.
I installed LAMP ([in Linux], Apache, MySQL, PHP) and i tested them works.
I even installed these [following] PHP packages one-by-one using "Composer" and tested the examples but i couldnt make them run...
Also it seems their forum are abandoned to get my questions answer.
php-client for telegram-cli
A wrapper for Telegram-CLI
PHP Wrapper and Drupal module using Telegram CLI
Could somebody tell me how to make one of them work in simple way.
All steps of building Telegram-cli, loging in for first time and run it as deamon has beed completed.
For Example:
This project has been installed on php project root dir using "Composer".
Example.php file has been moved to web server root directory.
But also unning it cause a 500 Internal server error.
The error line is:
$telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');
notices:
The file has been checked and is already there.
And the telegram-cli is running as a daemon on root user.
I added a telegramd group and telegramd user assigned to that group.
I detacted that php commands running under apache user account.
I changed the apache user group to telegramd.
But again nothing...
So, Please help me
Edit:
I changed the httpd.conf user and group parameters to run at the same (telegramd) account
User telegramd
Group telegramd
And i have restarted the apache and checked the username by
exec('whoami');
The Apache is running under "telegramd" user account.
But nothing again..
Edit 2:
error_log file:
[Wed Feb 10 11:02:04.251133 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Warning: stream_socket_client(): unable to connect to unix:///tmp/tg.sck (No such file or directory) in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 48
[Wed Feb 10 11:02:04.251332 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Fatal error: Uncaught exception 'Zyberspace\Telegram\Cli\ClientException' with message 'Could not connect to socket "unix:///tmp/tg.sck"' in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php:51\nStack trace:\n#0 /var/www/html/example.php(10): Zyberspace\Telegram\Cli\RawClient->__construct('unix:///tmp/tg....')\n#1 {main}\n thrown in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 51

Why I'm getting the PHP Fatal error in following scenario?

I'm using LAMP on my local machine. I'm getting the following error in apache error log and a blank web page in browser when I hit the URL:http://localhost/smart-rebate-web/web/admin/forgot_password.php
Following is the error I got in apache error log:
[Tue Apr 15 17:10:18 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required 'includes/public-application-header.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/smart-rebate-web/web/admin/forgot_password.php on line 2, referer: http://localhost/smart-rebate-web/web/admin/login.php?lout=1
For your reference I'm attaching the image of my project structure titled 'smart-rebate-web' in Netbeans editor.
and following is the sceenshot of abrwser after I hit the URL :
http://localhost/smart-rebate-web/web/admin/forgot_password.php
So can anyone please help me in resolving this issue please? Thanks in advance. If you want any further information or any code I can provide you the same. Following asre the permissons of these files if I print in terminal:
-rw-rw-r-- 1 eywa eywa 1646 Apr 14 13:05 application-header.php
-rw------- 1 eywa eywa 1006 Apr 10 18:06 public-application-header.php
You have permission issue. According to your current file permission, only file owner can read and write that file, others cannot read. When you go on browser, default www-data user tries to read that file. And it is not permitted. Make your file 644 or change file owner to www-data. ``www-data` is the apache user used while you open php files from browser. And more flexible way, use following;
require_once(dirname(__FILE__) . "/includes/public-application-header.php");
Try using
require_once('web/admin/includes/<filename>');

Permission denied on codeigniter

I'm running an Apache server on my PC with Debian 7 (well, actually Crunchbang, but it's the same thing).
I was playing with the CodeIgniter framework, and it was working all right. I completed the first tutorial, the one in which you create your first static page (this one: http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html ), and it worked perfectly.
However, as you can see on the very first step, there's a line that goes like this:
[...]
public function view($page = 'home')
[...]
I changed that line to " $page = 'about' ", to try if it could display the other page instead. That's when Hell opened its doors and released the Kraken.
Then it started to show a 404 error, so I changed the settings back again, but the error kept ocurring. I restarted Apache, restarted my PC (I don't know, sometimes it works) and finally, deleted the codeigniter files from my /var/www/ directory, and copied them again.
Now the error is different: It just displays nothing! A blank page, just that. This is what my apache errorlog says:
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/var/www/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/index.php on line 202
[Fri Feb 21 23:03:11 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/var/www/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 202
It sounds like the permissions are set incorrectly on your server.
Check what group Apache runs in (I think Debian by default uses www-data), and make sure you set the group owner and read permissions.
# chown www-data:www-data -R /var/www
# chmod g+r -R /var/www
If the above doesn't work, try setting permissions to 777 just to see if the problem lies elsewhere. I couldn't imagine what else could cause that error, though.

AWS Elastic Beanstalk - PHP script fails to execute after deploying new version

I am using AWS Elastic Beanstalk for PHP which manage 1 EC2 linux server with Apache web server.
When deploying a different version (zip file with all my php scripts) through the management console i sometimes run into a weird situation.
In some cases, even if i am deploying a version with exactly the same scripts which all worked before, some of them suddenly aren't working. When deploying another version again (still same scripts, same content), suddenly everything is working as normal.
Example of a problematic service :
<?php
// dynamically loads needed classes
function __autoload($class_name) {
include $class_name . '.php';
}
$response = new Response();
$response->data = array('platform_version' => Configuration::PLATFORM_VERSION);
die(json_encode($response));
?>
Normally, this script returns a json object. After changing nothing and deploying a version this scripts returns nothing. Is there a way to find if an error occurred?
BTW, i can see a call to the service in the application_access_log of Apache with return status 200.
EDIT:
After changing the error level on the web server i started to see interesting information in the application_error_log :
*[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Fatal error: require_once() [function.require-once]: Cannot redeclare class response in /var/www/html/InstallerLog.php on line 12
[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Stack trace:
[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP 1. {main}() /var/www/html/InstallerLog.php:0*
Why am i getting this error?
I am using :
require_once 'Response.php';
In my script so this kind of error should not occur for my knowledge...
OK. So eventually it was pretty basic.
The error occurred because the class name i was using, "Response", was already in use in other place (not in my code, maybe in the SDK or something like that).
After changing the name to something less generic the error didn't happen again.
Just for play safe i have also added :
if(!class_exists('MyNewResponse'))
before creating the class.

Ubuntu 11.10 PHP don't proceed

i've just setup a LAMP development environment on my laptop, all works fine except for php. Apache don't process PHP code embeded inside pages, and display no error. All php package seems to be correctly installed.
Testing a simple: <?php phpinfo(); ?>, give a blank page
error log give:
[Fri Mar 02 20:30:13 2012] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/home/lib/utils/setDocumentRoot.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
I finally solve my problem, it was due to a fix i've set in my virtualHost config (who was calling a missing file: setDocumentRoot.php), i've disabled that script and all works great.

Categories