You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Silvio Siefke <si...@web.de> on 2011/02/02 15:53:27 UTC

[users@httpd] Apache2, Fastcgi and PHP

Hello,

i try since 2 days to run Apache with FastCGI and PHP. I have try other
configuration, FCGI with PHP, the same. The apache want not use PHP over
CGI.

Before i use a configuration with suPHP and PHP-CGI without any
Problems. Only that this like not some CMS which want try. So i must
change the configuration.


My System:
# uname -a
FreeBSD hetzner.silviosiefke.de 8.1-STABLE FreeBSD 8.1-STABLE #0: Thu
Sep 16 22:54:11 CEST 2010
root@hetzner.silviosiefke.de:/usr/obj/usr/src/sys/GENERIC  i386

In the httpd.conf i have activate the line
LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so

and in the virutell Host i take the follow lines, i has read that
spawn-cgi the better configuration as shell scripts:

AddHandler php5-fastcgi .php
FastCgiExternalServer /usr/local/www/silvio_backup -host 127.0.0.1:9000

That was the configuration, more i have not do.

Spawn-fcgi i startet with the commands:
# cat /etc/rc.conf | grep spawn
spawn_fcgi_enable="YES"
spawn_fcgi_app="/usr/local/bin/php-cgi"
spawn_fcgi_pidfile="/var/run/spawn-fcgi.pid"
spawn_fcgi_username="www"
spawn_fcgi_groupname="www"
spawn_fcgi_bindaddr="127.0.0.1"
spawn_fcgi_bindport="9000"
#spawn_fcgi_bindsocket="/tmp/php.socket"
#spawn_fcgi_bindsocket_mode="0777"
spawn_fcgi_children="5"
spawn_fcgi_max_requests="1000"

In the log i have no entry only one line,
- - [02/Feb/2011:14:37:09 +0100] "GET /phpinfo.php HTTP/1.1" 200 17

# httpd -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 auth_basic_module (shared)
 file_cache_module (shared)
 cache_module (shared)
 disk_cache_module (shared)
 reqtimeout_module (shared)
 charset_lite_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 unique_id_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 suexec_module (shared)
 cgid_module (shared)
 cgi_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 fastcgi_module (shared)
Syntax OK

# httpd -V
Server version: Apache/2.2.17 (FreeBSD)
Server built:   Feb  2 2011 12:53:55
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.4.2, APR-Util 1.3.10
Compiled using: APR 1.4.2, APR-Util 1.3.10
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr/local"
 -D SUEXEC_BIN="/usr/local/sbin/suexec"
 -D DEFAULT_PIDLOG="/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="etc/apache22/mime.types"
 -D SERVER_CONFIG_FILE="etc/apache22/httpd.conf"

# ps ax | grep php
 2343  ??  Is     0:00.05 /usr/local/bin/php-cgi
 2344  ??  I      0:00.01 /usr/local/bin/php-cgi
 2345  ??  I      0:00.00 /usr/local/bin/php-cgi
 2346  ??  I      0:00.00 /usr/local/bin/php-cgi
 2347  ??  I      0:00.00 /usr/local/bin/php-cgi
 2348  ??  I      0:00.00 /usr/local/bin/php-cgi


I really know not what i should do, i not find the mistake or the bad
configuration. Apache not use log really. Has someone a idea what going
wrong.


Regards
Silvio

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Nilesh Govindarajan <ni...@itech7.com>.
On 02/02/2011 10:28 PM, Silvio Siefke wrote:
> Hello,
> 
> 
> Am 02.02.2011 17:26, schrieb Nilesh Govindarajan:
>> Quite a weird question, have you checked the firewall?
>> Try if it works without the firewall.
>> I don't think a firewall would ever be configured to block localhost
>> connections (its absurd!), but still.
> 
> I have no firewall active on the system. I make a new install on the
> system. Other say me, he make the same and it run direct.
> 
> cd /usr/ports/www/mod_fastcgi && make install clean
> cd /usr/ports/www/spawn_fcgi && make install clean
> service spawn-fcgi onestart
> 
> LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so
> AddHandler php5-fastcgi .php
> FastCgiExternalServer /usr/local/www/apache22/data -host localhost:9000
> 
> That is the way. By a member in a forum goes well, by me not. That is
> really strange.
> 
> 
> Regards
> Silvio
> 

You're using localhost:9000 in FastCgiExternalServer, try with 127.0.0.1
Probably apache has problems resolving localhost, though it should not be.

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/_linuxgeek_
Website: http://www.itech7.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Silvio Siefke <si...@web.de>.
Hello,


