Join the community today
Register Now

Nginx PHP-FPM Php error logs not showing

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Saahib, Jun 20, 2018.

  1. Saahib

    Saahib New Member

    25
    2
    3
    Oct 8, 2017
    Ratings:
    +2
    Local Time:
    6:12 PM
    1.13
    10.2
    Hello,

    I saw logs which is created in each domain directory ie.
    /home/nginx/domains/adomain.com/log

    However, I can see nginx access log for that domain, nginx error log for that domain but there is no way user can access its php error log. I can only see one at
    /var/log/php-fpm/www-php.error.log

    But its for all domains, do we have per domain php error log provision ?
     
  2. eva2000

    eva2000 Administrator Staff Member

    40,190
    8,888
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,698
    Local Time:
    10:42 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    there's only 1 global php-fpm error log as there's only global php-fpm not per site see Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS

    very easy to filter logs using grep/egrep/awk etc for just the site you want i.e.

    Code (Text):
    cat -n /var/log/php-fpm/www-php.error.log | grep 'domain.com'
    

    or
    Code (Text):
    cat -n /var/log/php-fpm/www-php.error.log | grep 'subdomain.domain.com'
    
     
  3. Saahib

    Saahib New Member

    25
    2
    3
    Oct 8, 2017
    Ratings:
    +2
    Local Time:
    6:12 PM
    1.13
    10.2
    Thanks but how do I allow user with non-root access to see logs for his particular domain, is it possible to have php logs also in /home/nginx/domains/adomain.com/log ?
     
  4. eva2000

    eva2000 Administrator Staff Member

    40,190
    8,888
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,698
    Local Time:
    10:42 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Usually you don't as Centmin Mod isn't made for shared hosting - see FAQ item 2. Centmin Mod is made for a single root user access and management. Sharing the global php error log to users, means they get access to all site's php usage error logs.
     
  5. Saahib

    Saahib New Member

    25
    2
    3
    Oct 8, 2017
    Ratings:
    +2
    Local Time:
    6:12 PM
    1.13
    10.2
    That I know but if I have a developer who is not comfortable with command line and I gave FTP access for domain he is responsible then he may just see what he need to see. Any workaround ?
     
  6. eva2000

    eva2000 Administrator Staff Member

    40,190
    8,888
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,698
    Local Time:
    10:42 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Unfortunately no easy workaround, you'd either need to

    1. give full php global error log copy to the developer or
    2. give root access (not advisable) or
    3. setup a test VPS with the sole test site copy for developer and then give root access or
    4. setup multiple php-fpm pools and use one of these php-fpm pools php include file as replacement to existing /usr/local/nginx/conf/php.conf in vhost config file and then that php-fpm pool would have it's own php error log i.e. from Beta Branch - Centmin Mod .08 beta03+ Multiple PHP-FPM pools support added if you used /usr/local/nginx/conf/phpfpmd/phpfpm_pool2.conf pool configured to listen to
    127.0.0.1:9002, the include file would be /usr/local/nginx/conf/php-pool2.conf which you can use to replace /usr/local/nginx/conf/php.conf in nginx vhost include file for it. Then /usr/local/nginx/conf/phpfpmd/phpfpm_pool2.conf would have it's own error and slow log defined in /usr/local/nginx/conf/phpfpmd/phpfpm_pool2.conf i.e. centminmod/centminmod
    Code (Text):
    slowlog = /var/log/php-fpm/www-slow-pool2.log
    
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error-pool2.log
    

    Then share that log /var/log/php-fpm/www-php.error-pool2.log
     
  7. Meirami

    Meirami Member

    128
    15
    18
    Dec 21, 2017
    Ratings:
    +41
    Local Time:
    3:42 PM
    Haven't ever tried but can this work?
    Cronjob which runs '
    cat -n /var/log/php-fpm/www-php.error.log | grep 'domain.com'' and saves results to a file in a user folder with right permissions.
     
  8. eva2000

    eva2000 Administrator Staff Member

    40,190
    8,888
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,698
    Local Time:
    10:42 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    You could write a script and run that via cron though might not be the complete picture but close enough.
     
..