Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Community support for Plesk, CPanel, WebMin and others with insight from two of the founders of Plesk. Ask for help here! No question is too simple or complicated. :-)
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

(DISCLAIMER - I already posted this in PHP, but I think this might be the correct forum. I am desperate and not sure, so please forgive me in advance. Any help is greatly appreciated and please delete whichever post you feel is best)

Hi all,

Scott, it's been awhile, but I have been watching your progress from afar. Things are really developing.

Here is my question. And I am either a total noob, or I am not alone. Plesk 9.2.1, clean install, stock image off of 1and1, art updated. Running the latest of everything as of yesterday.

I used suPHP in the past, but found it had some issues. I am willing to go back, but I was excited about what P9.2.1 offered with the click and go FastCGI. My initial tests were positive. Set all Directories to 755, all files to 644, owner.psacln and it was straight forward. I was able to delete files from within a Joomla site after adding them and they used the ftp credentials. Everything was great. All I had to do next was do my trusty PHP settings in my vhost.conf file and websrvmgr the box.

I then went and set the necessary php.ini settings and restarted the webserver, and was stopped dead in my tracks after I realized they were no longer being picked up in the vhost.conf file. (and of course it ignores the safe_mode setting under plesk from within the control panel)

Now after well over 40-55 hours of non-stop searching and reading and searching (and more reading...), I have learned that I am lost, lol.

I learned that I am really running this as a wrapper and that it (FastCGI fcgi) is only pulling the php.ini settings from /etc/php.ini. But then I also saw that it was running as an apache module. So I don't know. I am just in need of a point in the right direction to tell me if I am wasting my time or not.

Here is what I have read that seems to touch on the issue I am having. I still have not decided what to do next. If I have to kludge a fix that is so complicated, then I may as well suPHP my way for now.

Here are SOME of the links:
http://www.forum.psoft.net/showthread.php?t=21125
http://forum.parallels.com/showthread.php?t=82866
http://forum.parallels.com/pda/index.php/t-83298.html
http://www.askapache.com/php/custom-php ... ricks.html
Good Link Below, I think he has the solution, but I couldn't get it working.
http://www.sebastian.himberger.de/blog/ ... h-fastcgi/

Not in any particular order, but the first one helped me wrap my brain around this, although it wasn't plesk specific. I absolutely did NOT want to surrender to writing a post and then having to wait :-( but I am defeated and I know I am not the only one having this problem.

Here is what I was trying to achieve:

-Virtual Domains each to have their own php.ini/php settings, I don't care how, but a place to provide unique per domain php settings. vhost.conf, a directory under etc, .htaccess, etc. whatever, I don't care as long as it works, lol.

-I need to be able to set open_basedir, display_errors, safe_mode, etc.
-This is critical for most of the popular applications like Joomla, SugarCRM, etc. (vTiger), all of which we use.

I am flat out stuck in the stuck with no place to go (like Richard Gear in "Officer and a Gentleman", lol). I completely surrender and will gladly buy a drink for anyone who can help. After all my homework, I just can't believe I am alone on this. I can't be the only one trying to use FastCGI and have unique / per domain php.ini settings. If I am, then I won't be for long ;-)

All the best.
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

Ok,

I am replying to my post instead of editing my last post, because I think I figured this out.

I'm in the early stages, but I have it working from the bash prompt just fine.

Tomorrow, after a good night's sleep (3:45am here), I provide what I did and maybe someone can help me punch through.

This should allow for using the vhost.conf file to make php settings changes with the only exeception being that you have to put your settings in a php.ini file. As it stands, I am doing it in the conf directory, but I'm dead tired and I will need help with this last piece. I am confident this will work.

Here is the problem I think.

mod_fcgid has to be greater than or = to version 2.1 to support arguments in FGCGWrapper.

so in my vhost.conf, the following is throwing an error about the aruments.
FCGIWrapper "/usr/local/bin/php-cgi -c /etc/" .php

When I run this from the command line:
/usr/bin/php-cgi -c /var/www/vhosts/domain.com/conf phpinfo.php |grep safe_mode

it will pick up the change I make in the php.ini file that resides in the conf directory (which I am also launching the test from)

