PHP-FPM不能在Apache,CentOS 6.4上作为全局PHP处理程序工作

我试图将我的服务器上的PHP处理程序从mod_php切换到PHP-FPM。 但是,我的设置是worng。 当我试图打开server.com/info.php时,它被打开为显示文件内容的标准文本,而不是通过phpparsing:

<?php phpinfo(); ?> 

Httpd和php-fpm日志什么都没显示。 httpd -M – 显示加载的mod_fastcgi。 系统:CentOS 6.4 x64,Apache 2.2.15。

使用这样的configuration从源代码编译的PHP-5.5.3:

 ./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 

通过init.d / php-fpm正常启动php-fpm进程,并准备在127.0.0.1:9000上监听连接。 显示正确信息的netstat。 mod_fastcgi – 通过yum安装

我的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和默认的池“www”confs和许多教程中描述的互联网上的任何地方都完全一样,而这个教程并没有帮助我(这个时候只有www.conf中的用户和组是“apache” – 在PHP编译时插入从源头上。

第二个问题:PHP-FPM安装程序仅适用于文档根目录中的文件?

现在我的文档根目录是/ var / www / html。 但像zabbix,phpmyadmin几个网站驻留在“/ home / vhosts”,他们是子目录,而不是虚拟主机。 我在尝试aceess server.com/pma时看到错误:

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

之前我有相同的来源和一切工作编译mod_php。 现在它仍然在系统path中注册,但在httpd中加载mod_php被禁用。

我有<IfModule mod_fastcgi.so>它应该是<IfModule mod_fastcgi.c>

另外httpdconfiguration需要: SuexecUserGroup apache apache

httpd的我的fpm.conf,testingApache 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> 

此configuration将PHP-FPM设置为整个服务器的全局php处理程序。 您可以使用上面的代码来更改FPM池和/或SuExec参数的单独虚拟主机。