I´m running my project on my raspberry with Apache2 and PHP5. It´s non public, so me and a friend are currently the only users. The site basically executes shell commands and waits for their finish. Some tasks last usually about 5 minutes.

I´ve a login area which uses sessions and it is based on an abstract class, which I inherrit each protected page from.

Here is a small snippet of it from another serverfault post to locate the problem:

$start = microtime(TRUE);
$time = microtime(TRUE) - $start;
echo $time;

And indeed, it is session_start(), which is getting stuck all the time. Waiting times of 1-10 minutes are sadly usual, which makes my site unusable, but it does not always happen.

One solution I´ve read and tried out was to use session_write_close(), but it has no positive effect at all.

As it is a common php function, I think the problem is not my code but the server settings (maybe the raspberry hardware?! But I don´t think it is too bad to handle 1-2 sessions without a problem)

This is my /etc/apache2/apache2.conf

LockFile ${APACHE_LOCK_DIR}/accept.lock
Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0

<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0

<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0


AccessFileName .htaccess

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all

DefaultType None

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

Include mods-enabled/*.load
Include mods-enabled/*.conf

Include ports.conf

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Include conf.d/

Include sites-enabled/

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

I´m using htaccess too, to protect my complete site, but I don´t think this has any effect on sessions.

This is the session part of my php.ini:


session.save_handler = files

session.use_cookies = 1

session.use_only_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 = 0

session.gc_divisor = 1000

session.gc_maxlifetime = 1440

session.bug_compat_42 = Off

session.bug_compat_warn = Off

session.referer_check =

session.cache_limiter = nocache

session.cache_expire = 180

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"

How can I solve the session slowdown issue?I´m happy about any suggestions

1 Answer 1


Have you thought about a lighter weight httpd server? something like lighttpd?

I don't have a lot of experience with PHP but when I had a web server running on my Pi lighttpd was a lot better than apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.