PHP not working with multiple domains: Ubuntu 14.04 LTS

When I first set up Virtualmin, there was just one web server, and PHP worked great. After I tried to add a secondary top-level server, PHP stopped working in both. I have the appropriate DNS records pointing to the server, and there’s no question that Apache is handing off each domain to its appropriate document root (I’ve placed different index files there, and it works).

Now I’ve put an index.php in both domain’s public_html folder as such:

domain1.com: /home/firstuser/public_html/index.php

<?php echo "Hello world, PHP doesn't work!"; ?>

domain2.com: /home/seconduser/public_html/index.php

<?php echo "Temporarily out of service."; ?>

I’ve done a re-check on Virtualmin and every looks fine. Also, not sure if related, but I renamed the first domain from domain.com to domain1.com (obviously all names are changed here).

I’ve checked the Apache error logs, and nothing shows up about PHP. What is going on here?

Howdy,

What is it that’s occurring when you access those two domains? What error(s) are you seeing in your browser?

Also, you mentioned that there weren’t any errors in the Apache error log – if you look in the Apache access log though for those domains (in $HOME/logs/access_log), do you see an entry that corresponds with your attempt to load that website?

-Eric

I may have found a solution, but I suspect it is a workaround, and may be circumventing the Virtualmin configuration settings. First, I’ll describe the problem further.

When I visit either domain1.com or domain2.com in the web browser, I see a PHP source page, not a PHP rendered page. What I see is what I posted originally.

The apache access in /var/log/apache2 doesn’t show anything (in apache2.conf the custom logs are pointed at the virtualmin folders for logs). The apache error log only shows when the apache2 service has been started/stopped. The logs at $HOME/logs/access_log point to /var/logs/virtualmin/domain_access_log and domain_error_log. There are never any errors in these logs. Only the access log populates (with the typical IP address, browser info, page requested and response code), and understandably, since I’m able to access the page. Apache is having no problem serving the page.

Now for what I did. In another thread, some user posted to change the handler settings in apache’s php5.conf, adding SetHandler application/x-httpd-php and SetHandler application/x-httpd-php-source if not present. I have those lines commented out, because Virtualmin told me to, so as to make use of the domain owner permissions when running PHP. I didn’t uncomment them, because this would cause my Virtualmin to produce an error if I re-checked the system config.

Another solution, which seems like it could be possibly as problematic, is to edit /etc/mime.types and uncomment the following line:

#application/x-httpd-php phtml pht php

Although in a different file, this looks almost the same type of handler that I was supposed to disable at a global level from PHP. I can report that the PHP in all my domains/servers on the same machine does now work, but I feel like this is just a hack, and not a real solution. Any thoughts?

Howdy,

Hmm, what PHP Execution Mode are your domains set to? You can determine that in Server Configuration -> Website Options.

-Eric

At the time I hadn’t changed anything. That means CGI run as domain owner, and Apache mod_php. I tried to change the PHP mode to CGI wrapper, but that gave me another error:

The requested URL /cgi-bin/php5.cgi/index.php was not found on this server.

Since my index.php page was located in the public_html directory, I can see why this happened. I changed it back to mod_php, and still had the problem.

Any thoughts on this?