How to install mcrypt for PHP 7.2 on Aws Linux 2

How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -
Number of replies: 19

I am trying to install single signon by Edwiser on a new moodle install with 3.5+ and php 7.25 on AWS Linux 2.

It needs mcrypt.  

Now I am getting an error on logon to moodle.

Since I can't get into moodle how do I disable the extension that wants it so I could just remove the plugin.

Thanks

If I could get mcrpyt to work that would be fine.

Thanks for any help.

Average of ratings: -
In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Albert Ramsbottom -

You could try this in the config.php

$CFG->auth = '';
This should override the authentication plugins and let you get to the normal login page


Cheers

In reply to Albert Ramsbottom

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

@Don ... can confirm that Albert's suggestion works.

I normally use: $CFG->auth='manual'; to force to manual.

But, if you associated the only admin account you have to use Edwiser Webservices authentication (see info below in another posting) then we have to find another way to get you in as admin level so you can disable Edwiser config in Moodle.

@Don ... do you have more than one account in the Moodle?  Are all of them set to admin levels?

'spirit of sharing', Ken


In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

When I sign in with a student account I get same message.  The problem is with the Edwiser single signon ext.

I am waiting on their suggestion.

Thanks

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 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

Not entirely helpful, but...

Everybody plus dog uses Ubuntu or CentOS to run Moodle. Amazon provide these options. I would strongly encourage you to consider using the common OSs as we have lots of expertise here. 

Failing that, as AWS is a proprietary OS to Amazon, can't their support people help with this? In the nicest way, it's not so much a Moodle problem as an OS issue.  

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

If you do have to post asking assistance, you do need to provide a little more information about the system.  'AWS Linux 2' ... we know means Amazon Web Services ... but 'Linux 2' means what?    Could that be 'CentOS' ... or 'Ubuntu' ... Linux's also have versions ... CentOS 7 is the most current now.  Ubuntu is up to 18.04 now.  

Besides that, Amazon has partnered with some makers of distro's ... example ... seen an a Ubuntu security announcement ... kernel update for linux-azure.   They also have partnered with Amazon cause the other day there was a kernel update for linux-aws.   That means something is different.

You should be able to find out via ssh and the command 'uname -an' would/should disclose or give a hint as to distro.

As far as mcrypt ... hard to imagine that Amazon doesn't allow ssh access.   So one could **easily** acquire the missing php extension via ssh and package manager ... and specific directions on how to do that dependent upon the Linux distro ... in Ubuntu the package manager is apt-get ... in CentOS 7 the package manager is yum (although they have a newer package manager now).

Then again, Amazon has offered Bitnami ... an AMP (Apache/MySQLorMariaDB/PHP[vr?]) stack with Moodle ... which is Linux but all the parts that make a Moodle go are off into another/non-standard location.

So maybe what's been shared above will give you a hint as to where to look to get the PHP extension you need installed.

'spirit of sharing', Ken

In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 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

I think this is a 'distro' specific to Amazon - https://aws.amazon.com/amazon-linux-ami/

In reply to Howard Miller

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

That's probably true.  What a gigantic maze Amazon is!!!!

Still though ... linux is linux ... right? (har, har) ... but the basics for package management and PHP should be there, I would hope.

Wonder if their offerings come with 'man'?

'spirit of sharing', Ken


In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

AWs has given me the following response:

Thank you for contacting AWS Support. My name is Luke and I will assist you today.

I understand you would like to install mcrypt on php7.2 on Amazon Linux 2.

The installation of mcrypt is out of the scope of our support, however I will help you on a best effort basis. I've taken the liberty to do a bit of extra research on this topic and the following information is provided to your on a best effort basis.

