user9465677
user9465677

Reputation: 427

Drupal 6 and multiple versions of PHP

My still requires me to run Drupal 6 (yes I understand the risks). I have multiple versions of PHP installed on my Ubuntu 16.04 - 5.6, 7, 7.2.3. The 7.2.3. is being used by Laravel and my Drupal 7 installs. I tried making updates to Drupal 6 but it keeps on complaining about the mbsting.http_input. Even though I have updated the php.ini for 7.23 it is still there. Is there a way that I can point drupal 6 to PHP 5.6 while still keeping 7.2.3 for the rest?

To add some additional context - when I log to my drupal 6 blog and go to install.php it says drupal already installed. But when I go to the main page it show 500 error.

Upvotes: 1

Views: 174

Answers (1)

norman.lol
norman.lol

Reputation: 5374

Yes you can use different PHP versions per vhost. But it's quite fiddly to setup (at least for me it was). Have a look at mod_proxy_fcgi and ProxyPassMatch.

I once managed to set this up in Docker (Dockerfile). Natively I guess it must go along the lines of the following Apache confs.

drupal6.com.conf

Listen 80

<VirtualHost *:80>

    ServerName drupal6.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/php56

    ErrorLog ${APACHE_LOG_DIR}/php56error.log
    CustomLog ${APACHE_LOG_DIR}/php56access.log combined

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/var/www/php56"
    <Directory "/var/www/php56">
        Order allow,deny
        Allow from all
        AllowOverride FileInfo All
        Require all granted
    </Directory>

</VirtualHost>

drupal7.com.conf

Listen 80

<VirtualHost *:80>

    ServerName drupal7.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/php72

    ErrorLog ${APACHE_LOG_DIR}/php72error.log
    CustomLog ${APACHE_LOG_DIR}/php72access.log combined

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php/php7.1-fpm.sock|fcgi://localhost/var/www/php72"
    <Directory "/var/www/php72">
        Order allow,deny
        Allow from all
        AllowOverride FileInfo All
        Require all granted
    </Directory>

</VirtualHost>

For Nginx take the following approach as starting point (source).

  1. $ git clone https://gist.github.com/2fca8bfdc5004bade15bac84b9ab73e7.git test/multiphp
  2. $ docker build -t nginx-multiphp test/multiphp
  3. $ docker run -p 8856:8856 -p 8871:8871 --rm -P nginx-multiphp
  4. In your browser visit: http://localhost:8856 for PHP56 and http://localhost:8871 for PHP71 accordingly.
  5. Happy happy

Upvotes: 1

Related Questions