Dear All,

Operating System: RedHat Linux 7

I wanted to configure php for oracle http server.
I followed the instructions given in the below link:

http://www.oracle.com/technetwork/articles/dsl/jones-php-ohs-2194096.html

Based on the above link, i created php.conf file as given below to forward all requests to php-fpm for processing php files:


LoadModule fastcgi_module "/chroot/home/ec-user/Oracle/Middleware/Oracle_Home/ohs/modules/mod_fastcgi.so"

<IfModule mod_fastcgi.c>

<VirtualHost *:80>

ServerName fpmtest.localhost
DocumentRoot /var/www/html

FastCGIExternalServer /var/www/html/php-fpm -host 127.0.0.1:9000

<Directory /var/www/html>
    Order allow,deny
    Allow from all
    <FilesMatch \.php$>
        SetHandler application/x-httpd-fastphp5
    </FilesMatch>
    Action application/x-httpd-fastphp5 /php-fpm
</Directory>
</VirtualHost>

</IfModule>

Now php files located within the directory /var/www/html are getting processed fine. But php files located within the subdirectories of /var/www/html are not being processed and are displayed as plain text files.

Please help me on what needs to be done so that php files located within all the subdirectories/virtual hosts stored within /var/www/html are also processed.

For eg. i have the given below directive for one of my virtual host.
Please let me know what needs to be done to process php files in similar virtual host directives:

<VirtualHost *:80>
  ServerName mydomain.com
	ServerAlias www.mydomain.com    

DocumentRoot /var/www/html/mydomain/www/web

<Directory /var/www/html/mydomain/www/web>
	AllowOverride All
  RewriteEngine On
  Options -Indexes FollowSymLinks

</Directory>   

</VirtualHost>

Also please let me know what needs to be done add php-fpm to start automatically at boot time

Please help.

Thanks and Regards

    7 days later

    It's been a while, but I think you need a few changes.

    1. Move your stanza for

      <Directory /var/www/html>
      Order allow,deny
      Allow from all
      <FilesMatch .php$>
      SetHandler application/x-httpd-fastphp5
      </FilesMatch>
      Action application/x-httpd-fastphp5 /php-fpm
      </Directory>

    into httpd.conf and add Options +ExecCGI to it

    1. Move your FileMatch outside of the directory stanza, so PHP files not in /var/www/html will still be run

    2. You may need to change php-fpm.d/www.conf to listen on the apache user and 0666 permissions (this is a relatively new change)

    3. To turn on php-fpm on system boot for RHEL7 use sudo systemctl enable php-fpm.service

    It would help if you posted errors, if any, you may be getting from the system, apache or php.

      Hello Kudose,

      Thanks for reply.

      Given below what i did. Please correct me if i am wrong somewhere:

      Updated these lines into httpd.conf

      LoadModule fastcgi_module "/chroot/home/ec-user/Oracle/Middleware/Oracle_Home/ohs/modules/mod_fastcgi.so"
      
      <IfModule mod_fastcgi.c>
      
      <VirtualHost *:80>
      
      ServerName fpmtest.localhost
      DocumentRoot /var/www/html
      
      FastCGIExternalServer /var/www/html/php-fpm -host 127.0.0.1:9000
      
      	<FilesMatch \.php$>
              SetHandler application/x-httpd-fastphp5
          </FilesMatch>
          Action application/x-httpd-fastphp5 /php-fpm
      
      <Directory /var/www/html>
      	Options +ExecCGI
          Order allow,deny
          Allow from all
      
      </Directory>
      </VirtualHost>
      
      </IfModule>
      
      
      1. Changed /etc/php-fpm.d/www.conf to listen to process owner (in my case, ec2-user) and changed permissions to 0666

      2. Now my apache fails to start 🙁
        Given below errors:

      
      [VirtualHost: fpmtest.localhost:0] (111)Connection refused:  FastCGI: failed to connect to server "/var/www/html/php-fpm": connect() failed
      
      [VirtualHost: fpmtest.localhost:0]  FastCGI: incomplete headers (0 bytes) received from server "/var/www/html/php-fpm"
      
      [VirtualHost: main]  caught SIGTERM, shutting down
      
      

      Please help me.

      And by the way, i followed your command to start php-fpm at reboot and it worked perfectly fine. Thanks for that

        Write a Reply...