Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Plesk PHP Session Cleanup unable to delete files from /var/lib/php/session

Posted on 2014-04-10
9
Medium Priority
?
2,808 Views
Last Modified: 2014-04-16
I'm using 11.0.9 CentOS 6 110120608.16

All session files on my server are stored in the folder /var/lib/php/session

The folder has the following permissions set:

drwx-wx-wt 2 root root 548864 Apr 10 20:09 session

But all session files inside that folder only have rw permissions for there apache user exclusively

So I think the cron configured in /etc/cron.hourly/plesk-php-cleanuper is unable to actually perform the session cleanup, hence the size of the folder continues to grow and at this point every time the job runs and combs through all files the I/O weight goes to 100% and slows my entire server down to the point where the applications hosted on it are completely unaccessible.

How can I resolve this matter?
0
Comment
Question by:SWB-Consulting
  • 6
  • 3
9 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39993767
I think you can set the rights on this folder as follows:

chmod 1777 /var/lib/php/session

Using sticky bit nobody can change the rights on this folder but the root user.
0
 

Author Comment

by:SWB-Consulting
ID: 39994372
OK, but how do I get the actual session files to be generated so they're accessible to the root user? Right now they are only generated with rw permissions to the apache user.
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39994448
So the files get created with user apache:apache in rw? Is that the issue? I'm sorry, might have misunderstood ...

I'm assuming you already did the upgrade: http://kb.parallels.com/en/115704 ??
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:SWB-Consulting
ID: 39994541
No worries, yes I did that workaround on there. But I'm actually running PHP as module so not sure if that applies.

Yes, the problem seems to be that all session files are created with rw permission for ONLY the apache user. But the cleanup job is run under root.

Even when I try to remove a single file in that folder as root user it won't do it, it just finishes the delete command without any response and nothing has changed.
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39994626
You can change the permissions on those file though, no?

chmod 777 /var/lib/php/session/*

or change the owner for all files in that directory first then run the script again for cleanup?

chown root:root /var/lib/php/session/*
0
 

Author Comment

by:SWB-Consulting
ID: 39994673
True, if I do it manually one time I could do that. But on an ongoing basis I have an automated job running that always tries to remove those files.

Or I could maybe just run the job as a crontab under the apache user.

I understand and appreciate your idea, but it strikes me as a bit of a patch/workaround. Everything that is in place right now is the way plesk seems to have it set by default, so I'm wondering if there isn't some way to get the session files saved with less restrictive permissions?

I can't be the only one on plesk with this issue (although I haven't found anyone with exactly this issue)
0
 

Author Comment

by:SWB-Consulting
ID: 39994683
This is the cronjob that plesk has created to cleanup sessions:

[ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && find /var/lib/php/session -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib64/plesk-9.0/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete

Open in new window

0
 

Accepted Solution

by:
SWB-Consulting earned 0 total points
ID: 39995715
Actually I figured it out: I changed the permissions from the officially prescribed Plesk ones (1733) to 733. Now the root user can delete files in that folder.
0
 

Author Closing Comment

by:SWB-Consulting
ID: 40003501
I found the problem.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question