logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



PHP as FCGID w/multiple PHP.INI files

 
Post new topic   Reply to topic    Apache Forum Index -> Other Software



View previous topic :: View next topic  
Author Message
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Wed 10 Mar '10 1:24    Post subject: PHP as FCGID w/multiple PHP.INI files Reply with quote

First off, I did try to search AL for this topic, without success.

I have researched to the best of my current abilities to answer this without success.

Currently FCGID resolves the issue of stability having to call numerous non-thread-safe EXE's via PHP's EXEC() and SYSTEM() commands.

I have about 400 vhosts. I want to have at least two different PHP.INI files, at least two but maybe more.

The services I offer use a web-based file management, customized mail services, online image manipulation services, online media conversion services and so on. These all use a huge number of command line capable apps to make this all happen in this manner and PHP is so darn easy to code and secure, I just hate think that I have to go down a different path, starting over.

I could run some users, the bulk of my VHOSTS with the PHP module, but then I am running a more complicated environment than I would like to. If that is the only option for having multiple INI files, then so be it.

######################

My Questions: Is it possible in WAMP to run PHP exclusively as FCGID and have different PHP.INI files?

If so, how?

######################
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2101
Location: Sun Diego, USA

PostPosted: Wed 10 Mar '10 3:33    Post subject: Reply with quote

php.example.com uses mod_php and it's one php.ini file
user1.example.com uses mod_fcgid and loads only the php.ini file in /home/user1
user2.example.com uses mod_fcgid and loads only the php.ini file in /home/user2
user3.example.com uses mod_fcgid but loads mod_php's php.ini file

Code:


#httpd.conf

LoadModule php5_module /php/php5apache2_2.dll
LoadModule fcgid_module modules/mod_fcgid.so
PHPIniDir /php

<IfModule fcgid_module>
# whatever directives wanted bla bla bla
# Use same php.ini as mod_php globally for mod_fcgid
FcgidInitialEnv PHPRC "/php"
</IfModule>


#httpd-vhost.conf

#using mod_php and /php/php.ini
<VirtualHost *:80>
    ServerName php.example.com
    DocumentRoot "/home/htdocs"
</VirtualHost>

#using mod_fcgid and /home/user1/php.ini
<VirtualHost *:80>
    ServerName user1.example.com
    DocumentRoot "/home/user1/htdocs"
      FcgidInitialEnv PHPRC "/home/user1"
      AddHandler fcgid-script .php
      FcgidWrapper "/php/php-cgi.exe" .php
</VirtualHost>

#using mod_fcgid and /home/user2/php.ini
<VirtualHost *:80>
    ServerName user2.example.com
    DocumentRoot "/home/user2/htdocs"
      FcgidInitialEnv PHPRC "/home/user2"
      AddHandler fcgid-script .php
      FcgidWrapper "/php/php-cgi.exe" .php
</VirtualHost>

#using mod_fcgid and global php.ini
<VirtualHost *:80>
    ServerName user3.example.com
    DocumentRoot "/home/user3/htdocs"
      AddHandler fcgid-script .php
      FcgidWrapper "/php/php-cgi.exe" .php
</VirtualHost>


There may be other ways to do this but this works for me.
There is no need to use mod_php I just did it cause I want to show the mix & match aspect of it.


Last edited by glsmith on Wed 10 Mar '10 18:34; edited 1 time in total
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Wed 10 Mar '10 7:25    Post subject: Reply with quote

Many thanks for this incredibly simple explanation.

Checked the test INI files, perfect.

Currently I am in test flight, but this solution looks promising.

Question: Do you notice any change in memory usage?

Even if the processing load creates more load, even if it were to and if it were to use more RAM, so what! This should be rock solid stable.

Thank you very much for your fast reply.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6202
Location: Germany, Next to Hamburg

PostPosted: Wed 10 Mar '10 10:36    Post subject: Reply with quote

Hi Brian,
there no more usage with using different ini files as I know from my experience. At least if you don't load a different number of extensions. You should also be able to load different php version. Sometimes very useful for testing.
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Thu 11 Mar '10 5:28    Post subject: Reply with quote

Different PHP versions, actually that can be important.

I have one extension that I use with ImageMagick, it requires a 4.x.x version of PHP but does somethings that I need very nicely.

I will probably end up running PHP as CGI and Module after all.

FCGID has really come a long ways with regards for PHP support and on Windows it really was needed.

I am running a full testing server on my workstation and so far I am very happy.

I have not had a chance to set up MySQL and also MSSQL yet. I also have an application for using an ODBC connection (SQLite3?) to pull data to generate reports from a Spiceworks db file. I used SQLite3 to pull live data into Excel so I assume that is the same connector PHP would use, not sure yet though.

I really appreciate AL and the many experienced contributors here, my simple question was thoroughly and quickly answered. Thank you.
Back to top
flatcircle



Joined: 27 Jun 2006
Posts: 79

PostPosted: Thu 11 Nov '10 15:18    Post subject: Reply with quote

Is this correct?

<VirtualHost *:80>
ServerName php.example.com
DocumentRoot "/home/htdocs"
</VirtualHost>

Shouldn't the line:

Code:
AddType application/x-httpd-php .php


be included as well?

mod_php => AddType application/x-httpd-php .php

Code:
<VirtualHost *:80>
    ServerName php.example.com
    DocumentRoot "/home/htdocs"
    AddType application/x-httpd-php .php
</VirtualHost>



mod_fcgid => AddHandler fcgid-script .php

Code:
<VirtualHost *:80>
    ServerName user1.example.com
    DocumentRoot "/home/user1/htdocs"
    FcgidInitialEnv PHPRC "/home/user1"
    AddHandler fcgid-script .php
    FcgidWrapper "/php/php-cgi.exe" .php
</VirtualHost>
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Other Software
Page 1 of 1