So from command line, it works, but I get an error when I try to save and reload apache with FCGIW wrapper setting as per above. php-cgi is a binary, so maybe plesk is doing something that is preventing this from working as expected.

I hope this can help someone and I also help this can get some feedback. I am really stumped. It should have been as simple as enabling FastCGI for php in the control panel, editing the vhost.conf for the domain to include the wrapper telling it where to look for the php.ini config, and the putting in the php.ini settings we want for that domain.

UPDATE:
Ok, I think I cracked the case. I just did an rpm -qa |grep fcgi

psa-fcgi-2.4.0-2
psa-mod-fcgid-configurator-1.0-14
psa-mod_fcgid-1.10-3

SO!!!
Question: Scott, how can I upgrade psa-mod_fcgid ?

(only 3 days to figure all this out, that's all)
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

After my breakthrough lastnight, I re-read this post:
http://forum.parallels.com/showthread.php?t=87493

and "hannes42" explained it PERFECTLY!
http://forum.parallels.com/showpost.php ... ostcount=2

So, does this mean I should just use suPHP, or can FastCGI be made to work in Plesk 9?

Looks like php 5.3 finally gets this all working right. In the meantime, I am thinking suPHP or FastCGI+htscanner is the play ( like second option because I can allow users to change the basic settings which only affect them and keep the server side settings in our control open_basedir, etc.)

http://linkzuki.com/1b
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by BruceLee »

before you start having a lot of work, try this:
http://www.sebastian.himberger.de/blog/ ... h-fastcgi/


One problem with the current Plesk version (as with most Plesk versions :/) is that it has some nasty bugs. For example mod_rewrite doesn’t work with the FastCGI configuration. The problem is that the generated virtual host configuration has a small but important problem. The generated host looks something like this:

<VirtualHost 88.198.164.10:80>
ServerName playground.himberger.de:80
ServerAlias www.playground.himberger.de

<IfModule mod_fcgid.c>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /usr/bin/php5-cgi .php
Options ExecCGI
allow from all
</Files>
</IfModule>
</VirtualHost>

The issue with this configuration is the line “Options ExecCGI“. This line enables the execution of CGI scripts for this particular directory but overrides all the Options set earlier. These are in parts needed for mod_rewrite. To fix this the line should be “Options +ExecCGI“. Sadly changing the configuration doesn’t help because at the next opportunity Plesk will regenerate the config file and your change is gone.

Luckily there is a way around this…

Enable mod_rewrite (the solution)

Luckily Plesk allows you to append a custom configuration to the virtual host by creating a file vhost.conf in the ${yourvhost}/conf directory. By putting the following config in your vhost.conf you can take back the overwritten Options (don’t forget to restart the Apache HTTPD).

<Directory "/var/www/vhosts/${yourvhost}/httpdocs">
<Files ~ (\.php)>
Options All
</Files>
</Directory>

You have to be very specific (using the enclosing Directory directive) to cause the current setting to be overridden.

With this knowledge at hand we can do some other nice tricks.
Using a custom php.ini with fastcgi

Since we are now able to override the Plesk generated configuration we can also alter the fastcgi command and for example specify a custom php.ini:

<Directory "/var/www/vhosts/${yourvhost}/httpdocs">
<Files ~ (\.php)>
FCGIWrapper "/usr/bin/php5-cgi -c /etc/phpconfigs/${yourvhost}" .php
Options All
</Files>
</Directory>

The FCGIWrapper command will use the directory specified with the -c parameter for it’s php configuration. Simply put your php.ini in this directory and it will automatically be picked up. This way you can easily use a per customer PHP configuration with fastcgi and Plesk.
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

Bruce,

Thanks for the reply, but I already referenced that post. (see notes below) I am now looking at htscanner as a solution or cut bait and just go suPHP (which I don't want to do). I'm also considering rolling an update for plesk for fcgi (which I have absolutely no clue how to do or what that entails, lol) So my vision is: Native FastCGI using Plesk 9.2.1. Then use the model you referenced (which I posted earlier), but with a new mod_fcgi for plesk that is greater than 2.0. I have no idea if this will work or give me what I need, but in my opinion it is the most elegant if it works. IF (by all means, if you <plural> feel different, PLEASE post something.)

The problem is you can't use this line:
FCGIWrapper "/usr/bin/php5-cgi -c /etc/phpconfigs/${yourvhost}" .php


The reason is because you are passing more than one parameter and you need a newer version fcgi

"mod_fcgid has to be greater than or = to version 2.1 to support arguments in FGCGWrapper."

Plesk currently only has:
psa-mod_fcgid-1.10-3


(See snippet from my post earlier)
UPDATE:
Ok, I think I cracked the case. I just did an rpm -qa |grep fcgi

psa-fcgi-2.4.0-2
psa-mod-fcgid-configurator-1.0-14
psa-mod_fcgid-1.10-3

SO!!!
Question: Scott, how can I upgrade psa-mod_fcgid ?
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

SOLVED!

I figured it all out. Thank you all for the prompt replies and the help.

Keep up the good work Scott.
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by BruceLee »

Great that you figured it out. Sorry that my post was something you alreadey tried.
I overlooked it. How did you solve it?
It think a solution would be helpful for other people and for me, too.
Thanks
ClearlyTechnical
Forum User
Forum User
Posts: 37
Joined: Wed Feb 09, 2005 6:27 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by ClearlyTechnical »

Bruce,

I am going to document everything and post a link to my how-to. I am working on some last issues as it relates to tidying up and making sure everything is secure.

It works like a dream. Parallels Support is nothing short of PATHETIC!

(I had to get that out).

It was amazing how simple this was after I knew where to look.

Take care.

Thanks,
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by BruceLee »

Hi,

do you have worked out the last issues and found some time document it?
I would appreciate it.

Thanks
mneese
Forum Regular
Forum Regular
Posts: 218
Joined: Thu Apr 23, 2009 12:08 pm

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by mneese »

I don't have any idea what this person did, but if you have 9.2.1, there was posted by plesk a patch to cover such issues. Also, simply upgrading to 9.2.2 would handle the issues also.

I wonder why he didn't discover within the plesk panel, under web settings for each domain the option to have php run as apache or fcgi?

Don't you love it when you invest time and energy to help someone, then they drop out of sight with the solution?
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by BruceLee »

That's what I thought too. But maybe he had a special problem caused by conditions we don't know until he
writes his documentation. And after reading it a check would be easy.

You are right...a short response would be nice :)
Let's give him some time :)
Bierteufel
Forum User
Forum User
Posts: 8
Joined: Thu Oct 22, 2009 8:03 am

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by Bierteufel »

ClearlyTechnical wrote:SOLVED!

I figured it all out. Thank you all for the prompt replies and the help.

Keep up the good work Scott.

Can you tell me you you have solved the problem with the

psa-mod_fcgid-1.10-3 Update

??

Hmm, no answer.

But i found this one:

http://forum.parallels.com/showthread.php?t=92562

And it works.
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HELP!

Unread post by BruceLee »

Based on the thread http://forum.parallels.com/showthread.php?t=92562:

Code: Select all

#!/bin/sh
# Custom PHP FCGID wrapper for Plesk domains

PHPRC="/etc/php-ini.d/php-${UID}.ini"
[ -f ${PHPRC} ] || PHPRC="/etc/php.ini"

export PHPRC
exec /usr/bin/php-cgi.app
I'm having some questions about security and permissions?
Is it safe putting the php.ini files like in this script in /etc/php-ini.d/?
Would /var/www/vhosts/php-ini/domain.tld/php.ini be better or the same?
Or can I set permissions in /var/www/vhosts/domain.tld/some_folder_for_php.ini in that manner that
the fastcgi-vhost-user can read and execute but not change it?

Thanks
thewolf
Forum User
Forum User
Posts: 24
Joined: Tue Dec 21, 2004 7:53 am

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HEL

Unread post by thewolf »

Does anyone know if newer versions of Plesk support specific PHP settings per each domain?

Thanks.
BruceLee
Forum Regular
Forum Regular
Posts: 879
Joined: Sat Mar 28, 2009 6:58 pm
Location: Germany

Re: Per Domain php.ini Settings with FastCGI Plesk 9.2.1 HEL

Unread post by BruceLee »

you can set php settings through vhost config for each domain with standard plesk (8.x or 9.x) options.
Post Reply