Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: URL with port go to base url (not subdir) php-fpm |
|
| Author |
|
FriendlyFriend
Joined: 28 Oct 2026 Posts: 2 Location: US, Tampa
|
Posted: Wed 28 Oct '26 20:39 Post subject: URL with port go to base url (not subdir) php-fpm |
|
|
Problem I'm trying to resolve with httpd.conf directives is to have php-fpm go to different versions by port, not by subfolder in the URL.
Want:
localhost:96/phpinfo.php to show that using php 8.2 and have that web root url go to subdirectory setup with php-fpm that points to var/www/php81/
What I get:
Is showing php 8.4 (the default version on server)
What does work:
localhost:96/php82/phpinfo.php
What I get:
php 8.2 as desired, just with URL that isn't desired.
On Debian, firewall port 96 is opened. Default php is 8.4.
Not running for production server - development server for doing upgrades to old large php application.
I just wanted production and development to match without the subfolder in url difference to prevent mistakes when putting on production.
Debian (I have windows background) doesn't use a single httpd.conf file so code below is complete contents of that file, not changing other conf files:
| Code: | Listen 96
<VirtualHost *:96>
<Directory /var/www/html/php82>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Location /php82>
ProxyPass "unix:/run/php/php8.2-fpm.sock|fcgi://localhost/var/www/html/php82"
</Location>
</VirtualHost> |
Not sure what I'm missing. |
|
| Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7488 Location: EU, Germany, Next to Hamburg
|
Posted: Thu 29 Oct '26 13:49 Post subject: |
|
|
Hi,
A short example
| Code: |
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule rewrite_module modules/mod_rewrite.so
Listen 96
<VirtualHost *:96>
ServerName localhost
DocumentRoot "/var/www/html/php82"
<Directory "/var/www/html/php82">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
ProxyPassMatch "^/.*\.php(/.*)?$" \
"fcgi://localhost:9000/var/www/html/php82" enablereuse=on
</VirtualHost>
|
|
|
| Back to top |
|
FriendlyFriend
Joined: 28 Oct 2026 Posts: 2 Location: US, Tampa
|
Posted: Thu 29 Oct '26 17:22 Post subject: This is what ended up working |
|
|
Your code gave me "Service Unavailable" in browser.
I combined yours and mine (kind of) and this worked:
| Code: | Listen 96
<VirtualHost *:96>
ServerName localhost
DocumentRoot "/var/www/html/php82"
<Directory /var/www/html/php82>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Location /php82>
ProxyPass "unix:/run/php/php8.2-fpm.sock|fcgi://localhost/var/www/html/php82"
</Location>
</VirtualHost> |
|
|
| Back to top |
|
|
|
|
|
|