We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

get apache 503

Hi there,

Not sure if i am in the right place. But...My project based on https://github.com/phalcon/phalcon-compose is working on my local machine, and unfortunatly returns an apache 503 status page on my vps. Unless i comment out the $application->handle(). How can i configure phalcon to point me in the right direction?

public/index.php


<?php
 ini_set('display_errors', "On");
 error_reporting(E_ALL);
 $debug = new Phalcon\Debug();
 $debug->listen();

use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\Application;

/**
 * Define some useful constants
 */
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');

try {

    /**
     * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
     */
    $di = new FactoryDefault();

    /**
     * Read services
     */
    include APP_PATH . "/config/services.php";

    /**
     * Get config service for use in inline setup below
     */
    $config = $di->getConfig();

    /**
     * Include Autoloader
     */
    include APP_PATH . '/config/loader.php';

    /**
    * Handle the request
    */
    $application = new Application($di);
   # this works :
   print_r($application);
   #uncommenting the next line gives me an apache 503 page, but it doesn tell me why there is a 503.
    #echo $application->handle()->getContent();

} catch (\Exception $e) {
    echo get_class($e), ": ", $e->getMessage(), "\n";
    echo " File=", $e->getFile(), "\n";
    echo " Line=", $e->getLine(), "\n";
    echo $e->getTraceAsString();
}

Thanks in advance!

edited Mar '18

I will try this project today or tomorrow, but I have noticed that there is logs directory.

Is there any log in that location?

edited Mar '18

Yes! There is an application.log. But i have created the file manualy. It is readable and writable by docker. but doesnt contain anything. Here is my config file and services

config.php

<?php

use Phalcon\Config;
use Phalcon\Logger;

return new Config([
    'database' => [
        // 'adapter' => 'Postgresql',
        'host' => 'postgres',
        'port' => '5432',
        'username' => 'phalcon',
        'password' => 'yesverysecret',
        'dbname' => 'phalcon'
    ],
    'application' => [
        'controllersDir' => APP_PATH . '/controllers/',
        'modelsDir'      => APP_PATH . '/models/',
        'formsDir'       => APP_PATH . '/forms/',
        'viewsDir'       => APP_PATH . '/views/',
        'libraryDir'     => APP_PATH . '/library/',
        'pluginsDir'     => APP_PATH . '/plugins/',
        'cacheDir'       => BASE_PATH . '/cache/',
        'helpersDir'       => APP_PATH . '/helpers/',
        'baseUri'        => '/',
        'publicUrl'      => 'lsa.deriddercode.nl',
        'cryptSalt'      => 'salt'
    ],
    'mail' => [
        'fromName' => 'Vokuro',
        'fromEmail' => '[email protected]',
        'smtp' => [
            'server' => 'smtp.gmail.com',
            'port' => 587,
            'security' => 'tls',
            'username' => '',
            'password' => ''
        ]
    ],
    'amazon' => [
        'AWSAccessKeyId' => '',
        'AWSSecretKey' => ''
    ],
    'logger' => [
        'path'     => BASE_PATH . '/logs/',
        'format'   => '%date% [%type%] %message%',
        'date'     => 'D j H:i:s',
        'logLevel' => Logger::DEBUG,
        'filename' => 'application.log',
    ],
    // Set to false to disable sending emails (for use in test environment)
    'useMail' => false
]);

part of services.php

/**
 * Logger service
 */
$di->set('logger', function ($filename = null, $format = null) {
    $config = $this->getConfig();

    $format   = $format ?: $config->get('logger')->format;
    $filename = trim($filename ?: $config->get('logger')->filename, '\\/');
    $path     = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;

    $formatter = new FormatterLine($format, $config->get('logger')->date);
    $logger    = new FileLogger($path . $filename);

    $logger->setFormatter($formatter);
    $logger->setLogLevel($config->get('logger')->logLevel);

    return $logger;
});

Edit:

i have narrow it down to the database controller

use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter;

try{
    $tconfig = [
    "host"     => "lsa.deriddercode.nl", # also tried localhost and postgres (docker container name)
    "dbname"   => "phalcon",
    "port"     => 5432,
    "username" => "phalcon",
    "password" => "yesverysecret",
];
    $db =  new DbAdapter($tconfig); # this turns into a useless 503 maintenance apache error
    # $db = new DbAdapter(); # this works
    print_r($db);
    }catch (\Exception $e) {
echo 'fail'; 
}

Why dont i get an error message or connection failed on the db adapter? There is nothing wrong with the postgres container. I can reach it from a adminer instance on my localmachine.



43.9k
edited Mar '18

Hi,

error 503 means a server fault. You have to lok at your webserver error log to see what's going wrong.

...}catch (\Exception $e) { echo 'fail';

yes, that won't give you much information ;-))