Dancing with a tambourine - "PHP"

Hi all!
Problems with PHP, when approaching the site, appears in the logs:

ee /var/log/php-fpm.log

Aug 30 23:11:22.960921 fpm_request_check_timed_out(), line 146: child
596, script ‘/usr/local/www/web1/index.php’ (pool default) executing too
slow (5.069391 sec), logg
Aug 30 23:11:22.961224 fpm_got_signal(), line 48: received SIGCHLD
Aug 30 23:11:22.961607 fpm_children_bury(), line 194: child 596 stopped
for tracing
Aug 30 23:11:22.961689 fpm_php_trace(), line 139: about to trace 596
Aug 30 23:11:22.962430 fpm_trace_get_long(), line 69: ptrace(PT_IO)
failed: Bad address (14)
Aug 30 23:11:22.980848 fpm_php_trace(), line 167: finished trace of 596

ee /usr/local/etc/nginx/nginx.conf

user www;
worker_processes 3;

pid /var/run/nginx.pid;
worker_rlimit_nofile 1000;

events {
worker_connections 2000;
}

http {
include mime.types;
default_type application/octet-stream;

tcp_nopush     on;
tcp_nodelay    on;
keepalive_timeout  65;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 128;

sendfile on;
gzip  on;

gzip_min_length 2048;
gzip_types text/css text/js text/xml;

client_max_body_size 10m;
large_client_header_buffers 4 8k;

log_format main      '$remote_addr - $remote_user [$time_local] '
                     '"$request"'
                     '"$http_referer" "$http_user_agent" 

“$gzip_ratio”’;

server {
    listen       80;
    server_name mysite.com;
    access_log   /var/log/nginx.access_log  main;

    charset windows-1251;
    client_max_body_size    25m;

    location / {
        root   /usr/local/www/web1;
        index  index.html index.php;
    }

    location ~* \.php$ {
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 1024k;
        fastcgi_buffers 4 1024k;
        fastcgi_busy_buffers_size 1024k;
        fastcgi_temp_file_write_size 1024k;
        fastcgi_temp_path /tmp;

        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME 

/usr/local/www/web1$fastcgi_script_name;
include fastcgi_params;
}
}
}

ee /usr/local/etc/php-fpm.conf

<?xml version="1.0" ?>
    All relative paths in this config are relative to php's install 

prefix

            Pid file
            /var/run/php-fpm.pid

            Error log file
            /var/log/php-fpm.log

            Log level
            notice

            When this amount of php processes exited with SIGSEGV or 

SIGBUS …
10

            ... in a less than this interval of time, a graceful 

restart will be initiated.
Useful to work around accidental curruptions in
accelerator’s shared memory.
1m

            Time limit on waiting child's reaction on signals from 

master
5s

            Set to 'no' to debug fpm
            yes







                    Name of pool. Used in logs and stats.
                    default

                    Address to accept fastcgi requests on.
                    Valid syntax is 'ip.ad.re.ss:port' or just 

‘port’ or ‘/path/to/unix/socket’
127.0.0.1:9000

                            Set listen(2) backlog
                            -1

                            Set permissions for unix socket, if one 

used.
In Linux read/write permissions must be
set in order to allow connections from web server.
Many BSD-derrived systems allow
connections regardless of permissions.

                            0666


                    Additional php.ini defines, specific to this 

pool of workers.

            <!--            /usr/sbin/sendmail -t -i            -->
            <!--            0 

–>

                    Unix user of processes
                    www

                    Unix group of processes
                    www

                    Process manager settings


                            Sets style of controling worker process 

count.
Valid values are ‘static’ and
‘apache-like’
static

                            Sets the limit on the number of 

simultaneous requests that will be served.
Equivalent to Apache MaxClients
directive.
Equivalent to PHP_FCGI_CHILDREN
environment in original php.fcgi
Used with any pm_style.
5

                            Settings group for 'apache-like' pm 

style

                                    Sets the number of server 

processes created on startup.
Used only when ‘apache-like’
pm_style is selected
20

                                    Sets the desired minimum number 

of idle server processes.
Used only when ‘apache-like’
pm_style is selected
5

                                    Sets the desired maximum number 

of idle server processes.
Used only when ‘apache-like’
pm_style is selected
35

                    The timeout (in seconds) for serving a single 

request after which the worker process will be terminated
Should be used when ‘max_execution_time’ ini
option does not stop script execution for some reason
‘0s’ means ‘off’
0s

                    The timeout (in seconds) for serving of single 

request after which a php backtrace will be dumped to slow.log file
‘0s’ means ‘off’

                    5s

                    The log file for slow requests
                    /var/log/php-slow.log

                    Set open file desc rlimit
                    1024

                    Set max core size rlimit
                    0

                    Chroot to this directory at the start, absolute 

path

                    Chdir to this directory at the start, absolute 

path

                    Redirect workers' stdout and stderr into main 

error log.
If not set, they will be redirected to
/dev/null, according to FastCGI specs
yes

                    How much requests each process should execute 

before respawn.
Useful to work around memory leaks in 3rd party
libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
1500

                    Comma separated list of ipv4 addresses of 

FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment
in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
127.0.0.1

                    Pass environment variables like LD_LIBRARY_PATH
                    All $VARIABLEs are taken from current 

environment

                            $HOSTNAME
                            /usr/local/bin:/usr/bin:/bin
                            /tmp
                            /tmp
                            /tmp
                            $OSTYPE
                            $MACHTYPE
                            2

ee /usr/local/etc/php.ini

engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func=
serialize_precision = 100
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
expose_php = On
max_execution_time = 60
max_input_time = 60
memory_limit = 48M ; увеличиваем лимит по памяти для “тяжелых”
скриптов
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024 ;размер лога
ignore_repeated_errors = On
ignore_repeated_source = On
report_memleaks = On
track_errors = On
variables_order = “EGPCS”
register_globals = off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 12M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = “text/html”
doc_root =
user_dir =
enable_dl = On
file_uploads = On
upload_max_filesize = 8M
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60

define_syslog_variables = Off

SMTP = localhost
smtp_port = 25

sql.safe_mode = Off

odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1

mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off

msql.allow_persistent = On
msql.max_persistent = -1
msql.max_links = -1

pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

sybase.allow_persistent = On
sybase.max_persistent = -1
sybase.max_links = -1
sybase.min_error_severity = 10
sybase.min_message_severity = 10
sybase.compatability_mode = Off

sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10

bcmath.scale = 0

ifx.default_host =
ifx.default_user =
ifx.default_password =
ifx.allow_persistent = On
ifx.max_persistent = -1
ifx.max_links = -1
ifx.textasvarchar = 0
ifx.byteasvarchar = 0
ifx.charasvarchar = 0
ifx.blobinfile = 0
ifx.nullformat = 0

session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 256000
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 18000
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags =
“a=href,area=href,frame=src,input=src,form=fakeentry”

tidy.clean_output = Off

soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400

; eAccelerator
zend_extension="/usr/local/lib/php/20060613/eaccelerator.so"
eaccelerator.enable=“1”
eaccelerator.shm_size=“64”
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.optimizer=“1”
eaccelerator.check_mtime=“1”
eaccelerator.debug=“0”
eaccelerator.filter=""
eaccelerator.shm_max=“0”
eaccelerator.shm_ttl=“3600”
eaccelerator.shm_prune_period=“0”
eaccelerator.shm_only=“0”
eaccelerator.compress=“1”
eaccelerator.compress_level=“9”

root# uname -a
FreeBSD 6.4-RELEASE
[email protected]:/usr/obj/usr/src/sys/SMP i386

root# php -v
PHP 5.2.10 with Suhosin-Patch 0.9.7 (cli) (built: Aug 26 2009 20:59:41)
Copyright © 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2009 Zend Technologies
with eAccelerator v0.9.5.3, Copyright © 2004-2006 eAccelerator, by
eAccelerator

root# php-cgi -v
PHP 5.2.10 with Suhosin-Patch 0.9.7 (cgi-fcgi) (built: Aug 26 2009
20:59:11)
Copyright © 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2009 Zend Technologies
with eAccelerator v0.9.5.3, Copyright © 2004-2006 eAccelerator, by
eAccelerator

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5359,5359#msg-5359

sounds like the script is performing like crap. you should profile it
for the bottleneck.

or, you could change php-fpm.conf to allow things to run longer but
that’s poor user experience, better to fix the problem not work around
it.

I have a web site called about 30 minutes.

At the same server running phpmyadmin, with him all right! The pages
open very quickly.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5359,5378#msg-5378

ee /usr/local/www/web1/index.php

<?php /* This file is part of TorrentPier TorrentPier is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. TorrentPier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GPL 2.0 should have been included with the program. If not, see http://www.gnu.org/licenses/ Official SVN repository and contact information can be found at http://code.google.com/p/torrentpier/ */ define('IN_PHPBB', true); define('BB_SCRIPT', 'index'); define('BB_ROOT', './'); $phpEx = substr(strrchr(__FILE__, '.'), 1); require(BB_ROOT ."common.$phpEx"); $page_cfg['load_tpl_vars'] = array( 'post_icons', ); $show_last_topic = true; $last_topic_max_len = 28; $show_online_users = true; $show_subforums = true; $datastore->enqueue(array( 'stats', 'moderators', )); if ($bb_cfg['show_latest_news']) { $datastore->enqueue('latest_news'); } // Init userdata $user->session_start(); // Init main vars $viewcat = isset($_GET['c']) ? (int) $_GET['c'] : 0; $lastvisit = (IS_GUEST) ? TIMENOW : $userdata['user_lastvisit']; // Caching output $req_page = 'index_page'; $req_page .= ($viewcat) ? "_c{$viewcat}" : ''; define('REQUESTED_PAGE', $req_page); caching_output(IS_GUEST, 'send', REQUESTED_PAGE .'_guest'); // Topics read tracks $tracking_topics = get_tracks('topic'); $tracking_forums = get_tracks('forum'); // Statistics $stats = $datastore->get('stats'); // Forums data $forums = $datastore->get('cat_forums'); $cat_title_html = $forums['cat_title_html']; $forum_name_html = $forums['forum_name_html']; $anon = ANONYMOUS; $excluded_forums_csv = $user->get_excluded_forums(AUTH_VIEW); $only_new = $user->opt_js['only_new']; // Validate requested category id if ($viewcat AND !$viewcat =& $forums['c'][$viewcat]['cat_id']) { redirect("index.$phpEx"); } // Forums $forums_join_sql = 'f.cat_id = c.cat_id'; $forums_join_sql .= ($viewcat) ? " AND f.cat_id = $viewcat " : ''; $forums_join_sql .= ($excluded_forums_csv) ? " AND f.forum_id NOT IN($excluded_forums_csv) AND f.forum_parent NOT IN($excluded_forums_csv) " : ''; // Posts $posts_join_sql = "p.post_id = f.forum_last_post_id"; $posts_join_sql .= ($only_new == ONLY_NEW_POSTS) ? " AND p.post_time > $lastvisit " : ''; $join_p_type = ($only_new == ONLY_NEW_POSTS) ? 'INNER JOIN' : 'LEFT JOIN'; // Topics $topics_join_sql = "t.topic_last_post_id = p.post_id"; $topics_join_sql .= ($only_new == ONLY_NEW_TOPICS) ? " AND t.topic_time > $lastvisit " : ''; $join_t_type = ($only_new == ONLY_NEW_TOPICS) ? 'INNER JOIN' : 'LEFT JOIN'; $sql = " SELECT SQL_CACHE f.cat_id, f.forum_id, f.forum_status, f.forum_parent, f.show_on_index, p.post_id AS last_post_id, p.post_time AS last_post_time, t.topic_id AS last_topic_id, t.topic_title AS last_topic_title, u.user_id AS last_post_user_id, IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username FROM ". CATEGORIES_TABLE ." c INNER JOIN ". FORUMS_TABLE ." f ON($forums_join_sql) $join_p_type ". POSTS_TABLE ." p ON($posts_join_sql) $join_t_type ". TOPICS_TABLE ." t ON($topics_join_sql) LEFT JOIN ". USERS_TABLE ." u ON(u.user_id = p.poster_id) ORDER BY c.cat_order, f.forum_order "; $cat_forums = array(); $replace_in_parent = array( 'last_post_id', 'last_post_time', 'last_post_user_id', 'last_post_username', 'last_topic_title', 'last_topic_id', ); foreach ($db->fetch_rowset($sql) as $row) { if (!$cat_id = $row['cat_id'] OR !$forum_id = $row['forum_id']) { continue; } if ($parent_id = $row['forum_parent']) { if (!$parent =& $cat_forums[$cat_id]['f'][$parent_id]) { $parent = $forums['f'][$parent_id]; $parent['last_post_time'] = 0; } if ($row['last_post_time'] > $parent['last_post_time']) { foreach ($replace_in_parent as $key) { $parent[$key] = $row[$key]; } } if ($show_subforums && $row['show_on_index']) { $parent['last_sf_id'] = $forum_id; } else { continue; } } else { $f =& $forums['f'][$forum_id]; $row['forum_desc'] = $f['forum_desc']; $row['forum_posts'] = $f['forum_posts']; $row['forum_topics'] = $f['forum_topics']; } $cat_forums[$cat_id]['f'][$forum_id] = $row; } unset($forums); $datastore->rm('cat_forums'); // Obtain list of moderators $moderators = array(); $mod = $datastore->get('moderators'); foreach ($mod['mod_users'] as $forum_id => $user_ids) { foreach ($user_ids as $user_id) { $moderators[$forum_id][] = ''. $mod['name_users'][$user_id] .''; } } foreach ($mod['mod_groups'] as $forum_id => $group_ids) { foreach ($group_ids as $group_id) { $moderators[$forum_id][] = ''. $mod['name_groups'][$group_id] .''; } } unset($mod); $datastore->rm('moderators'); if (!$forums_count = count($cat_forums) AND $viewcat) { redirect("index.$phpEx"); } $template->assign_vars(array( 'SHOW_FORUMS' => $forums_count, 'PAGE_TITLE' => $lang['Index'], 'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], 'TOTAL_TOPICS' => sprintf($lang['Posted_topics_total'], $stats['topiccount']), 'TOTAL_POSTS' => sprintf($lang['Posted_articles_total'], $stats['postcount']), 'TOTAL_USERS' => sprintf($lang['Registered_users_total'], $stats['usercount']), 'NEWEST_USER' => sprintf($lang['Newest_user'], '', $stats['newestuser']['username'], ''), // Tracker stats 'TORRENTS_STAT' => sprintf($lang['Torrents_stat'], $stats['torrentcount'], humn_size($stats['size'])), 'PEERS_STAT' => sprintf($lang['Peers_stat'], $stats['peers'], $stats['seeders'], $stats['leechers']), 'SPEED_STAT' => sprintf($lang['Speed_stat'], humn_size($stats['speed']) .'/s'), 'FORUM_IMG' => $images['forum'], 'FORUM_NEW_IMG' => $images['forum_new'], 'FORUM_LOCKED_IMG' => $images['forum_locked'], 'SHOW_ONLY_NEW_MENU' => true, 'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS), 'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS), 'U_SEARCH_NEW' => "search.$phpEx?new=1", 'U_SEARCH_SELF_BY_MY' => "search.$phpEx?uid={$userdata['user_id']}&o=1", 'U_SEARCH_LATEST' => "search.$phpEx?search_id=latest", 'U_SEARCH_UNANSWERED' => "search.$phpEx?search_id=unanswered", 'SHOW_LAST_TOPIC' => $show_last_topic, )); // Build index page foreach ($cat_forums as $cid => $c) { $template->assign_block_vars('c', array( 'CAT_ID' => $cid, 'CAT_TITLE' => $cat_title_html[$cid], 'U_VIEWCAT' => "index.$phpEx?c=$cid", )); foreach ($c['f'] as $fid => $f) { if (!$fname_html =& $forum_name_html[$fid]) { continue; } $is_sf = $f['forum_parent']; $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : ''; $folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"]; if ($f['forum_status'] == FORUM_LOCKED) { $folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked']; } if ($is_sf) { $template->assign_block_vars('c.f.sf', array( 'SF_ID' => $fid, 'SF_NAME' => $fname_html, 'SF_NEW' => $new ? ' new' : '', )); continue; } $template->assign_block_vars('c.f', array( 'FORUM_FOLDER_IMG' => $folder_image, 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname_html, 'FORUM_DESC' => $f['forum_desc'], 'POSTS' => commify($f['forum_posts']), 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '', 'FORUM_FOLDER_ALT' => ($new) ? 'new' : 'old', )); if ($f['last_post_id']) { $template->assign_block_vars('c.f.last', array( 'LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_TIP' => $f['last_topic_title'], 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), 'LAST_POST_TIME' => create_date($bb_cfg['last_post_date_format'], $f['last_post_time']), 'LAST_POST_USER_ID' => ($f['last_post_user_id'] != ANONYMOUS) ? $f['last_post_user_id'] : false, 'LAST_POST_USER_NAME' => ($f['last_post_username']) ? str_short($f['last_post_username'], 15) : $lang['Guest'], )); } } } // Set tpl vars for bt_userdata if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) { show_bt_userdata($userdata['user_id']); } // Latest news if ($bb_cfg['show_latest_news']) { $latest_news = $datastore->get('latest_news'); $template->assign_vars(array( 'SHOW_LATEST_NEWS' => true, )); foreach ($latest_news as $news) { $template->assign_block_vars('news', array( 'NEWS_TOPIC_ID' => $news['topic_id'], 'NEWS_TITLE' => $news['topic_title'], 'NEWS_TIME' => create_date('d-M', $news['topic_time']), 'NEWS_IS_NEW' => $news['topic_time'] > $lastvisit, )); } } // Allow cron if (IS_ADMIN || IS_MOD) { if (@file_exists(CRON_RUNNING)) { if (@file_exists(CRON_ALLOWED)) { unlink (CRON_ALLOWED); } rename(CRON_RUNNING, CRON_ALLOWED); } } // Display page define('SHOW_ONLINE', $show_online_users); print_page('index.tpl'); Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5359,5412#msg-5412

which again, makes it sound like your website’s code needs
optimization. it’s not php or nginx that’s the issue but probably the
php code itself on the main page doing something wrong.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs