2

I'm trying to switch PHP handler on my server from mod_php to PHP-FPM. But something with my setup is worng. When I'm trying to open server.com/info.php, it's being opened as standard text showing contents of file, not parsed via php:

<?php phpinfo(); ?> 

Httpd and php-fpm logs showing nothing. httpd -M - shows mod_fastcgi loaded. System:CentOS 6.4 x64, Apache 2.2.15.

PHP-5.5.3 compiled from source with such configuration:

./configure \ --prefix=/opt/php553-fpm \ --with-config-file-path=/opt/php553-fpm/etc \ --with-config-file-scan-dir=/opt/php553-fpm/etc/php.d \ --with-pdo-pgsql \ --with-zlib-dir \ --with-freetype-dir \ --enable-bcmath \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --with-pgsql \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-mysql \ --with-pdo-mysql \ --with-mysqli \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --with-libdir=lib64 \ --enable-ftp \ --with-imap \ --with-imap-ssl \ --with-kerberos \ --with-gettext \ --enable-fpm \ --with-fpm-user=apache \ --with-fpm-group=apache 

php-fpm process starting normally via init.d/php-fpm, and ready to listen connections on 127.0.0.1:9000. netstat showing correct info. mod_fastcgi - installed via yum

my httpd/fpm.conf

<IfModule mod_fastcgi.so> <FilesMatch \.php$> SetHandler php-script </FilesMatch> # AddHandler php-script .php Action php-script /php.external Alias /php.external /var/run/mod_fastcgi/php.fpm FastCGIExternalServer /var/run/mod_fastcgi/php.fpm -host 127.0.0.1:9000 AddType application/x-httpd-fastphp5 .php DirectoryIndex index.php <Directory "/var/run/mod_fastcgi/"> Order deny,allow Deny from all <Files "php.fpm"> Order allow,deny Allow from all </Files> </Directory> </IfModule> 

fastcgi.conf

User apache Group apache LoadModule fastcgi_module modules/mod_fastcgi.so # dir for IPC socket files FastCgiIpcDir /var/run/mod_fastcgi # wrap all fastcgi script calls in suexec FastCgiWrapper On # global FastCgiConfig can be overridden by FastCgiServer options in vhost config FastCgiConfig -idle-timeout 20 -maxClassProcesses 1 

php-fpm.conf and default pool 'www' confs are exactly same as everywhere on internet described in many-many tutorials which not helping me this time (. Only user and group in www.conf are "apache" - inserted during PHP compilation from source.

Second question: PHP-FPM setup works only with files in document root?

Right now document root for me is /var/www/html. But several sites like zabbix, phpmyadmin reside in "/home/vhosts" and they are subdirectories and not virtualhosts. I see error when I try aceess server.com/pma:

Directory index forbidden by Options directive: /home/vhosts/pma/ 

Before I had mod_php compiled from same sources and everything worked. Right now it's still registered in system path, but loading of mod_php in httpd is disabled.

3
  • 1
    See the OP's question about what is working in Apache 2.2: stackoverflow.com/questions/15773901/… Perhaps that helps? Commented Aug 26, 2013 at 20:05
  • Thanks! some points in thread helped. will update thread as solved with solution. Commented Aug 27, 2013 at 9:25
  • iDen, to avoid this question staying open for ever, please consider writing your solution up as an answer, then accepting it by clicking on the tick outline next to it (you may have to wait a day or two for this option to be presented). Commented Aug 27, 2013 at 9:39

1 Answer 1

2

I had <IfModule mod_fastcgi.so> And it should be <IfModule mod_fastcgi.c>

Also httpd configuration needs: SuexecUserGroup apache apache

My fpm.conf for httpd, Tested on Apache 2.2:

<IfModule mod_fastcgi.c> <FilesMatch \.php$> SetHandler php-script </FilesMatch> SuexecUserGroup apache apache Action php-script /php.external Alias /php.external /var/run/mod_fastcgi/php.fpm FastCGIExternalServer /var/run/mod_fastcgi/php.fpm -host 127.0.0.1:9000 -idle-timeout 900 -pass-header Authorization AddType application/x-httpd-fastphp5 .php DirectoryIndex index.php index.shtml index.cgi index.html index.htm Options +Indexes +FollowSymLinks +ExecCGI +Includes +MultiViews <Directory "/var/run/mod_fastcgi/"> Order deny,allow Deny from all <Files "php.fpm"> Order allow,deny Allow from all </Files> </Directory> </IfModule> 

This configuration sets PHP-FPM as global php handler for whole server. You can use above code for separate virtualhosts changing FPM pools and/or SuExec arguments.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.