Zen Cart Logo
Forums / Installing on a Linux/Unix Server / Running PHP as CGI, any drawback?

Running PHP as CGI, any drawback?

Locked

Views: 2,135

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
9 Dec 2007, 3:26 AM
#1
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Running PHP as CGI, any drawback?

I'm recommended by my host to use PHP as CGI (I can switch back if I want to) for security purpose. I wonder if it will have any effect on Zencart and Wordpress ? Will something stops working because of that?

Regards,
yellow1912

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

9 Dec 2007, 4:32 AM
#2
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Running PHP as CGI, any drawback?

works well for us,

Zen cart PCI compliant Hosting

9 Dec 2007, 5:46 AM
#3
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Running PHP as CGI, any drawback?

PHP running as CGI is definitely more secure, than PHP as an Apache module.

There could be some trip-ups though, since you can no longer use 777 permissions anywhere and "nobody" cannot own any files. If not sure about these then best to discuss with your Hoster; somebody has to make sure all permissions are correct.

On the plus side, wherever 777 permissions on directorys were previously required to work properly, will now work just fine with 755 permissions -- without having to worry (as much) about somebody uploading something they shouldn't.

Also, any PHP directives previously setup in an .htaccess file, will have to be removed and placed in a "php.ini" file -- with syntax changes as well.

The learning is in the doing.

Potent Products

9 Dec 2007, 5:52 AM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Running PHP as CGI, any drawback?

Also, any PHP directives previously setup in an .htaccess file, will have to be removed and placed in a "php.ini" file -- with syntax changes as well.

Zencart has many .htaccess files, do I need to make any change?

The htaccess in my root folder is like this

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
```It's for automatically redirecting users to <https://www.domain.com> if they visit domain.com, will it continue to work with the new setting?

Thanks,

yellow1912

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

9 Dec 2007, 6:12 AM
#5
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Running PHP as CGI, any drawback?

All .htaccess files provided within a Default Zen Cart setup have directives that apply only to Apache. These will not cause any problems, regardless of how PHP is run. The directives in your last post for example, are strictly for Apache and will not cause problems.

For security reasons the following should always be used, regardless of where your site is Hosted and how PHP is run.

If PHP is run as an Apache module:

in - public_html/.htaccess
php_flag session.use_trans_sid off
php_value register_globals off

If PHP is run as CGI

in - public_html/php.ini
session.use_trans_sid = off
register_globals = off

How to tell how PHP is being used?

If, after the transfer, the directives shown above for an .htaccess file are still in your .htaccess file and new site is running without problems, then safe to say PHP is run as an Apache module.

If, after the transfer, the directives shown above for an .htaccess file are still in your .htaccess file and new site is kicking out errors, then safe to say PHP is run as CGI. You would remove any PHP directives and put them in a "php.ini" file, changing syntax as necessary.

The learning is in the doing.

Potent Products

9 Dec 2007, 2:01 PM
#6
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Running PHP as CGI, any drawback?

to tell that your running php as cgi,
look in your phpinfo file

it will tell you is the php handler is apache cli or cgi/fastcgi

also if your in control of your own destiny then when you compile apache/php choose cgi safe mode,
this will not allow local php.ini files to override the globals,

also yes all folders can now be set to 755 files should be set to 644 or less
( exception is the config files need to be 444 otherwise the security error in ZC will show,
this is because to the system 644 is still writable )

Zen cart PCI compliant Hosting

10 Dec 2007, 4:24 PM
#7
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Running PHP as CGI, any drawback?

Thanks guys. I'm moving to the new server as of now. Will report back if anything happens.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

10 Feb 2008, 6:42 PM
#8
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Running PHP as CGI, any drawback?

Is there a noticeable speed or other difference when using the fastCGI? Does the zencart dev team recommend using it?

Thanks!

Matt


Zen Cart and it's community are the best!!