I am at a loss. I realized that apache2 is not running as domain user. in my Apache sites-avail conf files, it is configured for SuexecUserGroup correctly. There are no errors Suexec in apache at all, however when checking phpinfo() you can see that it is running a www-data
I have looked all over with another server that is running debian 11 and running correctly. I cannot figure out why I can’t get this running as the domain user.
I have also noticed that I cannot get this server to switch php versions. Something does not seem to be working correctly. I can’t find any logs files to point me to anything.
in php options I have it as FCGID. I do not know how many times I’ve switched exe modes and tried them all like FPM but nothing seems to changes. I know I need FCGID or FPM. Switching php version does nothing.
Is there anywhere I can check in webmin to understand why I cannot get this to work? I cannot find any difference in configuration of apache2 from a working server with virtualmin and this server.
If you are using suexec, then the suexec process runs as the domain user, but you should almost certainly use PHP-FPM, which runs as the domain user.
If you are seeing your PHP applications run as the Apache user, it means you have installed mod_php, and you should not have done that and you should undo that. It is always a mistake to install mod_php.
@Joe Thanks for the reply. I’ve provided a screenshot of the php options in virtualmin below.
So how do I check if mod_php is installed? I guess I should have showed php modules, sorry. I just do not think mod php is installed. But then again, have trouble trying to enable and disable using a2dismod/a2enconf because it does not find my
I’m very confused with this since I have 3 virtualmin’s running and cannot understand really how this is working to have php run as the domain user.
This is a working server running as domain user config: CentOS7
I might be wrong about it being mod_php. I don’t see it in the list of Apache modules (it’d be named just php), but there aren’t a lot of other explanations for how things would end up running as the Apache user. The only execution modes we support and would configure would be with suexec or FPM (or mod_php, but it’s not available by default), and only mod_php runs as the web server user.
So, something is amiss.
OP, you need to show us the relevant bits of the VirtualHost section for the offending site from httpd.conf. Anything related to PHP, CGI, Exec.
I did take a lot of time to search online for checking if mod_php was there. I managed to exec a apt remove php7.3* and removed what I beleived was mod_php. I did the same for php8.3, which is the version I want to use
apt remove php8.3
The following packages will be REMOVED:
php php8.3
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 77.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
My apps are fine after exec above. So I’m pretty sure mod_php is not present.
Here is all my <VirtualHost *:443>. I’ve changed the url to plain domain.ca
FPM and fcgid would look quite different. But, when I look at my systems, they do report the right user (but I’m not looking at the Apache process, because the Apache process always runs as the Apache user, and it’s not expected to do otherwise).
well I’ve tried all the configs for this problem domain. I’ve managed to create a new dummy virtual server and I can confirm this one worked as domain user for php when I check phpinfo(). So the server looks to configure new domains properly. It would sure be cool to see virtualmin code as it does the config so I could follow it and see maybe an indication of what could have gone wrong with my problematic domain.
I also tried to fine comb through the apache2 .conf file of this working dummy domain to ensure its the same for the problematic domain and it just will not give me the domain user in FPM. buggers
Anyway, unless there are other tings to check I’m assuming my best course of action will be to backup, delete this domain and re-created it… too bad, I would have liked to have found the problem so I could report it here.
You’re in luck. You can see every bit of code in Virtualmin.
But, this is going to be a problem in the FPM configuration and almost certainly something that happened after Virtualmin created your domain, I think. Since your Apache configuration looks correct, and since no one has ever reported this problem before. So, pretty sure you have something custom that breaks the user configuration. Maybe a syntax error in one of your other PHP configs that prevents loading the whole config.
Check the file in /etc/php-fpm.d/<domain-id>.conf (where domain-id is the number correlating to your problem domain, which you can find with virtualmin list-domains --id-only --domain <domainname.tld>) for the user and group fields, and also check any customization you have in the php-fpm config files to make sure they’re valid.
I believe this for sure, because when creating a dummy domain proved the virtualmin script is working I think.
sorry, this is from the dummy domain I created, showing us that creating a new virtual server on this is machine is working just fine.
So I just need to try and find out where I went wrong with this problematic domain so maybe I could share. If not, well I’ll just have to re-create it. Unfortunately, its been so long this machine was made I do not recall if I did things outside the virtualmin way. I do know that my apache2 .conf file for this problematic domain is titled with 0-domain.ca.conf when usually domains start simply with domain.ca.conf, so its like it was deleted and rebuilt or something. I just don’t remember.
Interesting, cool thanks for sharing. I do not have /etc/php-fpm but I do have /etc/php/8.2/fpm/pool.d that holds all the domains and default www.conf Holly shatballs batman I got it working!
If you look at these files /etc/php/8.2/fpm/pool.d/*.conf below
The last one which is www.conf hold www-data:www-data, but also had listen:/run/php/php8.3-fpm.sock and my other ones are listen = 127.0.0.1:800*
What I do not understand is my first below “mysandbox” is working with its own user even if it has listen = 127.0.0.1:8001. But what I did is change the problematic from listen = 127.0.0.1:8002 to listen = /run/php/php8.3-fpm.sock which crashed on systemctl restart php8.3-fpm because www.conf conflicted with same path, but then I did mv www.conf www.conf.bak and fpm restarted and my problematic is working.
So I’m still not sure what is going on here since mysandbox works with its path, but problmatic wasn’t, but at least I know this is fixing the problem. Any repercussions leaving www.conf.bak? Or can I fix my problematic with another listen path?
After understanding a little more about fpm and reading this post
Doing a grep on my problematic conf file in /etc/apache2/sites-available/ I realized that there was a problem with the apache file missing this snippet
I think @Joe would have caught this if I would have not only showed my <VirtualHost *:443> block, but my <VirtualHost *:80> as well as it had this. I do not know why my 443 was missing this but I’m sure somewhere I’m the blame. Now that I understand a little more about php-fpm and the sethandler proxy:fcgi I can see this was the missing piece.
Thanks again Joe for all the leads! I would have never found how this all worked and using the virtualmin list-domains --id-only --domain to get the domain ID