CGI in PHP

wordpress

#1

I have a .php page and I want to call a CGI file. However, I am unable to use the function virtual because it says it doesn’t exist.

Has this been disabled on Dreamhost? Is there another way for me to call a CGI file from within a PHP document?

I could call the CGI file via SSI if I were to use .shtml, but I need to use PHP.

I hope this makes sense. :slight_smile:


#2

the same problem for me


#3

The virtual() function only works when PHP is installed as an Apache module. The default setting is for PHP running as a CGI application. If you are using PHP4, it may be possible to switch to using mod_php, but not with PHP5.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#4

In my panel control PHP is configured on 4.4.2.

How i can switch mod_php ?

Thanks for support


#5

You may not be able to… the “old” control panel used to have a checkbox for “Run PHP as CGI (recommended)”, and you could “uncheck” that box to run as an apache module. That checkbox is no longer available on the control panel for any of my domains, even ones where it used to be present. :frowning:
–rlparker


#6

Add this to your .htaccess file, and you should be able to get mod_php working:

AddHandler application/x-httpd-php .phpThis will not work with PHP5.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#7

I ahev this on my root .htaccess

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

Where i put your code ?


#8

I have modified the .htaccess :

BEGIN WordPress

AddHandler application/x-httpd-php .php

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress

It’s correct ?

Now i don’t receive any error from virtual function, and the scripts seem to work.

But you can explain me what do the function
AddHandler application/x-httpd-php .php ???

Many thanksss


#9

[quote]But you can explain me what do the function
AddHandler application/x-httpd-php .php ???[/quote]
It instructs all files with the extension of .php to be interpreted by the mod_php Apache module, instead of the PHP CGI binary.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#10

with your line i receive an error in other php application:

Warning: shell_exec() has been disabled for security reasons


#11

[quote]with your line i receive an error in other php application:

Warning: shell_exec() has been disabled for security reasons[/quote]
Well, that would be because shell_exec() has been disabled for security reasons!

Seriously though, DreamHost will not allow you to run external processes when using mod_php, because any that you execute run as Apache’s user/group instead of your own.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#12

The script with shell_exec is in another folder…i can setup a different .htaccess for working with PHP as CGI ?


#13

I don’t know - I’ve never tried it.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#14

Have you any idea ? I don’k know what i must put in htaccess…i’m a total newbie :((


#15

Is it possible use conditional function in htaccess to set php as CGI working only in a specific directory like this example ?

IfModule mod_fastcgi.c>
FastCgiIpcDir /usr/local/www/fcgi_ipc/tmp
AddHandler fastcgi-script .fcgi
FastCgiSuexec /usr/local/sbin/suexec
FastCgiConfig -singleThreshold 100 -killInterval 300 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION