DreamHost Web Hosting
Discussion Forum


Forums
   >> General Troubleshooting
*Threaded Mode

Subject CGI in PHP  
Posted byretrograde (DH Familiar)
Posted on07/07/04 05:56 PM



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. :)



Subject Re: CGI in PHP new [re: retrograde]  
Posted byVendetta (DH New User )
Posted on05/25/06 11:32 AM



the same problem for me



Subject Re: CGI in PHP new [re: retrograde]  
Posted byscjessey (DH DreamNinja)
Posted on05/25/06 11:45 AM



In reply to:

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.


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 SCJESSEY97

Subject Re: CGI in PHP new [re: scjessey]  
Posted byVendetta (DH New User )
Posted on05/25/06 03:57 PM



In my panel control PHP is configured on 4.4.2.

How i can switch mod_php ?

Thanks for support



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byrlparker (DH Smarty Pants)
Posted on05/25/06 04:06 PM



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. :-(
--rlparker




Subject Re: CGI in PHP new [re: Vendetta]  
Posted byscjessey (DH DreamNinja)
Posted on05/25/06 06:43 PM



In reply to:

How i can switch mod_php ?


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

AddHandler application/x-httpd-php .php

This will not work with PHP5.

--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code SCJESSEY97

Subject Re: CGI in PHP new [re: nuwake]  
Posted byVendetta (DH New User )
Posted on05/26/06 08:09 AM



I ahev this on my root .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Where i put your code ?



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byVendetta (DH New User )
Posted on05/26/06 08:32 AM



I have modified the .htaccess :

# BEGIN WordPress
AddHandler application/x-httpd-php .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# 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



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byscjessey (DH DreamNinja)
Posted on05/26/06 09:29 AM



In reply to:

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


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 SCJESSEY97

Subject Re: CGI in PHP new [re: scjessey]  
Posted byVendetta (DH New User )
Posted on05/26/06 03:20 PM



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

Warning: shell_exec() has been disabled for security reasons



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byscjessey (DH DreamNinja)
Posted on05/26/06 04:01 PM



In reply to:

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

Warning: shell_exec() has been disabled for security reasons


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 SCJESSEY97

Subject Re: CGI in PHP new [re: scjessey]  
Posted byVendetta (DH New User )
Posted on05/26/06 04:04 PM



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



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byscjessey (DH DreamNinja)
Posted on05/26/06 04:07 PM



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

--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code SCJESSEY97


Subject Re: CGI in PHP new [re: scjessey]  
Posted byVendetta (DH Dreamling)
Posted on05/26/06 04:16 PM



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



Subject Re: CGI in PHP new [re: Vendetta]  
Posted byVendetta (DH Dreamling)
Posted on05/26/06 04:20 PM



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
</IfModule>





*Threaded Mode
Jump to