0

I had to migrate from an old server (Plesk 14; CentOS 5; Apache 2.2; PHP 5.3.5) to a new one (Plesk Onyx 17; CentOS 7.3; Apache 2.4; PHP 7)

Everything works fine with the exception of the custom Virtual Hosts.

On the old server, in my etc/httpd/conf/httpd.conf I had the following and it was working:

<VirtualHost XX.XX.XX.XX:80>
 DocumentRoot /var/www/vhosts/mycompany.com/httpdocs/myproject
 ServerName  myproject.com
 ServerAlias www.myproject.com

   <Directory /var/www/vhosts/mycompany.com/httpdocs/myproject>
        <IfModule sapi_apache2.c>
          php_admin_flag engine on
          php_admin_flag safe_mode on
        </IfModule>

       <IfModule mod_php5.c>
          php_admin_flag safe_mode off
          php_admin_value upload_tmp_dir "/tmp"
          php_admin_value session.save_path "/tmp"
       </IfModule>

       php_admin_flag engine on
       AddHandler php5-script .php

    </Directory>

</VirtualHost>

If I didn't have the php_admin_flag engine on and the AddHandler it would just download the php file as text.

On the new server I tried the exact same and it just downloads the php file.

I also tried adding the following in <Directory> with no success:

LoadModule php5_module  /usr/lib64/httpd/modules/libphp5.so
#Error:  Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.

php_admin_flag engine on
# Invalid command 'php_admin_flag', perhaps misspelled or defined by a module not included in the server configuration

AddType text/html .php 
#I used this to make sure AddType works. It does - PHP displayed as HTML

AddType application/x-httpd-php .php
#Downloads the file as text

AddHandler application/x-httpd-php .php
#Downloads the file as text

AddType php5-script  .php
#Shows php as plain text

Something worth mentioning is that on this Plesk there are multiple PHP versions. When I do php -v I get PHP 5.3.5 (cli) but when I use phpinfo() in a page I get "PHP Version 7.0.18".

My guess is that it has something to do with that.

On the Admin panel in Plesk it says run PHP 7 as FPS Application

plesk-php-fpm

Here's a snapshot of the phpinfo() https://pste.eu/p/BGpI.html

Any idea what could it be?

1 Answer 1

1

Hi Miro,

did you consider to SWITCH from MPM-EVENT to MPM-PREFORK, in order to be able to USE the libapache2 - PHP - module ?

LoadModule php5_module  /usr/lib64/httpd/modules/libphp5.so
#Error:  Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.

=> HOME > Tools & Settings > Apache Web Server > ( option ) MPM mode

Sign up to request clarification or add additional context in comments.

6 Comments

Changed the MPM to Prefork it works great now with this: LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so | AddHandler application/x-httpd-php .php Thank you!
The downside to this is that it's running php5 now. Any idea how to loadModule for php7?
"Any idea how to loadModule for php7" - Sure... just upgrade your vendor PHP - version to 7.0 or even 7.1. Example for CentOS 7.3: => yum --enablerepo=remi,remi-php71 install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
Hmm. What i meant was how to use the existing php 7 that comes with plesk? For example this and this open the same file on server but one is routed through VirtualHost with libphp5.so. Any idea how to load the existing php 7?
Miro... you might misunderstand something here: The additional Plesk PHP versions don't have an libapache2 - PHP - module for your apache - webserver and you can only use ONE of these modules for your installed apache - webserver on your server. ;-)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.