1

I have the following config: Apache 2.4, php-fpm, mod_proxy_fgci. The problem is that my config is not working with the alias directive: I've installed phpredmin, but the alias directive is not working with ProxyPass. Can someone push me in the right direction?

This is the config:

<VirtualHost *:80>
  ServerName default


# Directory
DocumentRoot /var/www/default/wwwroot
<Directory /var/www/default/wwwroot>
  Options +FollowSymLinks +ExecCGI +Includes
  AllowOverride All
  Require all granted
</Directory>

# PHP-FPM Server
<LocationMatch "^/(.*\.php(/.*)?)$">
  ProxyPass fcgi://127.0.0.1:9000/var/www/default/wwwroot/$1
</LocationMatch>

# Directory indexes
<IfModule dir_module>
  DirectoryIndex index.htm index.html index.shtml index.php index.phtml
</IfModule>


Alias /phpredmin /var/www/default/wwwroot/phpredmin/public
<Directory "/var/www/default/wwwroot/phpredmin/">
        AllowOverride All
        require ip 127.0.0.1
</Directory>


</VirtualHost>

Update

I've created an extra vhost and I've got phpredmin working with this config:

<VirtualHost *:80>

ServerName phpredmin.example.com
DocumentRoot /var/www/default/wwwroot/phpredmin

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel alert
DirectoryIndex index.php
ServerSignature Off

RewriteEngine on

<Directory /var/www/default/wwwroot/phpredmin>
    Options -Indexes
            require ip 192.168.2.0/24
            require ip 192.168.10.0/24
</Directory>


Alias /phpredmin /var/www/default/wwwroot/phpredmin/public
<Directory /var/www/default/wwwroot/phpredmin/public>
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule . fcgi://127.0.0.1:9000/var/www/default/wwwroot/phpredmin/public/index.php [P,L]


         RewriteRule ^/?(.*\.php)$ fcgi://127.0.0.1:9000/var/www/default/wwwroot/phpredmin/public/$1 [P,L]
         RewriteCond %{REQUEST_FILENAME} -d
         RewriteRule ^/?(.*)$ fcgi://127.0.0.1:9000/var/www/default/wwwroot/phpredmin/public/$1 [P,L]

         DirectoryIndex disabled
         ProxyErrorOverride on
</Directory>

0

2 Answers 2

3

Apache reads configuration file from top to bottom.

If a matching command is found (like your proxypass) it is executed and the rest of file is discarded.

In order to have your Alias command executed before ProxyPass, you need to put it on top of file.

<VirtualHost *:80>
  ServerName default


# Directory
DocumentRoot /var/www/default/wwwroot
<Directory /var/www/default/wwwroot>
  Options +FollowSymLinks +ExecCGI +Includes
  AllowOverride All
  Require all granted
</Directory>

Alias /phpredmin /var/www/default/wwwroot/phpredmin/public
<Directory "/var/www/default/wwwroot/phpredmin/">
        AllowOverride All
        require ip 127.0.0.1
</Directory>


# PHP-FPM Server
<LocationMatch "^/(.*\.php(/.*)?)$">
  ProxyPass fcgi://127.0.0.1:9000/var/www/default/wwwroot/$1
</LocationMatch>

# Directory indexes
<IfModule dir_module>
  DirectoryIndex index.htm index.html index.shtml index.php index.phtml
</IfModule>
</VirtualHost>
2

Here is the short answer. Put the following 3 lines in your httpd.conf file, and you are good to go :

<FilesMatch \.php$>
 SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

Worked for me in the exact same configuration as yours.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .