PHP script execution mode issue

I have upgraded my php from 5.3.3 to 5.4.45.

After the install, the server still served up html, but merely downloaded php scripts to my client machine.

I think I have narrowed down the issue, but I need help from this community.

I have found that switching Virtualmin/Server-Configuration/Website-Options/PHP script execution mode from the Virtualmin default of “FCGId” to “Apache mod_php (run as Apache’s user)” will allow the script to be run, even though it only serves up a blank page.

The approach I would prefer to take would be to use the Virtualmin default of “FCGId”. I suspect the php is producing blank pages due to some permissions error, and using the permissions structure created by the original Virtualmin virtual server install would bypass the need to reset permissions manually. (Ugh.)

Can you please let me know what the issue with FCGid might be? (ie. What the code should look like, and where in the Virtualmin system it should be located?)

System deets:
CentOS release 6.9 (Final)
PHP Version 5.4.45
Let me know if you need more info.

Thanking you in advance.

If it’s downloading your PHP scripts / webpages rather than displaying them, take a look here…


I’ve been to that page and tried my best to follow it’s instructions. Here are the relevant lines from my conf file:

DSO section includes:
LoadModule php5_module modules/
LoadModule php5_module modules/

Directory section:
<Directory /home/myvirtualserver/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php5.4 .php5.4

The file I am editing is: /etc/httpd/conf/httpd.conf.
I note this just in case the virtualmin structure uses another file.

Well, it depends how you have VM configured. Typically I believe, by default, VM uses host files generated in /etc/apache2/sites-available but if you forced it to use http.conf then that would be the correct location. If it uses what I believe are the default settings then it would use the path I have stated and there would be an individual file for each domain. Juts out of interest, do you get any errors generated when you run the VM re-check configuration (under Virtualmain -> System Settings).

Yeh… this could be part of the problem. I do not have an /etc/apache2 directory.

If I look under homes/myvirtualserver I do not see an apache2 directory there either.

On a side note, homes/myvirtualserver contains both an fcgi-bin directory, and an etc directory containing a php.ini file, and php5 and php5.4 directories.

Here is what Re-check configuration renders unto us:

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active …
Your system has 7.66 GB of memory, which is at or above the Virtualmin recommended minimum of 256 MB.
BIND DNS server is installed, and the system is configured to use it.

Mail server Postfix is installed and configured.

Your Postfix version does not support per-domain outgoing IP addresses.

Apache is installed.

The following PHP versions are available : 5.4.45 (/usr/bin/php-cgi), 5.4 (mod_php)

PHP-FPM support was not detected : No FPM configuration directory found

Webalizer is installed.

Apache is configured to host SSL websites.

MySQL is installed and running.

ProFTPD is installed.

Logrotate is installed.

SpamAssassin and Procmail are installed and configured for use.

ClamAV is installed and assumed to be running.

Plugin DAV Login is installed OK.

Plugin AWstats reporting is installed OK.

Plugin Protected web directories is installed OK.

Using network interface eth0 for virtual IPs.

Default IPv4 address for virtual servers is 67.555.55.213.

Default IP address is set to 67.555.55.213, which matches the detected external address.

Both user and group quotas are enabled for home and email directories.

All commands needed to create and restore backups are installed.

The selected package management and update systems are installed OK.

Chroot jails are not available : The Jailkit command jk_init was not found on your system - maybe the packet is not installed?

… your system is ready for use by Virtualmin.

On Centos you will never have /etc/apache2 directory and all the files are located inside /etc/httpd/.

Check /etc/https/httpd.conf under ########:80 and ########:443 and you should have something like this:

AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php7.1
FCGIWrapper /home/VIRTUAL_SERVER/fcgi-bin/php7.1.fcgi .php
FCGIWrapper /home/VIRTUAL_SERVER/fcgi-bin/php7.1.fcgi .php7.1

I’m using PHP 7.1 but it should be easy to change to whatever PHP version you are using.

Sorry, I missed the part about CentOS - sorry if I led you up the garden path. Hopefully Diabolico’s answer may give you the results you seek.

