• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Two PHP versions linux Plesk HOWTO

will this work for a subdomain? thanks

Hi,

I believe it will only work it the subdomain is a dedicated hosting. If you place the subdomain into a subdir of the main account, it will use the same PHP Version of the same account.

Thanks
Patrick
 
From one of my Plesk 10 servers:

# ATTENTION!
# DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK
# FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM
# MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE
# FOLLOWING FILE(S):
#/var/www/vhosts/domain.com/conf/vhost.conf
#/var/www/vhosts/domain.com/conf/vhost_ssl.conf
#/var/www/vhosts/domain.com/subdomains/subdomain1/conf/vhost.conf
#/var/www/vhosts/domain.com/subdomains/subdomain2/conf/vhost.conf
#/var/www/vhosts/domain.com/subdomains/subdomain3/conf/vhost.conf
#/var/www/vhosts/domain.com/subdomains/subdomain4/conf/vhost.conf


I have created one such vhost.conf changing the Directory to:

<Directory /var/www/vhosts/domain.com/subdomains/subdomain1/httpdocs>



All worked and the PHP 5.4.9 version is working on this subdomain.



However, looking at the place subdomains are stored, I believe this to be a server which was upgraded from a pre Plesk 10 version.
Because Plesk 10 does not normally create a subdomains folder anymore.


How this would be implemented for Plesk 11 -> I have no idea yet, I'd have to investigate.




I'm hoping Parallels will incorporate this feature into Plesk in the near future,
it would make our hackjob unnecessary.
 
Last edited:
From one of my Plesk 10 servers:




I have created one such vhost.conf changing the Directory to:

<Directory /var/www/vhosts/domain.com/subdomains/subdomain1/httpdocs>



All worked and the PHP 5.4.9 version is working on this subdomain.



However, looking at the place subdomains are stored, I believe this to be a server which was upgraded from a pre Plesk 10 version.
Because Plesk 10 does not normally created a subdomains folder anymore.


How this would be implemented for Plesk 11 -> I have no idea yet, I'd have to investigate.




I'm hoping Parallels will incorporate this feature into Plesk in the near future,
it would make our hackjob unnecessary.


in plesk 11 the subdomain is under the vhost /var/www/vhosts/subdomain.domain.com together with the main domain /var/www/vhosts/domain.com

but plesk is mapping

domain.com/httpdocs
domain.com/support <--- the directory of subdomain.domain.com
 
Find out where vhost information (apache) is stored for subdomains on Plesk 11.
If it is stored in the main httpd.include then that is where the vhost.conf needs to be included.

I have researched this before,
and I believe Plesk 10+ still makes a subdomains directory, but only for configuration files.
 
bzip2 problem

Hi there!

I`ve got a problem with the bzip2 extension:

checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

Bzip2 on the host is up to date...
Where can I edit the default path of bzip2 in the configure?

I've got Ubuntu 10.04.4 LTS
and Plesk 11.0.9 Update #32

Greets Dave
 
check if you got the bzip2 devel package installed ...

And once more: This Thread is NOT intended to be used for "php compile issues" - for them please use the appropriate boards / mailing lists ...
This Thread is intended for problems related with implementing those already compiled PHP binaries into Plesk! ;-)

Thank you!

Andreas Schnederle-Wagner
 
And once more: This Thread is NOT intended to be used for "php compile issues" - for them please use the appropriate boards / mailing lists ...
This Thread is intended for problems related with implementing those already compiled PHP binaries into Plesk! ;-)

Thank you!

Andreas Schnederle-Wagner
Exactly!
Please stop dump here all your problems with PHP.
 
I can't get work second PHP. My config looks like this:

[root@vps4 cgi-bin]# ll -a /var/www/vhosts/DOMAINNAME/
total 80
drwxr-xr-x 20 root root 4096 Feb 8 16:55 .
drwxr-xr-x 16 root root 4096 Feb 8 16:56 ..
drwxr-x--- 5 DOMAINUSER psaserv 4096 Feb 8 16:55 anon_ftp
drwxr-xr-x 2 root root 4096 Feb 8 16:55 bin
drwxr-x--- 4 DOMAINUSER psaserv 4096 Feb 9 18:27 cgi-bin
drwxr-x--- 2 root psaserv 4096 Feb 9 19:02 conf
drwxr-xr-x 2 root root 4096 Feb 8 16:55 dev
drwxr-xr-x 2 root psaserv 4096 Feb 8 16:55 error_docs
drwxr-xr-x 2 root root 4096 Feb 8 16:55 etc
drwxr-x--- 29 DOMAINUSER psaserv 4096 Feb 9 18:03 httpdocs
drwxr-xr-x 2 root root 4096 Feb 8 16:55 lib
drwxr-x--- 2 root psaserv 4096 Feb 9 19:02 pd
drwx------ 2 DOMAINUSER root 4096 Feb 8 16:55 private
drwxr-x--- 13 DOMAINUSER psaserv 4096 Feb 9 18:02 site1
dr-xr-x--- 7 DOMAINUSER psaserv 4096 Feb 8 16:55 statistics
drwxr-xr-x 2 root psaserv 4096 Feb 8 16:55 subdomains
drwxrwxrwt 2 root root 4096 Feb 8 16:55 tmp
drwxr-xr-x 4 root root 4096 Feb 8 16:55 usr
drwxr-xr-x 3 root root 4096 Feb 8 16:55 var
drwxr-xr-x 2 root psaserv 4096 Feb 8 16:55 web_users
[root@vps4 cgi-bin]# ll -a /var/www/vhosts/DOMAINNAME/cgi-bin/
total 16
drwxr-x--- 4 DOMAINUSER psaserv 4096 Feb 9 18:27 .
drwxr-xr-x 20 root root 4096 Feb 8 16:55 ..
d--x-----x 2 DOMAINUSER psacln 4096 Feb 9 19:52 .cgi_wrapper
drwxr-xr-x 2 DOMAINUSER psacln 4096 Nov 12 16:21 test
[root@vps4 cgi-bin]# ll -a /var/www/vhosts/DOMAINNAME/cgi-bin/.cgi_wrapper/
total 12
d--x-----x 2 DOMAINUSER psacln 4096 Feb 9 19:52 .
drwxr-x--- 4 DOMAINUSER psaserv 4096 Feb 9 18:27 ..
-r-x------ 1 DOMAINUSER psacln 165 Feb 9 19:52 .phpwrapper
[root@vps4 cgi-bin]# cat /var/www/vhosts/DOMAINNAME/cgi-bin/.cgi_wrapper/.phpwrapper
#!/bin/sh
export PHPRC=/var/www/vhosts/DOMAINNAME/etc/
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=1000
exec /usr/local/bin/php52-cgi/bin/php-cgi
[root@vps4 cgi-bin]# cat /var/www/vhosts/DOMAINNAME/conf/vhost.conf
<Directory /var/www/vhosts/DOMAINNAME/httpdocs>
RemoveHandler fcgid-script
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/vhosts/DOMAINNAME/cgi-bin/.cgi_wrapper/.phpwrapper .php
Options +ExecCGI
allow from all
</Files>
</IfModule>
</Directory>

Apache error_log

[Sat Feb 09 20:03:16 2013] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Sat Feb 09 20:03:16 2013] [error] [client x.x.x.x] Premature end of script headers: info.php

suexec_log

[2013-02-09 20:14:22]: uid: (10005/DOMAINUSER) gid: (504/504) cmd: .phpwrapper

PHP config.nice

'./configure' \
'--with-libdir=lib' \
'--cache-file=../config.cache' \
'--prefix=/usr/local/bin/php52-cgi' \
'--with-config-file-path=/usr/local/bin/php52-cgi/etc' \
'--disable-debug' \
'--with-pic' \
'--disable-rpath' \
'--with-bz2' \
'--with-curl' \
'--with-freetype-dir=/usr/local/bin/php52-cgi' \
'--with-png-dir=/usr/local/bin/php52-cgi' \
'--enable-gd-native-ttf' \
'--without-gdbm' \
'--with-gettext' \
'--with-gmp' \
'--with-iconv' \
'--with-jpeg-dir=/usr/local/bin/php52-cgi' \
'--with-openssl' \
'--with-pspell' \
'--with-pcre-regex' \
'--with-zlib' \
'--enable-exif' \
'--enable-ftp' \
'--enable-sockets' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-sysvmsg' \
'--enable-wddx' \
'--with-kerberos' \
'--with-unixODBC=/usr' \
'--enable-shmop' \
'--enable-calendar' \
'--with-libxml-dir=/usr/local/bin/php52-cgi' \
'--enable-pcntl' \
'--with-imap' \
'--with-imap-ssl' \
'--enable-mbstring' \
'--enable-mbregex' \
'--with-gd' \
'--enable-bcmath' \
'--with-xmlrpc' \
'--with-ldap' \
'--with-ldap-sasl' \
'--with-mysql' \
'--with-mysqli' \
'--with-snmp' \
'--enable-soap' \
'--with-xsl' \
'--enable-xmlreader' \
'--enable-xmlwriter' \
'--enable-pdo' \
'--with-pdo-mysql' \
'--with-pdo-pgsql' \
'--with-pear=/usr/local/bin/php52-cgi/pear' \
'--with-mcrypt' \
'--without-pdo-sqlite' \
'--with-config-file-scan-dir=/usr/local/bin/php52-cgi/php.d' \
"$@"

PHP works fine.

[root@vps4 cgi-bin]# /usr/local/bin/php52-cgi/bin/php-cgi -v
PHP 5.2.17 (cgi) (built: Feb 9 2013 19:25:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

I use latest Plesk 11 with CentOS 6. Second PHP is 5.2.17.

I have no idea what I'm doing wrong. :(
 
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):
Code:
/var/log/httpd/error_log

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.
 
Last edited:
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


Thank you r.lambda !
This will clarify alot for those that are still struggling with the concept and can't get it to run.


From what I've heared at WHD 2013, Plesk 11.5 is to hit release on March 28th (so in just 2 days).
Correct me if I'm wrong and if it was another product or date.


What we still need from Parallels are the recommended PHP configure flags.
So that we can compile all our PHP versions the way Parallels deems them the most optimal.
(I'd just like a 5.2 and 5.4 with the same compilation options Parallels uses for the 5.3 they ship, which you can find via phpinfo(); but would be handier to just have their guidelines).
 
Hi,

I've seen that several of you were struggling with the same problem as I. I've read through the whole thread, but unfortunately none of your tips did the trick for me.

The problem I have is that that PHP version isn't loaded correctly through FastCGI even though it is configured and built correctly. Also, I've followed all of the steps in your detailed tutorial.

Nevertheless, I get the following error when opening a PHP file (actually only containing the phpinfo):
[Sat Apr 06 21:53:01 2013] [warn] [client 213.89.160.46] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Sat Apr 06 21:53:01 2013] [error] [client 213.89.160.46] Premature end of script headers: info.php

Would be really nice if somebody could help me :)

ls -la /var/www/vhosts/domain.com/
total 64
drwxr-xr-x 16 root root 4096 Apr 6 18:14 .
drwxr-xr-x 8 root root 4096 Apr 6 15:46 ..
drwxr-x--- 5 domain psaserv 4096 Apr 6 15:46 anon_ftp
drwxr-x--- 4 domain psaserv 4096 Apr 6 21:17 cgi-bin
drwxr-x--- 2 root psaserv 4096 Apr 6 21:33 conf
drwxr-xr-x 2 root psaserv 4096 Apr 6 15:46 error_docs
drwxr-xr-x 2 root root 4096 Apr 6 15:46 etc
drwxr-x--- 12 domain psaserv 4096 Mar 24 13:38 httpdocs
drwxr-x--- 2 root psaserv 4096 Apr 6 15:51 pd
drwx------ 2 domain root 4096 Apr 6 15:46 private
dr-xr-x--- 7 domain psaserv 4096 Apr 6 15:46 statistics
drwxr-xr-x 2 root psaserv 4096 Apr 6 15:46 subdomains
drwxr-xr-x 2 root psaserv 4096 Apr 6 15:46 web_users

ls -la /var/www/vhosts/domain.com/cgi-bin/
total 16
drwxr-x--- 4 domain psaserv 4096 Apr 6 21:17 .
drwxr-xr-x 16 root root 4096 Apr 6 18:14 ..
d--x-----x 2 domain psaserv 4096 Apr 6 21:18 .cgi_wrapper
drwxr-xr-x 2 domain psaserv 4096 Apr 6 15:46 test

ls -la /var/www/vhosts/domain.com/cgi-bin/.cgi_wrapper/
total 12
d--x-----x 2 domain psaserv 4096 Apr 6 21:18 .
drwxr-x--- 4 domain psaserv 4096 Apr 6 21:17 ..
-r-x------ 1 domain psaserv 160 Apr 6 21:18 .phpwrapper

cat /var/www/vhosts/domain.com/cgi-bin/.cgi_wrapper/.phpwrapper
#!/bin/sh
export PHPRC=/var/www/vhosts/domain.com/etc/
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=1000
exec /usr/local/php5217-cgi/bin/php-cgi

cat /var/www/vhosts/domain.com/conf/vhost.conf
<Directory /var/www/vhosts/domain.com/httpsdocs>
RemoveHandler fcgid-script
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/vhosts/domain.com/cgi-bin/.cgi_wrapper/.phpwrapper .php
Options +ExecCGI
allow from all
</Files>
</IfModule>
</Directory>

Thanks,
Daniel
 
Last edited:
Hi Daniel.

I need to see your suexec_log
Also turn your php startup errors on in php.ini and ./php-cgi -v

The problem I have is that that PHP version isn't loaded correctly through FastCGI even though it is configured and built correctly.

There are many reasons for this happening. I need to see your suexec_log so we can narrow the solution-space.
 
Hi r.lambda,

My suexec.log is empty, and also after switching on startup errors, the error_log still shows the same two errors messages as above.

The output of the /usr/local/php5217-cgi/bin/php-cgi -v is:
PHP 5.2.17 (cgi-fcgi) (built: Apr 6 2013 21:50:06)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
 
I got the same problem.

[Thu Apr 18 09:49:43 2013] [warn] [client <IP>] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Apr 18 09:49:43 2013] [error] [client <IP>] Premature end of script headers: test.php


./php-cgi -v
PHP 5.4.0 (cgi-fcgi) (built: Apr 17 2013 11:43:20)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

tail -f /var/log/httpd/suexec_log

[2013-04-18 10:22:00]: uid: (10001/<user>) gid: (507/507) cmd: .phpwrapper


Could that be the reason ?
I compiled php-5.4 but the fastcgi option is not available.

configure: WARNING: unrecognized options: --enable-fastcgi
 
Read the NEWS file please:

- Improved and cleaned CGI code:
. FastCGI is now always enabled and cannot be disabled.
See sapi/cgi/CHANGES for more details. (Dmitry)
. Added CGI SAPI -T option which can be used to measure execution
time of script repeated several times. (Dmitry)
 
Thanks for this great tutorial! Finally it worked for me! First i had the problem with "resetting peers" also, but then i recompiled php with "--enable-fastcgi" as mentioned somewhere above in this topic, that did the magic for me! I hope this comment helps someone, but thanks again for this great tutorial!
 
Back
Top