htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Difference between PHP-CGI and PHP as an Apache module
PostPosted: Nov 1st, '06, 01:38 
Offline
User avatar

Joined: Sep 25th, '06, 04:48
Posts: 242
The benefits of running PHP-CGI are:

  • It is more secure. The PHP runs as your user rather than dhapache. That means you can put your database passwords in a file readable only by you and your php scripts can still access it!
  • It is more flexible. Because of security concerns when running PHP as an Apache module (which means it runs as our dhapache user), we have disabled a number of commands with the non-CGI PHP. This will cause installation problems with certain popular PHP scripts (such as Gallery) if you choose to run PHP not as a CGI!
  • It's just as fast as running PHP as an Apache module, and we include more default libraries.
There are a FEW VERY MINOR drawbacks to running PHP-CGI. They are:
  • Custom 404 pages won't work for .php files with PHP-CGI. Or will they? See n74's comment below!
  • Variables in the URL which are not regular ?foo=bar variables won't work without using mod_rewrite (http://httpd.apache.org/docs/mod/mod_rewrite.html) (example.com/blah.php/username/info/variable).
  • Custom php directives in .htaccess files (php_include_dir /home/user;/home/user/example_dir) won't work.
  • The $_SERVER['SCRIPT_NAME'] variable will return the php.cgi binary rather than the name of your script
  • Persistant database connections will not work. PHP's mysql_pconnect() function will just open a new connection because it can't find a persistant one.


If one of those is a show-stopper for you, you can easily switch to running PHP as an Apache module and not CGI, but be prepared for a bunch of potential security and ease-of-use issues! If you don't know what any of these drawbacks mean, you're fine just using the default setting of PHP-CGI and not worrying about anything!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSNbot Media and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB