Trouble getting Apache to recognize installed PHP7.2

Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -
Number of replies: 15

Hi All,

I'm trying to install Moodle 3.6. My stack is RHEL 7.6, Apache 2.4.6, MySQL 5.7, PHP 7.2

I've installed the Moodle files to /var/www/moodle, and created a test.php file at /var/www/moodle/web/. The test file tells me Apache is using PHP 5.4, but I certainly have version 7.2 installed (php -v says so). I've tried different methods to get Apache to use the later version, but without success.

I've tried to add a line to my httpd.conf file that points to where PHP 7.2 is: 

LoadModule php7_module /opt/rh/rh-php72/root/usr/lib64/libphp7-7.2.so

But this just gives me an error: "Can't locate API module structure 'php7_module' in file...:undefined symbol: php7_module"

I've seen many other similar threads in this forum, some mentioning a2enmod/a2dismod commands, but my server doesn't have those and I may not be able to get them (university IT has some control over the server).

I have other problems, but I think they're related to trying to step through the web-based install while using php 5.4, so it seems that may be my underlying problem and I guess I'll start there.

I'd appreciate any thoughts on this from the community! Many thanks for your time.

Average of ratings: -
In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

We need our CentOS Red Hat expert wink

Some point...

- you seem to have got command line 7.2 installed but you need to appreciate that command line PHP is nothing whatever to do with the version Apache loads. So 'php -v' tells you only the version of the command line interpreter. 

- a2enmod etc. are Debian/Ubuntu commands

- you're definitely not getting far trying to install Moodle on PHP 5.4

Other than that, as RHEL seems to come with 5.4 (as you note) what did you do to upgrade to 7.2. A quick good turned up loads of articles on installing PHP 7.2 on RHEL 7. Non of which - at first glance - seem terribly onerous. 

In reply to Howard Miller

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Thanks for the quick reply!

I should note that our IT did the initial creation and LAMP installation on this server. They installed PHP 7.2 to /opt/rh. I understand command line version is different than the Apache version...I was trying to demonstrate that 7.2 exists on my system but Apache isn't loading that version. If they are completely different installs I can look into that.

Until now I've been trying to work with IT and get the version they installed to be recognized, but I'm now going to see what else I can do.


In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Ken Task -
Picture of Particularly helpful Moodlers

Nothing like someone else setting up a server then turning it over without info. :|

Me thinks, from what you've shared so far, IT might have used RH's Software Collection repo.

Think your system is using RH Software Collections for repos.
https://access.redhat.com/products/Red_Hat_Enterprise_Linux/Developer/#rhscl=&dev-page=5
which is commercial

For PHP it has always been 'traditional' to use 3rd party (but well known and reliaable)
repos like epel or webtatic for higher versions of PHP.   RH is known to be 'conservative' with PHP versions from their repos.

What does yum repolist show?

cd /etc/yum.repos.d/

ls to see repo config files.

to see which repos are enabled:

yum repolist enabled

to see which repos are disabled:

yum repolist disabled

BTW, most blog/shared info for free (found via Google search) will probably show something other than RH's SCL due to it's commercial nature.

Best to pick your poison (repos) and remember your choice.   Right now the system a little confused - php-cli and php for web not the same.   Can't give speific instructions (which should probably come from your IT department) until repo setup is known.

'spirit of sharing', Ken


In reply to Ken Task

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Wanted to share the output from the commands you mentioned. I've attempted to clean up the formatting. I'll be bringing up the repo issue with our IT.

yum repolist and repolist enabled give the same output:

Loaded plugins: langpacks, product-id, rhnplugin, search-disabled-repos, subscription-manager

This system is receiving updates from RHN Classic or Red Hat Satellite.

  • epel/x86_64                                                                                            
  • remi-safe                                                                                              
  • rhel-x86_64-server-7                                                                                   
  • rhel-x86_64-server-7-rhscl-1                                                                          
  • rhel-x86_64-server-extras-7                                                                           
  • rhel-x86_64-server-optional-7                                                                        
  • rhel-x86_64-server-supplementary-7                                                                     
  • repolist: 70,153

contents of /etc/yum/repos.d/

  • epel.repo          
  • redhat.repo       
  • remi-glpi92.repo 
  • sudremi-glpi94.repo   
  • remi-php54.repo  
  • remi-php71.repo  
  • remi-php73.repo  
  • remi-safe.repo
  • epel-testing.repo  
  • remi-glpi91.repo 
  • remi-glpi93.repo  
  • remi-modular.repo 
  • remi-php70.repo  
  • remi-php72.repo 
  • remi.repo

yum repolist disabled:

  • epel-debuginfo/x86_64                             
  • epel-source/x86_64                               
  • epel-testing/x86_64                               
  • epel-testing-debuginfo/x86_64                     
  • epel-testing-source/x86_64                        
  • remi                                             
  • remi-debuginfo/x86_64                            
  • remi-glpi91                                      
  • remi-glpi92                                       
  • remi-glpi93                                       
  • remi-glpi94                                       
  • remi-modular                                    
  • remi-modular-test                                 
  • remi-php54                                        
  • remi-php55                                        
  • remi-php55-debuginfo/x86_64                       
  • remi-php56                                        
  • remi-php56-debuginfo/x86_64                      
  • remi-php70                                       
  • remi-php70-debuginfo/x86_64                       
  • remi-php70-test                                  
  • remi-php70-test-debuginfo/x86_64                  
  • remi-php71                                        
  • remi-php71-debuginfo/x86_64                       
  • remi-php71-test                                  
  • remi-php71-test-debuginfo/x86_64                 
  • remi-php72                                        
  • remi-php72-debuginfo/x86_64                       
  • remi-php72-test                                   
  • remi-php72-test-debuginfo/x86_64                 
  • remi-php73                                        
  • remi-php73-debuginfo/x86_64                       
  • remi-php73-test                                  
  • remi-php73-test-debuginfo/x86_64                  
  • remi-safe-debuginfo/x86_64                        
  • remi-test                                        
  • remi-test-debuginfo/x86_64                        


In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Ken Task -
Picture of Particularly helpful Moodlers
Since you are installing 3.6.x of Moodle, one does not need the system to use/know about any PHP version lower than 7.1.x   (php 56,70 are no longer supported for updates from PHP itself).
Remove any remi repos for lower than 7.1

Not sure that moodle has been tested to the hilt with 7.3 so no higher than 7.2 of PHP.
You can always upgrade PHP via yum easily once repos are straightened out.

Appears you will be using REMI for PHP - but not sure of the remi-glpi##'s repos.  Here again ... potential for confusion.  IT's responsibility?

May as well mention DB ... we haven't talked about that ... am gonna guess (here we go again... could be wrong)  ... that MariaDB is the 'darling' of commercial RHEL.
MariaDB is supposed to be a 'drop-in replacement' for MySQL.   Well, kinda.  Don't think there is anything in Moodle code that takes advantage of what good things MariaDB is doing ... MySQL <-8.0 ... ie, 5.7 or 5.8 (see requirements for Moodle 3.6.x) will do just as well.   I personally, use MySQL and the repos from MySQL just for MySQL.  No yum confusion then.  Have ability to upgrade to 8.0.x when ready ... now running 5.7 or 5.8  on servers.

'spirit of sharing', Ken




In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Alain Raap -
Picture of Particularly helpful Moodlers

Did you install server api php-fpm?
You can check your installed php packages with yum list installed | grep php7x (x=2 in your case)
Your installed packages should begin with rh-php7x

In reply to Alain Raap

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Looks like I have rh-php72-php-fpm.x86_64, version 7.2.10

In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Ok...some progress.

I have managed to get Apache to use PHP 7.2, by changing the names of the old 5.4 modules and symlinking the new modules into place. Loading my phpinfo page shows 7.2.

So now I should be able to visit the admin page (servername/moodle/admin) and begin web-based configuration, right?

What I see instead appears to be raw php...I've attached a screenshot.


Attachment Screen Shot 2019-04-23 at 08.25.51.jpg
In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Ken Task -
Picture of Particularly helpful Moodlers

This isn't 'progress' ... it's on the rails to a train wreck!

Stop!  Cease!  Desist hacking your own server - symlinks/'sprinkling' etc. will beget nothing but trouble when updating moodle, upgrading moodle or worse yet, having to upgrade PHP or any other software on your system.

Talk to your IT persons first.

Try commands that have been shared with you.