Let me first state that mcrypt is no longer supported (https://wiki.php.net/rfc/mcrypt-viking-funeral) by PHP7.2 . I recommend to get in touch with the people who made your program to see if you can use an earlier version of php with mcrypt or if they have an alternative way to install mcrypt on php7.2.

From my investigation the best way to get php and mcrypt install is to install php 5.4 and mcrypt 5.4 using unsupported EPEL packages from RHEL 7. Please note the following instructions should be tested in a lab environment before being deployed to a production environment. I've detailed instructions below:

 1. Install and enable the EPEL rpm package on RHEL 7 and Amazon Linux 2:

$sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 2. install php-mycrypt

$sudo yum install php-mcrypt

Installing:

 php-mcrypt                            x86_64                      5.4.16-7.el7                             epel                             20 k

Installing for dependencies:

 libmcrypt                             x86_64                      2.5.8-13.el7                             epel                             99 k

 libzip010-compat                      x86_64                      0.10.1-9.amzn2.0.4                       amzn2-core                       30 k

 php-common                            x86_64                      5.4.16-45.amzn2.0.5                      amzn2-core                      566 k

 3. install php

$sudo yum install php

Installed:

  php.x86_64 0:5.4.16-45.amzn2.0.5

 4. epel repo can now be disabled

$ sudo yum-config-manager --disable epel

Alternatively this might be out of scope of your query so I've provided some additional instructions if you need to know how to install php7.2 on Amazon Linux 2 :

1. Enable PHP7.2 in amazon-linux-extras:

$ sudo amazon-linux-extras enable php7.2

2. Install php7.2

$sudo yum install php

4.Verify the version of PHP that's available:

$ sudo yum info php

Version     : 7.2.5

Average of ratings: Useful (2)
In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 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

I failed to pick up on this. MCrypt was completely removed from Moodle back in 3.1.   So, I assume that this relates to something that either isn't Moodle or a third party plugin that's not been updated. Sorry, I don't know what 'Edwiser' is!

Having said all that. The latest versions of Moodle still run with PHP 7.0 which does still support mcrypt (as far as I can tell). 

The other thing I'm taking from this is that this is just a Fedora based distro. So the yum package manager and things like https://webtatic.com/ should work fine with a bit of luck. Ken is your man here.

Average of ratings: Useful (1)
In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

Well, Howard says am the guy .... but ... think it might be best to work with Edwiser and your WordPress to begin with.

You are dealing with RedHat Enterprise version 7 ... not CentOS 7 (which is what I run) ...

Support at Amazon is telling you 'best effort' ... nice of them to confess, but ...

if you follow those directions to get epel and the php-mcrypt he found it will beget version 5.4 and not what you need ... a php72-mcrypt.

Don't think you want to move backwards with php ...

Let's try to find out what you have an exactly what repo the php72 you do have comes from.

In ssh ... let's see if this command will work on Amazon or not:

yum list php71*

That command should start out showing what repos yum is checking.  Looks like:

 * base: repo1.dal.innoscale.net
 * epel: fedora-epel.mirror.lstn.net
 * extras: repo1.dal.innoscale.net
 * updates: repo1.dal.innoscale.net

Then a list installed packages:  Looks like (below just the first line of a long list):

Installed Packages
php71w-bcmath.x86_64                                         7.1.20-1.w7                               @webtatic

What does your @ show?   Above you can tell is webtatic repo

Edwiser Bridge Installation @
https://edwiser.org/bridge/documentation/

Doesn't mention anything about what PHP extensions are required.

Indicates one can install the plugin to WordPress via WordPress Admin.

According to:
https://edwiser.org/bridge/faqs/

First question in the FAQ ...
Which version of Moodle does Edwiser Bridge support?
Edwiser Bridge supports the Moodle version 2.9.x

and the question on which version of WordPress does Edwiser support?
Edwiser Bridge supports the latest version of WordPress which is version 4.4.

Hmmmm ... Word Press is 4.9.8 now.

It appears to use Webservices to interface with Moodle.

Just how far were you able to go into edwiser config?  To the point of associating a user with token/webservice?   And was that user your *only* admin account?

How about answering those last questions before we move forward?

'spirit of sharing', Ken


In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

I ran sudo yum list php*     "did not work without sudo"

[ec2-user@ip-172-31-46-117 www]$ sudo yum list php*
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
php.x86_64              7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-cli.x86_64          7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-common.x86_64       7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-fpm.x86_64          7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-gd.x86_64           7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-intl.x86_64         7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-json.x86_64         7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-mbstring.x86_64     7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-mysqlnd.x86_64      7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-opcache.x86_64      7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-pdo.x86_64          7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-pecl-zip.x86_64     1.15.2-3.amzn2       @amzn2extra-lamp-mariadb10.2-php7.2
php-soap.x86_64         7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-xml.x86_64          7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
php-xmlrpc.x86_64       7.2.5-3.amzn2.0.2    @amzn2extra-lamp-mariadb10.2-php7.2
Available Packages
php-bcmath.x86_64       7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-dba.x86_64          7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-dbg.x86_64          7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-devel.x86_64        7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-embedded.x86_64     7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-enchant.x86_64      7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-gmp.x86_64          7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-ldap.x86_64         7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-mysql.x86_64        5.4.16-43.amzn2      amzn2-core
php-odbc.x86_64         7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-pear.noarch         1:1.10.5-7.amzn2.0.1 amzn2-core
php-pecl-memcache.x86_64
                        3.0.8-4.amzn2        amzn2-core
php-pgsql.x86_64        7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-process.x86_64      7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-pspell.x86_64       7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-recode.x86_64       7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
php-snmp.x86_64         7.2.5-3.amzn2.0.2    amzn2extra-lamp-mariadb10.2-php7.2
[ec2-user@ip-172-31-46-117 www]$

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

Yes, you will have to prefix any command with 'sudo'.   Sudo designed to protect system from operator.   Hmmmmm .... sometimes gets in the way if you have serveral commands to execute.

So next time you login, try 'sudo -s'

That will prompt for your password ... same one you used to login to the site, but your prompt should change now and you'll be 'root'.

If you do the above use 'exit' **twice** ... once to get out of root ... and once to logout from the server.

It's not clear to me where you are going but think contacting Edwiser people is in order ... either their FAQ is out of date and needs updating or their plugin for Moodle 3.5 no longer compatible or ????

A lesson to learn about setting up webservices ... that will be tied to a user.   Create a user just for that purpose ... never ever use your original admin user for that purpose and never set up your secondary admin level user for other purposes either.

BTW, nice to know do have command line ...

you might explore the use of /admin/cli/cfg.php

php cfg.php --help

Does show ways one can change configuration of various things ...

to list them all:

php cfg.php

That will scroll a lot of info so suggest:

php cfg.php > configvars.txt

You can then call up or cat configvars.txt to figure out stuff about webservices.

'spirit of sharing', Ken


In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

Thanks so much for the help.  

I think Edwiser should solve it for me.  I am waiting on their response and will post it here.

I hop I could remove the ext folder from the moodle directory.  But I just can't find what to remove.

This is a new setup so I have dulicate AWS instance running that I will start using for the live site setup.

Thanks for sharing!

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

Well, a CentOS 7 (which is based upon RHEL7) Moodle 3.5.1+ has the following stock authentication plugins:

cas      email       lti     nologin    yui
classes  manual  none     shibboleth  upgrade.txt
db       ldap        mnet    oauth2   tests       webservice

Since Edwiser appears to use webservices can't remove the stock 'webservice' authentication.

There is nothing to remove (that's a guess).

It's probably all in the mdl_config_plugins table.

Did you have to install more than one addon to Moodle code?

Some more info from one of their pages:

https://edwiser.org/bridge/extensions/single-sign-on/

COMPATIBILITY DETAILS

WordPress Version 4.4.2 up to 4.9

Edwiser Bridge Version 1.3.3

WooCommerce Version 2.5.5 up to 3.2.6

Moodle Version 3.0.3 up to 3.5.0

PHP version 5.6 up to 7.1

So it looks like your PHP version 7.2 is the culprit?  Maybe?

On a CentOS 7 server with Webtatic repo for PHP:

php71w-mcrypt.x86_64

So 7.1 has mcrypt it appears.

But not 7.2 ... if webtatic had it, it would be listed in the 'm's'

php72w-mbstring.x86_64                        7.2.8-1.w7                webtatic
php72w-mysql.x86_64                           7.2.8-1.w7                webtatic
php72w-mysqlnd.x86_64                         7.2.8-1.w7              webtatic

It's not.  Also gone from epel and even remi.

'spirit of sharing', Ken




In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

Edwiser is updating it's plug-ins on Monday.  

Thanks for your help and sharing.

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Ken Task -
Picture of Particularly helpful Moodlers

Good to hear it.

Feel free to mark any posting that was helpful as 'Useful' ... that's how one says 'Thanks' with having to say it in a posting. smile

'spirit of sharing', Ken



In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

It appears to use Webservices to interface with Moodle.

Just how far were you able to go into edwiser config?  To the point of associating a user with token/webservice?   And was that user your *only* admin account?

How about answering those last questions before we move forward?

I fully configured the edwiser and got most everything else to work until I installed the Single-Signon Ext.
In reply to Ken Task

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

Thanks I should know that.  I will follow direction below!

In reply to Don DeRespinis

Re: How to install mcrypt for PHP 7.2 on Aws Linux 2

by Don DeRespinis -

I deleted the wdmwpmoodle directory under /auth  

After warning me about the missing plugin I was able to log in.

I am going to reinstall the woocommerce and edwiser bridge plugins without the SSO.

Thanks