• 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.

FastCGI PHP 5.2.13 / 5.3.2 NTS (Non thread safe)

A

ArnaudT

Guest
Hello Parallels' Team,

things are evolving fast regarding Windows Server 2008 (IIS) and PHP. Now thanks to Microsoft and PHP team efforts, we have very decent PHP web servers with high performances and reliability.
This is mostly possible mostly using IIS7, FastCGI and Non Thread Safe (NTS) PHP.

The latest asset, WinCache 1.1 (http://www.iis.net/download/wincacheforphp) brings performance even further, providing, for free, OpCode, sessions, files and user caching. Let's just say we can simply double the performances using it, without any change in the PHP code / pages.
WinCache is also restricted to only the Non Thread Safe (NTS) PHP versions.

On the other side, let's consider Plesk 9.x. It provides 5.2.x Thread Safe (TS) PHP libraries, usable as CGI, FastCGI and ISAPI mode.
If in the past, I used to be a big fan of ISAPI. I ended to FastCGI only recently. And it seems that even Microsoft has stopped supporting ISAPI since 2009.
Having Thread Safe libraries is probably a requirement when you use certain external PHP extensions. Though, it would be interesting to allow the user to choose between NTS or TS.

Sorry for those thoughts and considerations, back to my how to question:
If I replace my PleskPHP5 by a PHP 5.2.13 NTS install, Plesk control panel does not detect anymore this version, which is annoying for users (and even the admin) as it requires to add manually PHP 5 support (handler mapping) from IIS.
How to proceed to keep the PHP 5.2.13 (NTS) version appearing in components management list?

I tried to put the unsused (TS/Isapi) DLL, in the folder but it did not work. I was not keen mixing TS/NTS stuff anyway.

Anyway, what are Parallels' plans for Plesk 10 concerning PHP 5.2.x and 5.3.x support?

I am seriously starting to study some procedures to have more than the two versions of PHP installed. Especially to smoothly migrate some sites from PHP5.2 to 5.3.
At least, I can restore the original PHP 5.2.x TS used by Plesk (and its detection). Leave this for small sites not requiring high performances, while I use PHP 5.2 NTS, PHP 5.3 NTS with FastCGI and WinCache configured manually (by scripts over IIS).
I cannot say it is elegant, but for now, it is the only thing coming to my mind, while we wait for Plesk 10 release in Autumn or Winter '10.

Thank you for reading, and for your feedback.

Kind regards,
Arnaud.
 
I'm not sure, it's been a while, but I think my Plesk installation only recognised newer PHP versions if I put 'expose_php=on' in the php.ini.
 
Thanks for the tip.

I tried to to change expose_php to On and to restart IIS. Still no luck.

Anyway, I finally managed to install more than just the two PHP installs provided by Plesk. It is working properly.
 
Installing more than 2 PHP instances in the Plesk Windows

Hi ArnaudT,

I'm having the same issue as you had last time. Is it possible to get some information how you managed to install more than just the two PHP installs provided by Plesk?

Thanks,

Hau
 
Actually you need to keep the packaged PHP installs provided by Plesk untouched.

You can add some additional PHP versions in the C:\Program Files (x86)\Parallels\Plesk\Additional\.

Here is the procedure I am using:
- you create a folder named PHP535NTSVC9X64 (I named it to know exactly what type of build it is).
- unzip the build inside.
- add a php.ini (if it is PHP5.3, you might need to start over with a fresh configuration)
- pay attention to have the correct folders for extension. Mine is include_path=".;C:\Program Files (x86)\Parallels\Plesk\Additional\PHP534NTSVC9\pear;./includes;./pear"
- add any compatible additional extension (like Wincache) in the ext folder.
- in your Plesk domain site, uncheck PHP support.
- in IIS7, go to the given site.com and click on Handler Mappings
- Click on the right, on Add Module Mapping
- Request path: *.php Module: FastCgiModule
- for the Executable: browse, look for php-cgi.exe and don't forget to add double quotes. For instance: "C:\Program Files (x86)\Parallels\Plesk\Additional\PHP535NTSVC9X64\php-cgi.exe"
- Name it clearly PHP_5_3_5_NTS_VC9_name_site
- When you click ok you got a message to create a FastCGI application for this executable, click on Yes.
- In IIS7, go to the server main node (right below Start Page).
- Click on FastCgi Settings
- Select the proper Full Path corresponding to your new PHP application and double click on it
- Set InstanceMaxRequests to 10000 instead of 200 (I am not sure why I still do that)
- At the same line, to the right of EnvironmentVariables, double click on (Collection)
- In the environmentVariables Collector Editor, create a variable
- Name: PHPRC Value: C:\Program Files (x86)\Parallels\Plesk\Additional\PHP535NTSVC9X64\ (that's your new PHP install path). The PHPRC env variable provides some information to where to find the php.ini file.
- Eventually restart the application pool linked to your domain, or restart the IIS service from the IIS7 main node. (not forcefully required)
- Place a phpinfo.php file containing <?php phpinfo(); ?> in your site web root
- Try to see if you can access it, and check out that all is ok and loaded.

I have more than 9 versions of PHP on my server. It works nicely. Still, you might need to be careful if you have several versions using the same application pool for several subdomains. Sometimes, mixing a PHP 5.2 32bit build with a PHP 5.3 64bit build causes issues. Though I just managed to have two PHP 5.3 x64 NTS builds working together on the same domain.
Note that you can also make the handler using a web.config in your web root.

I hope you will be able to make it.
Arnaud.

edit to fix typos
 
Last edited by a moderator:
Hi ArnaudT,

First of all, thanks a lot for the information. However, I'm still stuck at the step below. I couldn't find the exe file anywhere. There are only dll files in that folder. Can you please advise?

- for the Executable: browse, look for php-cgi.exe and don't forget to add double quotes. For instance: "C:\Program Files (x86)\Parallels\Plesk\Additional\PHP535NTSVC9X64\php-cgi.exe"

Thanks so much,

Hau
 
Hi ArnaudT,

Don't worry about my last message. I must have gone out of my mind. I found it. Thanks a lot anyway.

Hau
 
Hi ArnaudT,

Don't worry about my last message. I must have gone out of my mind. I found it. Thanks a lot anyway.

Hau

Hi Hau,

could you make it? Please let me know if anything in unclear or require more details. It took me a while to be familiar with this method. ;)
 
Hi ArnaudT,
Are you still responding to this forum? If so, I have a question for you regarding your great "How-to" above.
Thanks,
E.
 
Wait, I just realized that your latest post was yesterday.

Ok, so here is my question(s).

1. You wrote, "Add a php.ini (if it is PHP5.3, you might need to start over with a fresh configuration)". Do you have a sample of your php.ini file to review?
2. You gave some settings for FastCGI settings. My dedicated XL server from 1&1 doesn't have a management console under IIS7 for FastCGI. Should I use the ISAPI or CGI management? If so, I can't follow your instructions following the "Click FastCGI Settings". Any suggestions?
3. Regarding your post regarding using phpmanager, do you know if that will work with Plesk. What I mean is, If I have multiple versions of PHP installed (e.g., PHP4-pre-installed for Plesk CP, PHP5.2.6-pre-installed, and PHP5.3.5-my install for other applications), will Plesk give those options when setting up a domain to use PHP?

Thanks for your help,
E.
 
Hi Erok415,

I'm still getting the notifications of new messages. So yes, I should answer :)

1. For the php.ini, you can mostly use the same settings that those provided in the 5.2. Still this is better to take the php.ini 5.3 distribution and to adjust the settings to the closest to your needs.
It is important to understand the settings you use there. There is no ideal sample, as depending of the PHP scripts you use, you would need some extensions, and not some others, some settings on or off. You may want to get ouput buffering or not, timeout for your scripts, etc.

2. Indeed, by default, Windows 2008 Server (not the R2) does not have the FastCGI interface included. You can get it from there and then install it:
http://www.iis.net/download or from the web installer (should be in your console).

I noticed that some new versions allow to have the same than Windows 2008 R2. It has a new property, and you don't need to use the PHPRC env var.
For some reason, that version did not want to install on my server. So I use the previous FastCGI interface. Fair enough.

3. I cannot really say about PHP Manager and the Plesk PHP versions. In theory, it should work as it will edit the php.ini and the handler correctly wherever you locate the PHP folder for him.
The PHP versions but the two Plesk directories (Php and PleskPhp5) won't be seen by Plesk. I could easily use TS (thread safe) Plesk 5.2.x 32 bits versions instead of the version released in the Plesk package (until 5.2.13, I have not tested the recent versions).
For some reason, it did not work that well with the recent NTS (non thread safe). It was not detected.

So you can have 5.2.13 TS (or maybe better) instead of 5.2.6.

Still to get much better performances, FastCGI should be used with NTS versions. As Plesk tries to make both ISAPI and FastCGI modes, they provide TS versions.

What I explain so far applies to Plesk 9.5.x. I have no experience or knowledge for version 10.x.
I have not even considered to migrate as my mail server is not supported anymore by Plesk 10.

There is no guarantee of any sort, I am just a Plesk user sharing a bit of experience. So be careful, make some backup (especially the Plesk PHP installs before changing them), as it is really easy to break things. Many times, I realized that I had to roll back when things were broken.
 
Thanks! That was informative. You don't know how long I searched for a viable solution to multiple installs of PHP on a Windows 2008 R2 server with plesk.

I did actually break some stuff though. I can't install Drupal 6.19 or D7 now because of a PDO error after trying to install PHP5.3.5 pre reading your great instructions. Since then, I have been able to follow your instructions sans the FastCGI instructions. Here is my current error (All other errors have been fixed as a result of my bad upgrade.):

# Warning: PDO::__construct(): Premature end of data (mysqlnd_wireprotocol.c:554) in DatabaseConnection->__construct() (line 300 of D:\inetpub\vhosts\%Site%\httpdocs\%Dir%\includes\database\database.inc).
# Warning: PDO::__construct(): OK packet 1 bytes shorter than expected in DatabaseConnection->__construct() (line 300 of D:\inetpub\vhosts\%Site%\httpdocs\%Dir%\includes\database\database.inc).
#

In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file.

Althoug I can run PHP pages, this error stops me from finishing the install. Plus, a WordPress blog will not run now. Basically it all comes down to connecting to MySQL. I made sure to uncomment "extension=php_mysql.dll and extension=php_pdo_mysql.dll" in both my C:\\Windows\php.ini and %Plesk_Dir%\plesk\additional\PleskPHP5\php.ini files.

I'm running Plesk CP 9.0.1 currently. Any extra help is appreciated.

PS. Thanks for responding so quick!
 
Well one thing to know with mysqlnd driver (provided with PHP5.3, and used by PDO, mysql and mysqli drivers) is that the password encoding requires to have a higher level of security (or something like that).
Plesk in version 9 or 9.5 does not generate that kind of password encoding.

So any access to a mysql database from PHP5.3 using mysqlnd would fail.

The fix is to open myPhpAdmin, connected with the very user created for the PHP web application and to type the SQL command:

SET PASSWORD = PASSWORD('thepasswordyouuse')

Then, PHP5.3 should be able to connect to this database.

Well I have also spent days to solve those things :(.
Hopefully you should be able to connect.
 
I understand what you are saying in reference to Plesk. But why would Plesk interfere if I'm installing say, a Drupal app independently from Plesk? I can try the myPHPAdmin and let you know what happens....

It didn't work, Ugh...!

I'm still getting the same error. I installed PHPmanager along with PHP 5.2.x and 5.3.5. They were installed in C:\\Windows (86)\php\. I'm going to try and install them in the directories were my Plesk php dir's are installed and see if that works.
 
I understand what you are saying in reference to Plesk. But why would Plesk interfere if I'm installing say, a Drupal app independently from Plesk? I can try the myPHPAdmin and let you know what happens....

It didn't work, Ugh...!

I'm still getting the same error. I installed PHPmanager along with PHP 5.2.x and 5.3.5. They were installed in C:\\Windows (86)\php\. I'm going to try and install them in the directories were my Plesk php dir's are installed and see if that works.

If you read the procedure I gave, the PHP versions were placed in Plesk\Additionnal folder. Of course you could place it somewhere else, but you would have to deal with permissions each time you reconfigure Plesk.

The issue you had reporting the SQL error is independant from Plesk. It is a known thing between mySQL4/5 and PHP 5.3.x using mysqlnd.

Don't forget each time you made a change in PHP.INI or in a PHP folder to restart IIS or the worker(s) associated.

And before installing Drupal or anything, you should make a <?php phpinfo(); ?> page working. That's the way to troubleshoot your issues.
 
I just received this article from my server support team. They say that this article http://kb.odin.com/6670 explains how to properly update PHP so that Plesk will use most up to date PHP script. Although this is great, I really like your idea.
Thanks,
Erik
 
I just received this article from my server support team. They say that this article http://kb.odin.com/6670 explains how to properly update PHP so that Plesk will use most up to date PHP script. Although this is great, I really like your idea.
Thanks,
Erik

Well that's what I was doing mostly before I ran into some issues recently, and then started this very thread.
Frankly do I want to waste 40% speed performance because I have to use Thread Safe versions? No I don't think so.
My PHP server is more than twice faster now, maybe even 300% in some cases, not thanks to Plesk, but to my own optimizations.
 
Wow, I didn't see the TS version mentioned in the article. But I do know that we need to use NTS for Windows. Thanks for your thoughts.
E.
 
Wow, I didn't see the TS version mentioned in the article. But I do know that we need to use NTS for Windows. Thanks for your thoughts.
E.

well, you may prefer to have NTS with FastCGI and TS with ISAPI. I think it should be that way. I guess that's the issue with Plesk Panel as it only proposes one version for both modes in 9.x.
Reading some recent thread, it seems that the problem is still there in Plesk 10.x. http://forum.parallels.com/showthread.php?t=107964

FastCGI is probably now the best way to make PHP working with Windows and IIS. Microsoft and Zend have worked together to make it working well.
The consequence is that PHP/ISAPI doesn't exist anymore with PHP5.3.x
http://news.php.net/php.internals.win/166
 
Back
Top