The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Display Errors on Command Line

Discussion in 'General Discussion' started by flashweb, Jun 26, 2015.

  1. flashweb

    flashweb Well-Known Member

    Joined:
    Mar 13, 2003
    Messages:
    243
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    When i run PHP script from command line, it won't display any errors.

    Code:
    # php test.php 
    #
    
    Content of the file is

    Code:
    # cat test.php 
    <?php
    
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    
    echo "hello"
    #
    
    PHP Settings and Version

    Code:
    # php -i | grep error
    display_errors => STDOUT => STDOUT
    display_startup_errors => Off => Off
    error_append_string => no value => no value
    error_log => error_log => error_log
    error_prepend_string => no value => no value
    error_reporting => 81 => 81
    html_errors => Off => Off
    ignore_repeated_errors => Off => Off
    log_errors => On => On
    log_errors_max_len => 1024 => 1024
    track_errors => Off => Off
    xmlrpc_error_number => 0 => 0
    xmlrpc_errors => Off => Off
    # php -v
    PHP 5.3.29 (cli) (built: May 31 2015 06:29:44) 
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
        with the ionCube PHP Loader v4.7.5, Copyright (c) 2002-2014, by ionCube Ltd., and
        with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies
    # 
    
    There i is no error_log on current folder.

    Code:
    # ls -l | grep err
    # 
    
    If i add fix PHP script by adding semicoln (;), it works properly.

    I want to debug a script as it works locally, not on server.

    Any idea how i can get php scripts to display errors in terminal ?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Are you running the PHP command as "root" or an individual users? Does it work if you use the command with the "-d" flag? EX:

    Code:
     php -d display_errors /path/to/file.php
    Thank you.
     
  3. flashweb

    flashweb Well-Known Member

    Joined:
    Mar 13, 2003
    Messages:
    243
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Running as root as i am making a script that alert me when some one login to cpanel.

    I got it working with php -n option (no php.ini)

    Code:
    root@server74 [~]# php -d display_errors 1.php
    root@server74 [~]# php -d display_errors=on 1.php
    root@server74 [~]# cat 1.php
    <?php
    
    echo "Hello World" 
    
    root@server74 [~]# php -n 1.php
    
    Parse error: syntax error, unexpected $end, expecting ',' or ';' in /root/1.php on line 5
    root@server74 [~]# 
    
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I am happy to see you were able to address the issue. One feature that might interest you is the ability for users can enable login notifications in the "Contact Information" area inside of cPanel.

    Thank you.
     
  5. flashweb

    flashweb Well-Known Member

    Joined:
    Mar 13, 2003
    Messages:
    243
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Thanks, i never know this is possible. Is there anyway root can enable this for all users by default ?

    Also enforce a password policy, so passwords get changed. Many (including me) never changed passwords. Having to change password changed every 60 days like banks will keep the internet as a whole safe :)
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    1. There are no options to enable this for all accounts, but the setting is stored in "/home/$username/.cpanel/contactinfo" as the following entry when enabled:

    Code:
    "notify_account_login": 1
    Thus, you could develop a custom code that adds or modifies this entry in the same file for each account.

    2. We do have a password aging feature that's documented at:

    Configure Security Policies

    Thank you.
     
Loading...

Share This Page