subdomain can not run php

I have a dedicated server and have install ubuntu 16.04 LTS and Virtualmin + Webmin, For example, My domain is mydomain.com, and now I need a sub domain demo.mydomain.com, then I created a Sub-sever and fill the domain name as “demo.mydomain.com”, Sub-server created successfully.

My problem is I can not run php for this sub-domain, I can access html file, for example, when I run http://demo.mydomain.com/index.php, it prompt can not open the page and then redirect www.mydomain.com.

I also enable sub-domain feature in Virtualmin Configuration -> Advanced Options and then try to add Sub-domain for mydomain.com but same result,

anyone can help?

Thanks in advanced.

Don’t enable sub-domains. That’s a misfeature we borrowed from cPanel way back in the day, but it was never a good idea.

I’m confused by this: “for example, when I run http://demo.mydomain.com/index.php, it prompt can not open the page and then redirect www.mydomain.com.”

I don’t understand where a redirect would even come from; nothing in the default Virtualmin server template for sub-servers would redirect to the parent domain. So, that’s weird and confusing.

What’s in the error_log for each of the servers in question? (The parent domain and the subdomain sub-server?)

Thanks for your reply
it really strange, now I add a top-level server allsites.cattheme.com basic on one of my domain name cattheme.com, and I have a wordpress script in /home/allsites/public_html and I can access html file http://allsites.cattheme.com/readme.html, but when I try to access http://allsites.cattheme.com/, or http://allsites.cattheme.com/index.php, it redirect to www.cattheme.com.

the original OS for my dedicated server is Ubuntu 14.04 LTS, and then I upgrade to 16.04 LTS in order to use php 7.0, and then install virtualmin + webmin, not sure if the issue is cause by OS?

any clue?

Howdy,

What is the PHP code in that particular Sub-Server?

Is it an app such as WordPress or Drupal?

If so, I’d be curious what happens if you make a test script, named something like test.php, and for it’s contents, place the following:

<?php phpinfo(); ?>

If you access that test.php script, does that work as expected?

-Eric

Thanks for all the help,

I have reload OS and install LAMP manually, Virtualmin is really great Control panel, and will try it on my other server.

Don't enable sub-domains. That's a misfeature we borrowed from cPanel way back in the day, but it was never a good idea.
May you elaborate ?

How should one use a subdomain with virtualmin then ?