That’s okay Adelphia, I figured out what you meant and no garden path was trod.

But my issue stands.

Both of you, Thanks for this. I think we’re getting somewhere. Here’s what I have now.

Diabolico, when I copied your syntax with my own version (same for 80 and 443):

AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5.4
FCGIWrapper /home/myvirtualserver/fcgi-bin/php5.4.fcgi .php
FCGIWrapper /home/myvirtualserver/fcgi-bin/php5.4.fcgi .php5

I got a filename error “Wrapper /home/myvirtualserver/fcgi-bin/php5.4.fcgi cannot be accessed: (2)No such file or directory”.

Checking the fcgi-bin directory, I see the file is called php5.fcgi. Is this the correct file?

It’s contents are here:

export PHPRC
umask 022
exec /usr/bin/php-cgi

I am curious about the “PHPRC=$PWD/…/etc/php5” line. What is $PWD? If I know that, then I can check that directory.

For now, I edited the path to re-link the php5.fcgi.
And that’s where I am now:

AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5.4
FCGIWrapper /home/myvirtualserver/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/myvirtualserver/fcgi-bin/php5.fcgi .php5

According to documentation, $PWD is the current working directory of PHP. This may be what’s incorrect. I found this…

“PWD should be the current working directory (the directory where your .php file containing phpinfo() is stored).” Google “php pwd environment variable” and you’ll find loads of info on it.

Wow. Whew. Prise the depths of the Web, and you shall find.

I found this after how many days?

So, I don’t think the problem is in the php5.fcgi file, or in the path to the php package.

My current php scripts spit out blank pages, but a simple “echo” script and php_test() both work just fine.

I’ll dig through my scripts to see what the compatibility issue is.

Many thanks to the fine citizens of this forum for your help. Adelpia and Diabolico, you both deserve medals.

Alrighty! I also got the compatibility issue figured out.

I thought I’d post the details here, for anyone finding themselves in the same boat in the future.

In short, the 3rd-party remi repository did not install the extensions in a manner usable by my set up (detailed in the OP).

Instead, php -v produced the error:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/’ - /usr/lib64/php/modules/ symbol mysql_client_errors, version libmysqlclient_18 not defined in file with link time reference in Unknown on line 0

As well as a couple of these:

PHP Warning: Module ‘mysql’ already loaded in Unknown on line 0

I tried a few command-line solutions, but what worked in the end was to physically download the proper extension (from Remi’s same repository, ironically --> link), and manually upload them to the proper directories:

usr/lib64/php/modules/ usr/lib64/php/modules/ usr/lib64/php/modules/ usr/lib64/php/modules/ usr/lib64/php-zts/modules/ usr/lib64/php-zts/modules/ usr/lib64/php-zts/modules/ usr/lib64/php-zts/modules/

Also, this version of php uses a separate directory of ini files for each active extension. You can set the extension variables here, but it is also the location where you activate the extension. Each of these files needs to be commented out:

etc/php/mysql.ini etc/php/mysqli.ini etc/php/pdo_mysql.ini etc/php-zts/mysql.ini etc/php-zts/mysqli.ini etc/php-zts/pdo_mysql.ini

Like this:

; Enable mysqli extension module

And these files (from the remi package) installed:

etc/php/mysqlnd_mysql.ini etc/php/mysqlnd_mysqli.ini etc/php/mysqlnd.ini etc/php/pdo_mysqlnd.ini etc/php-zts/mysqlnd_mysql.ini etc/php-zts/mysqlnd_mysqli.ini etc/php-zts/mysqlnd.ini etc/php-zts/pdo_mysqlnd.ini

So, it’s a bit of a dirty approach, but it’s working like a charm.


Floren adds some more explanation here about the strange file naming workaround.

And the “nd” (as in “mysqlnd”) is explained here.

Hoping that this post helps someone out down the road.

Thanks again to Adelphia and Diabolico for all your help. I wouldn’t have made it out of the gate without your posts above.