Running different php fcgi versions in multiple virtual subdomains
Hello, just stopping by with some information...
If you can't wait for Plesk 11.5 to hit production, it's entirely possible in Plesk 11.1 to make multiple PHPs work on a shared box, under one IP.
Here's the relevant file structure (I'm on EL6, it's analogous for any other *nix)
Code:
/var/www/vhosts/
->domain.com/
-->[docroot for domain.com]/
-->[docroot for sub1.domain.com]/
-->[docroot for sub2.domain.com]/
-->etc/
--->[optional php.ini that overrides global php.ini]
-->conf/
--->vhost.conf
-->cgi-bin/
--->.cgi_wrapper/
---->[fcgi wrapper for domain.com]
---->[fcgi wrapper for sub1.domain.com]
---->[fcgi wrapper for sub2.domain.com]
->sub1.domain.com/
-->etc/
--->[optional php.ini that overrides global php.ini]
-->conf/
--->vhost.conf
->sub2.domain.com/
-->etc/
--->[optional php.ini that overrides global php.ini]
-->conf/
--->vhost.conf
Key points:
* You tell each domain which wrapper to use through its vhost.conf
* The fcgi wrappers can point to different php installations, it's extremely flexible.
* Each (sub)domain gets its own php.ini
Here's the relevant ./configure options for compiling php
Code:
'--sysconfdir=/etc' \
'--libdir=/usr/lib' \
'--mandir=/usr/local/[B]PHPX.Y.Z[/B]/man' \
'--prefix=/usr/local/[B]PHPX.Y.Z[/B]' \
'--with-config-file-path=/usr/local/[B]PHPX.Y.Z[/B]/etc' \
'--with-config-file-scan-dir=/usr/local/[B]PHPX.Y.Z[/B]/etc/php.d' \
Name the php folder whatever you want, just remember to make sure the wrapper points to the correct folder.
Make sure you set the correct perms and owner on .cgi_wrapper/ and the wrapper scripts or fcgi/suexec will kill itself
The worst part is debugging all this.
Turn on debug logging in httpd.conf.
the relevant log should be found in (this is subject to OS):
You should see suexec being run. If you don't see it, you have misconfigured httpd / your vhost.conf / whatever
In this case, go back to step 1 and reread.
If your apache log is getting: exit()s, communication errors, permission mismatch
but the suexec process is still being spawned, that means you're almost done.
Information about log files:
* The httpd logs, even on debug mode will only show suexec being spawned and return codes. Therefore the log is only useful to see if httpd is talking to the wrapper.
* The suexec_log is where you'll spend most of your time, it's especially touchy about permissions and owners.
* Startup errors are not logged in php (to my knowledge). You can check by running in the console: /path/to/bin/php -v
The errors can mean a couple things:
- The PHP script you're trying to run is running into E_ERROR or E_PARSE
- Your php-cgi is running into startup errors. Turn on startup error reporting in php.ini
Then run /path/to/bin/php-cgi -v . Fix any warnings and whatever, just to be sure.
- Either your perms/owners were set incorrectly somewhere... please make sure they're not
- suexec_log keeps telling you permission mismatches because Plesk doesn't like suexec, and vice versa
Fix: replace apache's bundled suexec with Plesk's bundled suexec
Code:
cp -arf /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec
- You're still getting nothing, even though all the logs are telling you its rosy: look above, replace suexec!!!
Remember to restart httpd!
GOOGLE EVERYTHING.
Good hunting folks.