[solved] APC goes crazy under LSWS 4.1.10 & 4.1.11

Discussion in 'Bug Reports' started by Rowlf, Feb 28, 2012.

  1. Rowlf

    Rowlf New Member

    A while ago I had to disable APC for PHP as it was resetting every minute or two. It's only now that I've traced it to an LSWS update.

    The details:

    1) I'm using the 32-bit version and the bug is there both in the Standard and Enterprise editions.
    2) PHP 5.3.8 with APC enabled works normally under 4.1.9, APC goes nuts if I upgrade to 4.1.10 or 4.1.11.
    3) Compiling PHP 5.3.10 and switching to it under LSWS 4.1.11 does not help - APC still crashes.

    Please help :).
    Last edited by a moderator: Mar 12, 2012
  2. webizen

    webizen New Member

    what do you mean by APC crashes? anything in error log? is this shared hosting or dedicated?
  3. Rowlf

    Rowlf New Member

    I mean it resets every minute or two, deleting the entire cache that was built over the short period that it was up. I'm in the process of moving my sites from a VPS (Debian lenny) to Amazon EC2 (Amazon Linux, CentOS-based) and I'm experiencing these problems in both environments. The production box (Debian lenny) is working normally now that I've downgraded to LSWS 4.1.9, I'll enable APC on the test box again and see if there's anything in the error logs.
  4. NiteWave

    NiteWave Administrator

  5. Rowlf

    Rowlf New Member

    Tried that, it held out for 3 minutes :). And then started resetting again. What can I do to get you more info? I tried enabling DEBUG level logging, but there doesn't seem to be anything useful there. What should I look for?
  6. NiteWave

    NiteWave Administrator

    following output will help:
    #pstree -p
    #ps -ef|grep lsphp5
  7. Rowlf

    Rowlf New Member

    #pstree -p
    Code:
    init(1)-+-agetty(1563)
            |-atd(1516)
            |-auditd(1071)---{auditd}(1072)
            |-crond(1506)
            |-dbus-daemon(1107)
            |-dhclient(1034)
            |-fail2ban-server(23385)-+-{fail2ban-serve}(23386)
            |                        `-{fail2ban-serve}(23387)
            |-gam_server(1590)
            |-litespeed(24425)-+-httpd(24426)
            |                  `-litespeed(24427)-+-{litespeed}(24428)
            |                                     `-{litespeed}(24429)
            |-mingetty(1544)
            |-mingetty(1548)
            |-mingetty(1552)
            |-mingetty(1556)
            |-mingetty(1560)
            |-mingetty(1564)
            |-mysqld_safe(21913)---mysqld(22179)-+-{mysqld}(22188)
            |                                    |-{mysqld}(22189)
            |                                    |-{mysqld}(22190)
            |                                    |-{mysqld}(22191)
            |                                    |-{mysqld}(22192)
            |                                    |-{mysqld}(22193)
            |                                    |-{mysqld}(22194)
            |                                    |-{mysqld}(22195)
            |                                    |-{mysqld}(22196)
            |                                    |-{mysqld}(22197)
            |                                    |-{mysqld}(22199)
            |                                    |-{mysqld}(22200)
            |                                    |-{mysqld}(22201)
            |                                    |-{mysqld}(22202)
            |                                    `-{mysqld}(22210)
            |-ntpd(1169)
            |-rsyslogd(1086)-+-{rsyslogd}(1089)
            |                `-{rsyslogd}(1090)
            |-sendmail(1450)
            |-sendmail(1458)
            |-ssh-agent(24410)
            |-sshd(1149)---sshd(24385)---sshd(24388)---bash(24389)-+-cat(24474)
            |                                                      `-pstree(24473)
            |-udevd(621)-+-udevd(827)
            |            `-udevd(1562)
            `-yum-updatesd(1588)
    

    #ps -ef|grep lsphp5
    Code:
    ec2-user 24476 24389  0 11:55 pts/0    00:00:00 grep lsphp5
  8. Rowlf

    Rowlf New Member

    The above was on LSWS 4.1.11 with PHP 5.3.10 compiled which included Suhosin, APC, memcache and eAccelerator extensions (though only Suhosin + APC were enabled at the time).

    I have also tried enabling eAccelerator and the same thing happens to eAccelerator cache - it resets every few minutes.
  9. Rowlf

    Rowlf New Member

    just noticed that there were no lsphp processes in the output above given that this is not a production box, here it is again with me frantically clicking through the pages of a test site:
    Code:
            |-litespeed(24425)-+-httpd(24426)
            |                  `-litespeed(24427)-+-admin_php(24479)
            |                                     |-lsphp5(24481)
            |                                     |-{litespeed}(24428)
            |                                     `-{litespeed}(24429)
    
    Code:
    ec2-user 24481 24427  2 11:59 ?        00:00:02 lsphp5
    ec2-user 24514 24389  0 12:01 pts/0    00:00:00 grep lsphp5
    
  10. webizen

    webizen New Member

    lsphp5 is there running as ec2-user. is this shared hosting or dedicated environment (PHP suEXEC yes or no)? ls LSWS running as ec2-user?
    Last edited: Mar 1, 2012
  11. Rowlf

    Rowlf New Member

    PHP suEXEC is explicitly set to 'No' as was suggested in some other thread (I tried that before posting here).
    Code:
    ps -ef|grep litespeed
    root     24425     1  0 11:51 ?        00:00:05 litespeed (lshttpd)
    500      24427 24425  0 11:51 ?        00:00:15 litespeed (lshttpd)
    ec2-user 24953 24927  0 20:36 pts/0    00:00:00 grep litespeed
    
  12. Rowlf

    Rowlf New Member

    As far as I understand, lsphp5 is running as ec2-user because the vhosts are located in /home/ec2-user/ (follows Docroot UID). I've had this setup on the old Debian box for over four years and hadn't had a problem with APC before upgrading to LSWS 4.1.10 & 4.1.11.
  13. NiteWave

    NiteWave Administrator

    this indicates suExec is enabled.
    but also
    this should be impossible.

    this is the issue -- why you set to No, but lsphp5 running as ec2-user.
  14. Rowlf

    Rowlf New Member

    Just to make this clear - the PHP suExec Yes/No setting is under Configuration -> Server -> General -> Using Apache Configuration File, nowhere else, is that right? Is it a server-wide setting no matter what? If it was not set either way at the time I instantiated the problematic vhost, would this be inherited by the vhost somehow?

    Either way, I think I'll need to reinstall everything and see if it makes a difference.
  15. NiteWave

    NiteWave Administrator

    right.
    what's the value of
    Load Apache Configuration:Yes/No ?

    if No, all other settings under "Using Apache Configuration File" will be ignored.
  16. Rowlf

    Rowlf New Member

    It was set to No which I believe is the default setting. I have set it to Yes and restarted the server - APC still empties cache every couple of minutes and lsphp5 still runs under ec2-user.

    Now I've just SSH'd to the old Debian box to compare (it's running PHP 5.3.8 on LSWS 4.1.9) and "Load Apache Configuration" there is set to No, and PHP suEXEC is not defined as are the rest of the settings in that group. Yet lsphp processes are run by the litespeed user and APC works.

    The only difference I could see is that the Debian install is running lsphp processes whereas the new AWS one is running lsphp5 ones.
  17. webizen

    webizen New Member

    lsphp and lsphp5 should be the same. the cause of your problem seems to be your lsphp5 runs as different user for each account (follows Docroot UID). APC requires lsphp5 run under same user (web server user). i.e. only dedicated hosting can take advantage of APC.
  18. Rowlf

    Rowlf New Member

    So I wiped the entire thing and started from scratch, this time on a 64bit Amazon Linux image though. Installed the 4.1.11 Standard Edition of LSWS.

    Once I compiled PHP 5.3.10, I changed the following in the Server config(External App, php5):
    Max Idle Time to -1
    also verified that Max Connections and PHP_LSAPI_CHILDREN match (both set to 100).

    In Virtual Host Templates -> PHP_SuEXEC -> Security, I noticed that "ExtApp Set UID Mode" was by default set to "DocRoot UID". I changed it to "Server UID", then added a test vhost, instantiated it and changed Max Idle Time for the vhost itself to -1.

    This is what I got with one vhost working:
    Code:
    pstree -p | cat
    
            |-litespeed(2455)-+-httpd(2456)
            |                 `-litespeed(2457)-+-lsphp5(2520)
            |                                   |-lsphp5(2522)
            |                                   `-lsphp5(2523)
    Code:
    ps -ef | grep lsphp
    
    500       2520  2457  0 08:09 ?        00:00:00 lsphp5
    500       2522  2457  0 08:09 ?        00:00:00 lsphp5
    500       2523  2457  1 08:09 ?        00:00:01 lsphp5
    ec2-user  2556  1642  0 08:11 pts/0    00:00:00 grep lsphp
    So it looks like it now spawns PHP processes as the web server user (litespeed - uid 500). However they appear to be independent, there are no child processes.

    Refreshing the APC test page showed that too - APC accumulates cache for each of those three separate processes, so if I refresh the page, I see that one of the processes has accumulated a few MB of files from the test site, and the other one has nearly similar uptime (say 8 minutes) but has only the test apc.php file in the cache.

    Experimenting further, I selected "Run on startup" = Yes, Max Connections = 1 and Instances = 1. Then I got the one and only PHP process working with APC:
    Code:
            |-litespeed(2563)-+-httpd(2564)
            |                 `-litespeed(2565)-+-admin_php(2655)
            |                                   `-lsphp5(2632)
    
    ps -ef | grep lsphp
    500       2632  2565  0 08:14 ?        00:00:01 lsphp5
    ec2-user  2659  1642  0 08:17 pts/0    00:00:00 grep lsphp
    But I'm not sure what the repercussions are of limiting the amount of PHP processes per vhost to 1?

    Any ideas why the child processes are not being spawned at all?
  19. NiteWave

    NiteWave Administrator

    because you set "Max Connections = 1"

    try:
    Max Connections = 5
    Env PHP_LSAPI_CHILDREN=5

    keep
    Instances = 1
  20. Rowlf

    Rowlf New Member

    Thank you so much, that fixed it!

    Code:
            |-litespeed(2606)-+-httpd(2607)
            |                 `-litespeed(2608)---lsphp5(2668)-+-lsphp5(2670)
            |                                                  |-lsphp5(2671)
            |                                                  `-lsphp5(2672)
    
    
    ps -ef | grep lsphp
    500       2668  2608  0 23:58 ?        00:00:00 lsphp5
    500       2670  2668  0 23:58 ?        00:00:00 lsphp5
    500       2671  2668  0 23:58 ?        00:00:00 lsphp5
    500       2672  2668  0 23:58 ?        00:00:00 lsphp5

Share This Page