12

I have developed a website using PhalconPHP. the website works perfectly fine on my local computer with the following specifications:

PHP Version 7.0.22
Apache/2.4.18
PhalconPHP 3.3.1

and also on my previous Server (with DirectAdmin):

PHP Version 5.6.26
Apache 2
PhalconPHP 3.0.1

But recently I have migrated to a new VPS. with cPanel:

CENTOS 7.4 vmware [server]
cPanel v68.0.30
PHP Version 5.6.34 (multiple versions available, this one selected by myself)
PhalconPHP 3.2.2

On the new VPS my website always gives me Error 500.

in my Apache Error logs file: [cgi:error] End of script output before headers: ea-php70, referer: http://mywebsitedomain.net

What I suspect is the new database System. the new one is not mySql. it is MariaDB 10.1. I tried to downgrade to MySQL 5.6 but the WHM says there is no way I could downgrade to lower versions.

this is my config file:

[database]
adapter  = Mysql
host     = localhost
username = root
password = XXXXXXXXXXXX
dbname   = XXXXXXXXXXXX
charset  = utf8

and my Services.php:

protected function initDb()
{
    $config = $this->get('config')->get('database')->toArray();

    $dbClass = 'Phalcon\Db\Adapter\Pdo\\' . $config['adapter'];
    unset($config['adapter']);

    return new $dbClass($config);
}

And in my controllers... for example this code throws Error 500:

$this->view->files = Patients::query()->orderBy("id ASC")->execute();

but changing id to fname fixes the problem:

$this->view->files = Patients::query()->orderBy("fname ASC")->execute();

or even the following code throws error 500:

$user = Users::findFirst(array(
                         "conditions" => "id = :id:",
                         "bind" => array("id" => $this->session->get("userID"))
                        ));

is there a problem with the compatibility of PhalconPHP and MariaDB?

VafaK
  • 514
  • 1
  • 6
  • 22
  • 2
    Don't you log the error messages? "Error 500" is not helpful. – Paul Spiegel Mar 19 '18 at 11:28
  • "Looking for an answer drawing from credible and/or official sources." isn't the request for an external resource explicitly considered off-topic? Isn't the lack of a [mcve] considered off-topic? Anyhow, switch the DB on your machine to verify whether that is the reason your code doesn't work. – Ulrich Eckhardt Mar 25 '18 at 08:36
  • Hav you checked your .htaccess file? – Stefan Avramovic Mar 25 '18 at 12:23

2 Answers2

5

MariaDB was built to be mostly compatible with MySQL clients, it's unlikely to be the reason for your problems. If you're still concerned, you can switch from MariaDB to MySQL (and vice versa) by dumping (exporting) your tables, switching over, and importing them again.

More likely, the error line you're showing indicates that your new server is actually running PHP7 (ea-php70) and not PHP5.6 as you thought you selected.

The error End of script output before headers means the CGI script (in this case PHP7 itself) did not produce any HTTP headers before terminating. I suspect that your version of PhalconPHP is incompatible with PHP7 and therefore just crashes immediately.

If cPanel doesn't let you properly configure your infrastructure you likely have no other option but to drop it and set up your stack manually. But since you probably paid for cPanel, you could try opening a support ticket with them first: https://cpanel.com/support/

Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
  • @DevMoutarde Yeah but there's an older PhalconPHP version on the server. – Cobra_Fast Mar 18 '18 at 14:48
  • @Cobra_Fast Thanks for your answer. what is strange is that the phalcon seems to work if i remove all codes related to database. the `invo` sample app works fine which shows that the extension is loaded and working. but when I execute some queries on database this problem happens and only when I query by an Integer field. – VafaK Mar 18 '18 at 14:57
  • @Agha Well then try switching over to MySQL and see if that fixes your problem. – Cobra_Fast Mar 18 '18 at 15:01
0

Most probably old phalconPHP version it does not support latest php 7.x version i guess. as i remember I have read similiar problem in another blog question.

Raza Rafaideen
  • 2,119
  • 1
  • 19
  • 30