Php code displays instead of executing on new install

hello all - (another day, another silly question)

just did a new virtualmin/webmin install in a test environment. then I did my favorite command:

echo ‘<?php phpinfo(); ?>’ > /var/www/html/phpinfo.php ;

but the code was just displaying in the browser as is rather than executing. this seems like its happened many times before, but since this is a new env, I thought I should ask first.

i did try many of these suggestions like restart php-fpm, httpd, etc.

for fun, I put this code at the bottom of httpd.conf as suggested, but that didnt work either, but at least it tried to execute:

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

gave me this message:

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

any suggestions on what to try next? again, I apologize for so many silly questions.

SYSTEM INFORMATION
OS type and version RL 9.5
Webmin version 2.202
Virtualmin version 7.20.2
Webserver version Server version: Apache/2.4.62 (Rocky Linux)
Server built: Jan 10 2025 00:00:00

Virtualmin works mainly with individual server domains. I don’t know if php is set up for that server? Does it do this for any virtual server you have added?

As @ID10T hinted to, set up a VS and then move the php script to /home/VS/public_html
try viewing it again in browser

Try reading the docs (I know we all look at documentation last), your treating virtualmin as if it was a clean install of Rocky with apache default config.

2 Likes

I had also an issue with Error Code 503 Server unavailable 503 Error after cloning a sub-server .

In may case a configuration file in /etc/php/8.1/fpm/pool.d/ was missing

  • The Apache Configration points to: SetHandler proxy:unix:/run/php/17392042948251.sock|fcgi://127.0.0.1
  • /etc/php/8.1/fpm/pool.d/7392042948251.conf (was not created by the clone subserver task)
  • The special file /run/php/7392042948251.sock was not created, because 392042948251.conf was missing

In the log files I found a hint that the socket was not available

That’s almost always because mod_php has been installed on the system. Don’t install mod_php. If you’ve installed mod_php you should uninstall it. mod_php is in the php or phpVERSION-php package on EL systems.

That’s never going to do anything on a properly configured Virtualmin system. /var/www is not where any DocumentRoot will be or should be.

Virtualmin domain document roots live in /home/domainname/public_html.

You have a couple of special-cased CGI bins in /var/www on your old system, for reasons we’ve already discussed at great length. But, no document root should ever be there, and no PHP will ever be there.

1 Like

i keep “install scripts” from my last server rebuild. this is done in case I want/need to migrate to another service, and hopefully, I can keep the project time to under a day.

also, I keep them around in case of an emergency.

these install scripts contain tests that may have worked at one time, but not anymore so they need to be removed.

and apparently running a PHP script from /var/www/html is a good example of an obsolete test so I have just learned.

so of course these install scripts should be kept as current as possible.

probably for the php test I will include something like this in the install scripts:

virtualmin create-domain --domain example.com --pass password --desc "example.com top-level server" --unix --dir --webmin --web --ssl --dns --mail --limits-from-plan ;

from docs then put the <?php phpinto();?> code in the new virtual server.

thank you all for your suggestions.

2 Likes

If you are running multiple websites, then yes, this is not the setup used by many anymore. If you are setting up a single host, then it is still probably valid.

It’s not obsolete, it just doesn’t make sense for Virtualmin domains, and never has. Virtualmin has always put domain homes in /home.

No need, phpinfo() is in the GUI.

2 Likes

WOW! thank you for sharing this. it works perfectly.

1 Like

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