Think you are on the path to learning what doesn't work! :|

'spirit of sharing', Ken


In reply to Ken Task

Re: Trouble getting Apache to recognize installed PHP7.2

by Alain Raap -
Picture of Particularly helpful Moodlers

Ken I agree with you. Andrew, unless you're just 'playing' to take a look at a Moodle installation I would ask advice from your IT department. Installation of Moodle in a Redhat environment isn't an easy job, I know myself, because it took a long time for me to understand Moodle and get it working finally. If you make wrong decisions at the beginning (hardware, network, software integration), you'll pay the price when you've got a Moodle instance running and you run into (performance) problems or networking problems! Just a tip, take time to investigate what you need for your Moodle instance, and not to run in these pitfalls I just mentioned.

In reply to Alain Raap

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Thanks to both of you.

I've been in frequent contact with our IT and will continue given what I've learned in this thread.

I had hoped to take all the time I would need but I've already been at this for a couple of weeks and a hard deadline is approaching.

In reply to Ken Task

Re: Trouble getting Apache to recognize installed PHP7.2

by Ken Task -
Picture of Particularly helpful Moodlers

Additional tip to maybe undo what's been done so far ...

history > mycommands.txt

Viewing mycommands.txt file then will show what you hacked/tweaked/etc. in order to figure out how to reverse engineer.   Other wise, your IT department might not have the time ... nor the inclination ... to figure it out and will re-install the entire OS so you'd be starting over from scratch. 

Am gonna venture a guess that IT department is more Windows oriented and that's why they turned over the server to you. :\.  As 'shadow IT' it's necessary, if I am correct, to prove to IT you can handle it ... or loose the access level.   Domino affect ... takes longer to get things done.

Take your time an learn your system first (repos/etc) before Moodle.  OS is the horse .. Moodle is the cart!

2 cent advice!

'spirit of sharing', Ken



In reply to Ken Task

Re: Trouble getting Apache to recognize installed PHP7.2

by Andrew Stella -

Thanks. This IT group is specifically enterprise Linux, but they require admin of any applications be handled by the user. So, getting the environment set up is mostly up to them, and I did share the software requirements with them. Past that, they will help up to a point but let's just say they  share my sense of urgency, and I understand that.

I agree taking more time to learn the system would have been wise. I have some general Unix experience and a bit of Ubuntu but this is something quite a bit more complex.



In reply to Andrew Stella

Re: Trouble getting Apache to recognize installed PHP7.2

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, then my guess was in-correct.   Great that IT is 'specifically enterprise linux'.

From what you have described, IT should have handled AMP stack ... and you, then responsible only for the Moodle.

But, cart before the horse or horse before the cart? ... IT horse ... you are responsible for the cart.

Then IT:  https://docs.moodle.org/dev/Moodle_3.6_release_notes

Only the server requirements parts ... php, mysql/mariadb, certificate for site, etc.   Web service setup and running, PHP version selected and installed ... phpinfo page to prove to you that version installed is the version you desire.  Certficate for server ... $ via a CA or LetsEncrypt are all IT's jobs.

For your part:

Checking of versions:

php -v

php -m ... are all required PHP extensions for Moodle installed?

mysql -V

Also knowing how Apache setup ... mod/php-fmp/fastcgi, etc.

Those versions meet the requirements of version of Moodle to be installed?    If not, back to IT.

Installation of the moodle.

Would highly recommend installing via git which will make updates and upgrades much easier in future.

https://docs.moodle.org/36/en/Git_for_Administrators

'spirit of sharing', Ken


In reply to Ken Task

Re: Trouble getting Apache to recognize installed PHP7.2

by Alain Raap -
Picture of Particularly helpful Moodlers

In large organizations you get a Linux system and from that moment you are responsible for all the software (middleware like LAMP) and configuration of the ‘Linux box’. That asks some more knowledge of Linux and also of networking, firewalls and (Redhat) security. The last part can be difficult when SeLinux is enabled in your environment. I had difficulties with both networking and security and that took me weeks to find out and get it working in the end.

I don’t know what’s the size of your organization and IT department, maybe something to keep in mind when they (IT) ask you to ride the horse. Try to coorperate with the ‘people on the floor’, they can help you when you’re in trouble. Just my 2 cents wink