Php-fpm port not set properly upon restore

using RedHat 8
VirtualMin 6.17
WebMin 1.981

made several dummy servers real quick … as expected they were assigned php-fpm ports 8003, 8004, 8005 (other domains already exist on this server)

then I back up verne5.com that uses 8005.

then I delete verne5.com and the other placeholder domains, to free up ports in the 8000 range.

then I restore verne5.com and end up with php-fpm using 8003 as I would expect as that is the first free port number, BUT the apache httpd.conf file kept the older setting of 8005 – making the website not working :slight_smile:

… I assume the backup/restore captured the config item from /etc/webmin/virtual-server/domains/16420036881939632 of

php_fpm_port=8005

but I would have thought the restore code would make sure both sides of the php-fpm setup have the same port number !!

Since I am now aware of this issue, I can manually check the two settings to be sure they are the same.

And as a reminder, on RedHat8/Centos8, php-fpm is the only mode available.

Thoughts?

Verne

From experience when restoring apache settings, it will also include the port(s) and thus clash may occur. I either omit restoring apache settings or manually change the port in apache config afterwards. I use CentOS 8.5 - might be a better way but I get around this by the above.

@verne,

This actually sounds like it may be a legit bug with the restore procedure in Virtualmin as generally things of that nature are assessed during the restore process I believe and reassigned as needed.

@staff perhaps you can look into this as it definitely seems like it may require some adjustments.

This is a known bug that will be fixed in the next Virtualmin release.

any ETA? we have a big migration project on feb 25, is it realistic to have this bug fixed until then?

in general I think it would be a good idea to have some procedure to reassign ports globally, simmilar to the fix permission script under limits and validation as we stumble sometimes about this problem.

has this been fixed? we migrated the domains and switched to php-fcgi for the time beeing but get these errors for these domains. what is the best way to fix them?
Apache website : PHP FPM configuration error found : Apache config port 8001 does not match FPM config 8002

Try re-running config check, it must fix the problem.

I am not aware, that configuration check changes the system?!

but anyways, it didn’t change anything in this case. validation after runnign the configuration check still complains:


Apache website : PHP FPM configuration error found : Apache config port 8001 does not match FPM config 8002

Can we see the FPM config for this domain?

Also, Apache <VirtualHost></VirtualHost> part for the domain.