Am 02.02.2011 17:26, schrieb Nilesh Govindarajan:
> Quite a weird question, have you checked the firewall?
> Try if it works without the firewall.
> I don't think a firewall would ever be configured to block localhost
> connections (its absurd!), but still.

I have no firewall active on the system. I make a new install on the
system. Other say me, he make the same and it run direct.

cd /usr/ports/www/mod_fastcgi && make install clean
cd /usr/ports/www/spawn_fcgi && make install clean
service spawn-fcgi onestart

LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so
AddHandler php5-fastcgi .php
FastCgiExternalServer /usr/local/www/apache22/data -host localhost:9000

That is the way. By a member in a forum goes well, by me not. That is
really strange.


Regards
Silvio

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Nilesh Govindarajan <ni...@itech7.com>.
On 02/02/2011 09:04 PM, Silvio Siefke wrote:
> Am 02.02.2011 16:05, schrieb Nilesh Govindarajan:
>> ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
>> AddHandler php-fcgi .php
>> Action php-fcgi /cgi-bin/php-cgi
>> <FilesMatch "\.php$">
>>  Options +ExecCGI
>> </FilesMatch>
> 
> I think u use a shell script that speak apache with php-cgi. But this
> should works better with spawn-fcgi, so i read in a Forum from FreeBSD.
> But somewhere is something in my Apache, or my FreeBSD that this not run.
> 
> I think apache has prob to speak with the address, 127.0.0.1 so i think.
> But its hard that apache nothing really log.
> 
> Regards
> Silvio
> 

Quite a weird question, have you checked the firewall?
Try if it works without the firewall.
I don't think a firewall would ever be configured to block localhost
connections (its absurd!), but still.

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/_linuxgeek_
Website: http://www.itech7.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Silvio Siefke <si...@web.de>.
Am 02.02.2011 16:05, schrieb Nilesh Govindarajan:
> ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
> AddHandler php-fcgi .php
> Action php-fcgi /cgi-bin/php-cgi
> <FilesMatch "\.php$">
>  Options +ExecCGI
> </FilesMatch>

I think u use a shell script that speak apache with php-cgi. But this
should works better with spawn-fcgi, so i read in a Forum from FreeBSD.
But somewhere is something in my Apache, or my FreeBSD that this not run.

I think apache has prob to speak with the address, 127.0.0.1 so i think.
But its hard that apache nothing really log.

Regards
Silvio


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Nilesh Govindarajan <ni...@itech7.com>.
On 02/02/2011 08:23 PM, Silvio Siefke wrote:
> Hello,
> 
> i try since 2 days to run Apache with FastCGI and PHP. I have try other
> configuration, FCGI with PHP, the same. The apache want not use PHP over
> CGI.
> 
> Before i use a configuration with suPHP and PHP-CGI without any
> Problems. Only that this like not some CMS which want try. So i must
> change the configuration.
> 
> 
<snip>

Well, I don't recall exactly, I used something like this:

ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
AddHandler php-fcgi .php
Action php-fcgi /cgi-bin/php-cgi
<FilesMatch "\.php$">
 Options +ExecCGI
</FilesMatch>

Just let me know if it works.

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/_linuxgeek_
Website: http://www.itech7.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Apache2, Fastcgi and PHP

Posted by Igor Galić <i....@brainsware.org>.
----- "Silvio Siefke" <si...@web.de> wrote:

> Hello,
> 
> i try since 2 days to run Apache with FastCGI and PHP. I have try
> other
> configuration, FCGI with PHP, the same. The apache want not use PHP
> over
> CGI.
> 
> Before i use a configuration with suPHP and PHP-CGI without any
> Problems. Only that this like not some CMS which want try. So i must
> change the configuration.
> 
> 
> My System:
> # uname -a
> FreeBSD hetzner.silviosiefke.de 8.1-STABLE FreeBSD 8.1-STABLE #0: Thu
> Sep 16 22:54:11 CEST 2010
> root@hetzner.silviosiefke.de:/usr/obj/usr/src/sys/GENERIC  i386
> 
> In the httpd.conf i have activate the line
> LoadModule fastcgi_module libexec/apache22/mod_fastcgi.so
> 
> and in the virutell Host i take the follow lines, i has read that
> spawn-cgi the better configuration as shell scripts:
> 
> AddHandler php5-fastcgi .php
> FastCgiExternalServer /usr/local/www/silvio_backup -host
> 127.0.0.1:9000

These days we recommend mod_fcgid for FastCGI:

http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

> That was the configuration, more i have not do.
> 
> Spawn-fcgi i startet with the commands:
> # cat /etc/rc.conf | grep spawn
> spawn_fcgi_enable="YES"
> spawn_fcgi_app="/usr/local/bin/php-cgi"
> spawn_fcgi_pidfile="/var/run/spawn-fcgi.pid"
> spawn_fcgi_username="www"
> spawn_fcgi_groupname="www"
> spawn_fcgi_bindaddr="127.0.0.1"
> spawn_fcgi_bindport="9000"
> #spawn_fcgi_bindsocket="/tmp/php.socket"
> #spawn_fcgi_bindsocket_mode="0777"
> spawn_fcgi_children="5"
> spawn_fcgi_max_requests="1000"
> 
> In the log i have no entry only one line,
> - - [02/Feb/2011:14:37:09 +0100] "GET /phpinfo.php HTTP/1.1" 200 17
> 
> # httpd -M
> Loaded Modules:
>  core_module (static)
>  mpm_prefork_module (static)
>  http_module (static)
>  so_module (static)
>  authn_file_module (shared)
>  authn_default_module (shared)
>  authz_host_module (shared)
>  authz_groupfile_module (shared)
>  authz_user_module (shared)
>  auth_basic_module (shared)
>  file_cache_module (shared)
>  cache_module (shared)
>  disk_cache_module (shared)
>  reqtimeout_module (shared)
>  charset_lite_module (shared)
>  deflate_module (shared)
>  log_config_module (shared)
>  env_module (shared)
>  mime_magic_module (shared)
>  cern_meta_module (shared)

Do you really need this?

>  unique_id_module (shared)

Do you really use this?

>  setenvif_module (shared)
>  mime_module (shared)
>  status_module (shared)
>  autoindex_module (shared)
>  asis_module (shared)

Or this?

>  suexec_module (shared)
>  cgid_module (shared)
>  cgi_module (shared)
>  negotiation_module (shared)
>  dir_module (shared)
>  actions_module (shared)
>  alias_module (shared)
>  rewrite_module (shared)
>  fastcgi_module (shared)
> Syntax OK

You should revisit:
http://httpd.apache.org/docs/current/mod/
to decide on that..

> # httpd -V
> Server version: Apache/2.2.17 (FreeBSD)
> Server built:   Feb  2 2011 12:53:55
> Server's Module Magic Number: 20051115:25
> Server loaded:  APR 1.4.2, APR-Util 1.3.10
> Compiled using: APR 1.4.2, APR-Util 1.3.10
> Architecture:   32-bit
> Server MPM:     Prefork

Why not run worker when you're running PHP with FastCGI?
No threading issues to be afraid of...

>   threaded:     no
>     forked:     yes (variable process count)
> Server compiled with....
>  -D APACHE_MPM_DIR="server/mpm/prefork"
>  -D APR_HAS_SENDFILE
>  -D APR_HAS_MMAP
>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
>  -D APR_USE_FLOCK_SERIALIZE
>  -D APR_USE_PTHREAD_SERIALIZE
>  -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
>  -D APR_HAS_OTHER_CHILD
>  -D AP_HAVE_RELIABLE_PIPED_LOGS
>  -D DYNAMIC_MODULE_LIMIT=128
>  -D HTTPD_ROOT="/usr/local"
>  -D SUEXEC_BIN="/usr/local/sbin/suexec"
>  -D DEFAULT_PIDLOG="/var/run/httpd.pid"
>  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
>  -D DEFAULT_LOCKFILE="/var/run/accept.lock"
>  -D DEFAULT_ERRORLOG="logs/error_log"
>  -D AP_TYPES_CONFIG_FILE="etc/apache22/mime.types"
>  -D SERVER_CONFIG_FILE="etc/apache22/httpd.conf"
> 
> # ps ax | grep php
>  2343  ??  Is     0:00.05 /usr/local/bin/php-cgi
>  2344  ??  I      0:00.01 /usr/local/bin/php-cgi
>  2345  ??  I      0:00.00 /usr/local/bin/php-cgi
>  2346  ??  I      0:00.00 /usr/local/bin/php-cgi
>  2347  ??  I      0:00.00 /usr/local/bin/php-cgi
>  2348  ??  I      0:00.00 /usr/local/bin/php-cgi
> 
> 
> I really know not what i should do, i not find the mistake or the bad
> configuration. Apache not use log really. Has someone a idea what
> going wrong.
> 
> 
> Regards
> Silvio

i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org