htaccess & php[45]-script

priestjim

Well-Known Member
#1
Hi!

I am trying to give my Plesk hosting clients a method of choosing between php4 and php5 without changing something in Plesk's configuration files. The quickest and most unobtrusive solution I've come so far is using .htaccess files inside the client's httpdocs directory with this line:

Code:
AddHandler php5-script php php3 php4 php5
to force PHP5 versioning and

Code:
AddHandler php4-script php php3 php4 php5
to force PHP4 versioning.

Unfortunately, while changing from PHP4 to PHP5 works, the other way around does not (PHP5->PHP4). Am I doing something wrong? Is it a bug?

Thanks in advance!
 
#4
Hello,
I want PHP to work in my HTML files with .htacess

I added

AddType application/x-httpd-php .html .htm

I tested my html file with php code but it is showing blank page, what should I use, any idea would be great.

Regards,
Pasha
 

mistwang

LiteSpeed Staff
#7
It looks correct. how about .php file? works as expected?

Check the server level script handler configuration from LSWS console. You should have a script handler for 'php', if not, only have script handler for 'php5', then you need to change the MIME type to "application/x-httpd-php5", it must match the script handler configuration.
 

priestjim

Well-Known Member
#8
A month after running correctly using the configuration described here, LS is giving me issues when selecting a PHP version on the fly. Let me explain:

I added the following directive to an .htaccess file in httpdocs:
AddType application/x-httpd-php4 php php3 php4 php5

Then I tried to open a classic info.php (phpinfo()) page to verify that the mod worked but instead I got the default Redhat info page. The weird part is that info.php4 with the .htaccess removed displays the correct PHP4 info! The even weirder thing is that on another server I got with the EXACT same configuration and php versions/compiles everything is running correctly.

Both PHP4 & PHP5 are recompiled with my options through LS's interface and everything else works correctly. The problem occurs with LS versions 4.0 through 4.0.3

Error log gives me:
2009-04-28 14:05:07.245 [ERROR] [83.235.175.46:2974-0#APVH_realestatemillennium.gr:80] MIME type [application/x-httpd-php4] for suffix '.php' does not allow serving as static file, access denied!
2009-04-28 14:05:07.245 [NOTICE] [83.235.175.46:2974-0#APVH_realestatemillennium.gr:80] Content len: 29, Request line:
(null)

Any suggestions?
 

priestjim

Well-Known Member
#10
I already have. .php4 scripts are working fine! In addition, converting to
AddType application/x-httpd-php5 php php3 php4 php5
from
AddType application/x-httpd-php4 php php3 php4 php5
which makes no sense since php5 is the default handler for php files but just for the heck of it, gives me no error whatsoever.
 

mistwang

LiteSpeed Staff
#11
I am talking about the script handler configuration in LSWS console, not whether .php4 scripts are processed by PHP4 or PHP5. It is controlled by the "AddType" directives you mentioned.

You have to have a script handler defined for "php4", so LSWS will know that MIME type "application/x-httpd-php4" will be handled by that handler. And later on, you can change the handler using those "AddType" directives.

You should not remove the script handler configuration from the LSWS console.
 

priestjim

Well-Known Member
#12
I thought it was apparent that I already have a php4 script handler.

Excerpt from httpd_config.xml:
<scriptHandlerList>
<scriptHandler>
<suffix>php5</suffix>
<type>lsapi</type>
<handler>lsphp5</handler>
<note></note>
</scriptHandler>
<scriptHandler>
<suffix>php</suffix>
<type>lsapi</type>
<handler>lsphp5</handler>
<note></note>
</scriptHandler>
<scriptHandler>
<suffix>php3</suffix>
<type>lsapi</type>
<handler>lsphp4</handler>
<note></note>
</scriptHandler>
<scriptHandler>
<suffix>php4</suffix>
<type>lsapi</type>
<handler>lsphp4</handler>
<note></note>
</scriptHandler>
</scriptHandlerList>
PHP4 settings:
<extProcessor>
<type>lsapi</type>
<name>lsphp4</name>
<address>uds://tmp/lshttpd/lsphp4.sock</address>
<note></note>
<maxConns>500</maxConns>
<env>PHP_LSAPI_MAX_REQUESTS=500</env>
<env>PHP_LSAPI_CHILDREN=500</env>
<env>LSAPI_MAX_PROCESS_TIME=3000</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<pcKeepAliveTimeout></pcKeepAliveTimeout>
<respBuffer>0</respBuffer>
<autoStart>1</autoStart>
<path>$SERVER_ROOT/fcgi-bin/lsphp4</path>
<backlog>100</backlog>
<instances>1</instances>
<runOnStartUp></runOnStartUp>
<extMaxIdleTime></extMaxIdleTime>
<priority>-1</priority>
<memSoftLimit>250M</memSoftLimit>
<memHardLimit>300M</memHardLimit>
<procSoftLimit>200</procSoftLimit>
<procHardLimit>200</procHardLimit>
</extProcessor>
 
Top