==
%
[14210915464455]                                                                                                        
user = adz                                                                                                              
group = adz                                                                                                             
listen = localhost:8000                                                                                                 
pm = dynamic                                                                                                            
pm.max_children = 9999                                                                                                  
pm.start_servers = 1                                                                                                    
pm.min_spare_servers = 1                                                                                                
pm.max_spare_servers = 5                                                                                                
php_admin_value[upload_tmp_dir] = /home/adz/domains/wpad.adz.de/tmp                                                     
php_admin_value[session.save_path] = /home/adz/domains/wpad.adz.de/tmp
==
<VirtualHost 192.168.10.74:80>
SuexecUserGroup "#1001" "#1001"
ServerName wpad.adz.de
ServerAlias www.wpad.adz.de
ServerAlias webmail.wpad.adz.de
ServerAlias admin.wpad.adz.de
DocumentRoot /home/adz/domains/wpad.adz.de/public_html
ErrorLog /var/log/virtualmin/wpad.adz.de_error_log
CustomLog /var/log/virtualmin/wpad.adz.de_access_log combined
ScriptAlias /cgi-bin/ /home/adz/domains/wpad.adz.de/cgi-bin/
ScriptAlias /awstats/ /home/adz/domains/wpad.adz.de/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/adz/domains/wpad.adz.de/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
<Directory /home/adz/domains/wpad.adz.de/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.wpad.adz.de
RewriteRule ^(.*) https://wpad.adz.de:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.wpad.adz.de
RewriteRule ^(.*) https://wpad.adz.de:10000/ [R]
RemoveHandler .php
RemoveHandler .php5.6
RemoveHandler .php7.0
RemoveHandler .php7.2
RemoveHandler .php7.3
RemoveHandler .php7.4
RemoveHandler .php8.0
RemoveHandler .php8.1
<Files awstats.pl>
AuthName "wpad.adz.de statistics"
AuthType Basic
AuthUserFile /home/adz/domains/wpad.adz.de/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://wpad.adz.de:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://wpad.adz.de:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
Alias /pipermail /var/lib/mailman/archives/public
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8007
</FilesMatch>
</VirtualHost>
<VirtualHost 192.168.10.74:443>
SuexecUserGroup "#1001" "#1001"
ServerName wpad.adz.de
ServerAlias www.wpad.adz.de
ServerAlias webmail.wpad.adz.de
ServerAlias admin.wpad.adz.de
DocumentRoot /home/adz/domains/wpad.adz.de/public_html
ErrorLog /var/log/virtualmin/wpad.adz.de_error_log
CustomLog /var/log/virtualmin/wpad.adz.de_access_log combined
ScriptAlias /cgi-bin/ /home/adz/domains/wpad.adz.de/cgi-bin/
ScriptAlias /awstats/ /home/adz/domains/wpad.adz.de/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/adz/domains/wpad.adz.de/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
<Directory /home/adz/domains/wpad.adz.de/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.wpad.adz.de
RewriteRule ^(.*) https://wpad.adz.de:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.wpad.adz.de
RewriteRule ^(.*) https://wpad.adz.de:10000/ [R]
RemoveHandler .php
RemoveHandler .php5.6
RemoveHandler .php7.0
RemoveHandler .php7.2
RemoveHandler .php7.3
RemoveHandler .php7.4
RemoveHandler .php8.0
RemoveHandler .php8.1
<Files awstats.pl>
AuthName "wpad.adz.de statistics"
AuthType Basic
AuthUserFile /home/adz/domains/wpad.adz.de/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://wpad.adz.de:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://wpad.adz.de:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
Alias /pipermail /var/lib/mailman/archives/public
SSLEngine on
SSLCertificateFile /home/adz/ssl.cert
SSLCertificateKeyFile /home/adz/ssl.key
SSLCACertificateFile /home/adz/ssl.ca
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8007
</FilesMatch>
</VirtualHost>

@Jamie, I assume this has already been fixed for Virtualmin 7?

Yes, it has.

ok, but will it repair existing misconfigurations?

ok, can you at least give me a manual way to assign the same ports to apache and php-fpm? we have only three or for servers here, so this would be much appreciated…

it is a lot of work, but this is what I just went thru yesterday …

first, I see where things are not aligned … I check the VirtualMin config with

grep php_fpm_port /etc/webmin/virtual-server/domains/16370012172535664

to see its set at 8007

Then I see what apache has with

grep ‘SetHandler proxy:fcgi://localhost:’ /etc/httpd/conf/httpd.conf

for the specific virtual host … maybe try

grep -e ServerName -e ‘SetHandler proxy:fcgi://localhost:’ /etc/httpd/conf/httpd.conf

to get each virtual host name along with its port number, or work your way thru httpd.conf using your favorite text editor.

Then look to see what’s in php-fpm at the moment with

grep listen /etc/php-fpm.d/16370012172535664.conf

then – decide which one is wrong … for me, two of them were correct so I only had to edit one. There could be times you need to edit all three !!

And of course when directly modifying these files you will need to tell Linux about it with

systemctl reload php-fpm
systemctl reload httpd

of course it never hurts to see if you have made a horrible change it does not like BEFORE doing the reloads –

php-fpm -t
httpd -t

Note the -t (TEST) operation cannot catch every little error.

Hope this helps a bit – of course there could be better/easier/safer ways than mucking around with the VI editor in Linux config files !!

1 Like

thanks, I found it in the end easier to switch to fcgi and back to fpm, this seems to fix ist.

very good point !! As my work the other day was on RedHat8, where php-fpm is the only option, suggesting switching back and forth did not occur to me :grinning:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.