0

We're running a different version of PHP for one of the sites, so we've configured fastcgi. But requests to any files, even static css and js is being passed through. How can we limit it to php only? This is the current configuration:

<VirtualHost *:80>
    DocumentRoot /services/www/htmlblog
    DirectoryIndex index.html index.shtml index.cgi index.php
    ServerName 128.199.222.207

    ServerAlias www.blog.example.org

    <IfModule mod_fastcgi.c>
        <FilesMatch \.php$>
            SetHandler php-script
        </FilesMatch>
        FastCgiExternalServer /services/www/htmlblog -host 127.0.0.1:8998 -pass-header Authorization
    </IfModule>
   <FilesMatch "configuration.php">
        Order allow,deny
        Deny from all
   </FilesMatch>
   <Directory "/">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>

I've tried this:

<IfModule mod_fastcgi.c>
  AddHandler php5-fcgi .php
  Action php5-fcgi /php5-fcgi
  Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
  FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:8998 -pass-header Authorization -idle-timeout 60
</IfModule>

Which serves up the index.php file located in that folder. If I change it to:

FastCgiExternalServer /services/www/htmlblog -host 127.0.0.1:8998 -pass-header Authorization -idle-timeout 60

It again just passes the static files to php-fpm.

Kit Sunde
  • 946
  • 3
  • 12
  • 31

1 Answers1

0

I think that you're config is not correct.

It should be something like this:

<IfModule mod_fastcgi.c>
  AddHandler php5-fcgi .php
  Action php5-fcgi /php5-fcgi
  Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
  FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 60
</IfModule>

Thank should then only pass PHP files to the FastCGI server.

Also, what I done was create a fastcgi-php.conf file and put that into my conf-available folder, and symlinked it, so then that way I'd have PHP enabled for the entire server.

D Takeshi
  • 66
  • 1
  • I need this version of PHP to be local to that virtualhost. There are other sites that are running `mod_php` on a different version of php. If I use `/usr/lib/cgi-bin/php5-fcgi` it serves the `index.php` located in that folder which outputs `phpinfo()` but if I instead use `/services/www/htmlblog` where my files are located. It still serves passes the static files to PHP. – Kit Sunde Sep 02 '15 at 22:55
  • How have you configured PHP+FastCGI? Are you using the FPM package? I'm pretty sure that you can just configure your FPM package to call the correct executable that you need, that'll give you the correct version that you need. Which I assume you're doing already. From there, you can use the example I provided and just modify the paths. The `/usr/lib/cgi-bin/php5-fcgi` is just an Alias for Apache. – D Takeshi Sep 02 '15 at 22:57
  • Also you can just put that configuration into your per site conf as well. – D Takeshi Sep 02 '15 at 23:16