Php not working on default site

This is a refresh install of Virtualmin on Ubuntu 16.04 using a Digital Ocean base image. Php is not executing on the default site. I have not added any virtual hosts yet. I've basically done nothing to the server other than go through the wizard and apply updates via apt.

I will continue to investigate on my own but this is very frustrating.



I just tried adding a virtual host and it will not execute PHP either. It displays index.html fine but says the page isn't working when I try to load index.php. On the default site it just shows index.php as plain text.

Check under the /etc/apache2 directory for any file named like php5.conf or php7.conf which contains a SetHandler line, and comment it out. Then try restarting Apache.

Thanks, that's not the issue. php7.0.conf is there and it already has both instances of SetHandler commented out. I guess Webmin/Virtualmin does this now automatically given all of the issues surrounding that particular problem.

This is easy to reproduce. I can just rebuild my droplet using the Ubuntu 16.04 x64 template, install virtualmin from my registration/subscription provided link, walk through the wizard, add a index.php to the /var/www/html directory and then load it and have it displayed as just text. Other than adding a non-root user to use to login to Virtualmin NO OTHER steps are taken and php is broken.

Project: Webmin Core ยป Virtualmin Virtual Servers

I tried this on Linode since I had access and a fresh server, exact same behavior. Simple index.php with phpinfo will not execute. It either displays as blank or as plain text. When it's plain text looking at the source reveals it is the code as expected just not producing any result.

Ah, it sounds like it may be using the default Ubuntu site, rather than a page under a Virtualmin account.

Try running this command;

a2dissite 000-default

Then add a site using Virtualmin's Create Virtual Server option, and upload your content into it. That will be located in $HOME/public_html.

The PHP should then be executed, and also run as the Virtual Server owner.

That seems to have done the trick, thanks! My mistake was thinking I could use a domain with the default site and have that work similarly to all the virtual hosts. While I'm sure you can in reality with Virtualmin that seems to be unsupported or something. Switching it to a virtual host based site fixed all my issues. Thanks again.

Glad to hear things are working now!

Yeah when Virtualmin is installed, it configures Apache and suexec to be able to run scripts from within /home, in a per-domain basis.

They will run as the Virtual Server owner.

But scripts outside of /home may not work properly at that point.

Feel free to let us know if you have any additional questions!