Learn about Centmin Mod LEMP Stack today
Register Now

PHP-FPM PHP Warning: require(): Unable to allocate memory for pool

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by karistuck, Jun 22, 2014.

  1. karistuck

    karistuck Member

    43
    2
    8
    Jun 1, 2014
    대한민국
    Ratings:
    +3
    Local Time:
    10:04 AM
    1.5.8
    Hi.

    I use wordpress on cenminmod on 512MB openvz vps(swap 1000MB)

    When I working dashboard on wordpress that have white screen issue.

    Than I check error.log ( cd /var/log/php-fpm/www-php.error.log )

    Last line have error message as
    512MB not enought for using wordpress?

    Help me If u know some knowledge


    Thank you
     
  2. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    11:04 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are you using APC Cache ? You can check via SSH command

    Code:
    php --ri apc
    which would output something like
    Code:
    apc
    
    APC Support => enabled
    Version => 3.1.15-dev
    APC Debugging => Disabled
    MMAP Support => Enabled
    MMAP File Mask =>
    Locking type => pthread mutex Locks
    Serialization Support => php, igbinary
    Revision => $Revision: 330418 $
    Build Date => Jun 21 2014 13:13:45
    
    Directive => Local Value => Master Value
    apc.enabled => On => On
    apc.shm_segments => 1 => 1
    apc.shm_size => 32M => 32M
    apc.shm_strings_buffer => 4M => 4M
    apc.include_once_override => Off => Off
    apc.num_files_hint => 4096 => 4096
    apc.user_entries_hint => 4096 => 4096
    apc.gc_ttl => 3600 => 3600
    apc.ttl => 7200 => 7200
    apc.user_ttl => 7200 => 7200
    apc.mmap_file_mask => no value => no value
    apc.filters => no value => no value
    apc.cache_by_default => On => On
    apc.file_update_protection => 2 => 2
    apc.enable_cli => On => On
    apc.max_file_size => 1M => 1M
    apc.stat => On => On
    apc.canonicalize => On => On
    apc.stat_ctime => Off => Off
    apc.write_lock => On => On
    apc.slam_defense => Off => Off
    apc.report_autofilter => Off => Off
    apc.rfc1867 => Off => Off
    apc.rfc1867_prefix => upload_ => upload_
    apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
    apc.rfc1867_freq => 0 => 0
    apc.rfc1867_ttl => 3600 => 3600
    apc.coredump_unmap => Off => Off
    apc.preload_path => no value => no value
    apc.file_md5 => Off => Off
    apc.use_request_time => On => On
    apc.lazy_functions => Off => Off
    apc.lazy_classes => Off => Off
    apc.serializer => igbinary => igbinary
    apc.enable_opcode_cache => On => On
    If you are then most likely APC Cache memory allocation is too low as the default is 32M for low memory systems as defined by apc.shm_size = 32M in /etc/centminmod/php.d/apc.ini file.

    Then restart php-fpm service via

    Code:
    service php-fpm restart
    or command shortcut
    Code:
    fpmrestart
    You can find all your php ini file locations via command
    Code:
    php --ini
    which would output something like the following
    Code:
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File:         /usr/local/lib/php.ini
    Scan for additional .ini files in: /etc/centminmod/php.d
    Additional .ini files parsed:      /etc/centminmod/php.d/apc.ini,
    /etc/centminmod/php.d/igbinary.ini,
    /etc/centminmod/php.d/imagick.ini,
    /etc/centminmod/php.d/memcache.ini,
    /etc/centminmod/php.d/memcached.ini
     
  3. karistuck

    karistuck Member

    43
    2
    8
    Jun 1, 2014
    대한민국
    Ratings:
    +3
    Local Time:
    10:04 AM
    1.5.8
    Im using 96MB with APC

    Does I edit 96M to 128M or 256M ?
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    11:04 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Use your APC stats page to monitor and adjust memory allocation to your specific needs

    First, edit user/pass in /usr/local/nginx/html/${N}_myapc.php

    where $N is a number, you can find what it is via

    Code:
    ls -lah /usr/local/nginx/html/*_myapc.php
    Second, password protect _myapc.php file. To password protect your ${N}_myapc.php file at /usr/local/nginx/html
    you need to do 3 steps:

    #############################################################
    1). Use htpasswd.py script at /usr/local/nginx/conf/htpasswd.py to setup
    username and password using following command:
    Code:
      python /usr/local/nginx/conf/htpasswd.py -b /usr/local/nginx/conf/htpasswd yourusername yourpassword
    
    change yourusername and yourpassword to unique values of your own.

    #############################################################
    2). Add the following 6 lines of code to your main nginx virtual host file
    /usr/local/nginx/conf/conf.d/virtual.conf first server{} entry. Changing ${N} in the location to your specific unique number prefix.

    6 lines of code:
    Code:
    location ~ ^/${N}_myapc\.php$ {
    auth_basic "Private";
    auth_basic_user_file /usr/local/nginx/conf/htpasswd;
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    }
    
    End result for first server{} entry looks like below:
    Code:
    server {
                listen   80;
                server_name yourhostname.com;
                root   html;
    
            access_log              /var/log/nginx/localhost.access.log     main buffer=32k;
            error_log               /var/log/nginx/localhost.error.log      error;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
                location / {
    
    #               Enables directory listings when index file not found
    #               autoindex  on;
    
    #               Shows file listing times as local time
    #               autoindex_localtime on;
    
    #               Enable for vBulletin usage WITHOUT vbSEO installed
    #               try_files               $uri $uri/ /index.php;
    
                }
    
    location ~ ^/${N}_myapc\.php$ {
    auth_basic "Private";
    auth_basic_user_file /usr/local/nginx/conf/htpasswd;
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    }
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    
           }
    
    #############################################################
    3). Restart Nginx
    Code:
    service nginx restart
    
    or with command shortcut
    Code:
    ngxrestart
    
    Then visit the file via your forum host name for the main vhost server_name listed in /usr/local/nginx/conf/conf.d/virtual.conf - yourhostname.com/${N}_myapc.php
     
  5. karistuck

    karistuck Member

    43
    2
    8
    Jun 1, 2014
    대한민국
    Ratings:
    +3
    Local Time:
    10:04 AM
    1.5.8
    1.jpg

    2.jpg


    I was changed memory 96M to 192M

    Thank you for watching.
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    11:04 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You have too much fragmentation and near 100% usage. You'd need to bump it up to 256M so maybe 512MB VPS might not be enough
     
  7. dorobo

    dorobo Active Member

    420
    104
    43
    Jun 6, 2014
    Ratings:
    +162
    Local Time:
    9:04 AM
    latest
    latest
    APC consumes too much memory eh?

    Xcache 3 on the other hand, needs only a little.

    But right now I'm using Zend Opcache.
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    11:04 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    it's not the opcache that is the issue, it all depends on the php apps you use and how much cache they require. More php app = more memory consumption :)