Installing ICONV extension is required

Installing ICONV extension is required

by Nawaraj Ghimire -
Number of replies: 31

I am trying to install Moodle following error occur please help to complete installation 

Thanks 

Install error

Average of ratings: -
In reply to Nawaraj Ghimire

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes, you need to install the PHP iconv, zip, fileinfo, xmlrc (and whatever else) extensions.

It sounds like you have a very basic PHP installation. Without knowing what the operating system is and how PHP was installed, there isn't much else I can say,
In reply to Howard Miller

Re: Installing ICONV extension is required

by Nawaraj Ghimire -
Thanks for reply
I am Try to install PHP Extension using (Cpanel and WHM) login I am unable to solve this problem I think I have (Linux server)
Thanks
In reply to Nawaraj Ghimire

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In which case... it's not really a Moodle problem. The best people to help you will be the support provided by your hosting.
In reply to Nawaraj Ghimire

Re: Installing ICONV extension is required

by Ken Task -
Picture of Particularly helpful Moodlers

Multiple php extensions to install.
Please see
https://docs.moodle.org/38/en/PHP
https://docs.moodle.org/dev/Moodle_3.8_release_notes

"Proudly Served by LiteSpeed"

Screen shot shows mulltipe cPanel tabs so would think your cPanel has some tool for Web service as well as PHP version + PHP extensions to load.  Don't use cPanel myself, but would imagine there is a cPanel page showing PHP extensions and you just need to click the box (check mark?) to tell server to use an extension.

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Installing ICONV extension is required

by Nawaraj Ghimire -
Thanks for Reply
I am trying to enable the required extension but no option which is required for my moodle
Image here
In reply to Nawaraj Ghimire

Re: Installing ICONV extension is required

by Ken Task -
Picture of Particularly helpful Moodlers

Your serve is hosted on asiaServerHost.com
That's your provider.

WHM and cPanels are provided by provider for customers to set up servers.
Moodle is only a PHP application that runs under a web service (Apache/Other ... your server is set up to use Litespeed).  Moodle requires a certain version of PHP + php extensions.  Without those extensions Moodle cannot be installed.

These forums are for Moodle but not configuration of WHM or cPanel on what could be 100's of thousands of providers. Contact technical support of your provider for specifics and details about how to use WHM/cPanel to install required PHP extensions.

'SoS', Ken

In reply to Ken Task

Re: Installing ICONV extension is required

by cyber sec -
I am also having a little trouble with php-iconv. I am using Ubuntu. When I try to install php-iconv, I get php-common instead.

# apt install php-iconv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.4-common' instead of 'php-iconv'
php7.4-common is already the newest version (7.4.3-4ubuntu2.4).
php7.4-common set to manually installed.

I cannot install php-iconv, and moodle will not install without it.
In reply to cyber sec

Re: Installing ICONV extension is required

by cyber sec -

The php-iconv module, seems to be installed.

# php -m | grep iconv
iconv 

I have restarted the webserver serveral times. But I keep getting the same error. "Moodle requires the iconv PHP extension. Please install or enable the iconv extension."

In reply to cyber sec

Re: Installing ICONV extension is required

by Ken Task -
Picture of Particularly helpful Moodlers

Don't use Ubuntu, but ... similar ... php-iconv is part of what is installed via php-common ... or supposed to be.

Does your server have multiple versions of PHP installed?

which php

use the full path shown in 'which' response and check version:

/full/path/to/php -v

Is that /full/path/to/php really an alias to a higher version of PHP?

Mind have to use a find as root user:

find / -name ??-iconv*

on an older Ubuntu that needs an upgrade to php to run higher version of Moodle, above command show:

/etc/php/7.0/apache2/conf.d/20-iconv.ini
/etc/php/7.0/cli/conf.d/20-iconv.ini

Also:

find / -name iconv.so

should show the .so file in something like:

/usr/lib/php/20151012/iconv.so

you might see version directories where it shows 20151012 above.

Howard uses Ubuntu ... maybe he'll jump in here an correct me! smile

'SoS', Ken

Average of ratings: Useful (1)
In reply to cyber sec

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This command doesn't help. It tells you that command line PHP has it - but that's a separate thing from the web version.

In your web root write a short PHP file called test.php with the following contents..

<?php phpinfo();

Run that from your browser. is iconv in there somewhere?
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Installing ICONV extension is required

by cyber sec -
BTW: trying to install Moodle 3.9

Ran <?php phpinfo();> it does show iconv.

# find / -name iconv.so
/usr/lib/php/20190902/iconv.so

# find / -name ??-iconv*
/etc/php/7.4/cgi/conf.d/20-iconv.ini
/etc/php/7.4/fpm/conf.d/20-iconv.ini
/etc/php/7.4/cli/conf.d/20-iconv.ini

# php -v
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

If it matters:

# uname -a
Linux www 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
In reply to cyber sec

Re: Installing ICONV extension is required

by cyber sec -
I had moodle installed before. But I decided I should install SSL first, so I deleted the fresh install. Could the problem be with the database? I don't see how, but I am grasping for straws.
In reply to cyber sec

Re: Installing ICONV extension is required

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

"Ran <?php phpinfo();> it does show iconv." – So you see something like this?:

iconv section from phpinfo()

So what happens when you try to install Moodle? Can you share a screenshot of any error messages you get?

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Installing ICONV extension is required

by cyber sec -
This is all I get about iconv


As for the error, there is no need for a screenshot. It is just a blank screen with: "Moodle requires the iconv PHP extension. Please install or enable the iconv extension."

I have completely removed, and re-installed the Postgresql database.
I removed all the files in the moodledata directory.
I removed the /var/www/html/moodle directory, and all the files.
I re-installed moodle-3.10.1.tgz into the /var/www/html/moodle directory. I was previously trying to install 3.9.

But I keep getting the same error.
In reply to cyber sec

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That doesn't look like the output from phpinfo() to me.
In reply to cyber sec

Re: Installing ICONV extension is required

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

So, on Ubuntu 20.10 site... the first mention of Iconv in phpinfo is here...


Note the highlight. Also note the .ini file that php is trying to import. If you have the standard Ubuntu config that should be there.

$ cat /etc/php/7.4/apache2/conf.d/20-iconv.ini
; configuration for php common module
; priority=20
extension=iconv.so

Further down, in more detail...


Again, note the highlights. 

If you don;t have something very much like this then you either didn't run phpinfo through the web server and browser (which I don't think you did) or you don't have iconv

Average of ratings: Useful (1)
In reply to cyber sec

Re: Installing ICONV extension is required

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The iconv extension isn't enabled in PHP for the web server environment.

Can you check the Server API entry near the top of PHP Info? Does it say "FPM/FastCGI"? In which case that's the environment it needs to be enabled for.

What does /etc/php/7.4/fpm/conf.d/20-iconv.ini contain? It should say something like:

extension=iconv

Have you tried restarting PHP-FPM which on Red Hat-like systems is done with systemctl restart php-fpm but might be different on Ubuntu. This is needed if the PHP configuration has changed since it was started.

When iconv is enabled you will see entries similar to my PHP Info screenshot and the 20-iconv.ini should also be listed under Additional .ini files parsed.

Average of ratings: Useful (2)
In reply to Leon Stringer

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Unless I missed something, nobody mentioned fpm. That's not the default on Ubuntu. Although, good spot if it turns out to be smile
In reply to Howard Miller

Re: Installing ICONV extension is required

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

OK, I don't really know Ubuntu, it was in the listing here so wasn't sure:

 # find / -name ??-iconv*
/etc/php/7.4/cgi/conf.d/20-iconv.ini
/etc/php/7.4/fpm/conf.d/20-iconv.ini
/etc/php/7.4/cli/conf.d/20-iconv.ini

cyber sec: If it's not FPM then PHP Info may instead say something like Server API: Apache 2.0 Handler in which case it's Apache that should be reloaded to re-read PHP configuration changes. Please tell us what the Server API says.

In reply to Leon Stringer

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
My config settings for php on Ubuntu don't look exactly like that. It may have been doctored by cPanel of course. I think this comes down to "ask your host". Isn't that what I said way back? big grin big grin
In reply to Leon Stringer

Re: Installing ICONV extension is required

by Ken Task -
Picture of Particularly helpful Moodlers

Didn't mean to confuse ... I was using older Ubuntu built by rookie @ Ubuntu many moons ago ... so the 'find' command was my attempt to assist (as is known, am a RH Family person).

Still though that find command should find iconv.ini on any linux system.

One thing I've learned in assisting folks who grant me access to their system ... you get what provider provides you.  Not unusual to see some differences ... close to generic docs ... but suttle diffs can drive one to drinkin'! :|

'SoS', Ken

In reply to Ken Task

Re: Installing ICONV extension is required

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 we're all confused. We're missing a load of basic information here.

Most cPanel installs that I have seen only superficially look like the distro they are supposedly built on top of.
In reply to Leon Stringer

Re: Installing ICONV extension is required

by cyber sec -

My previous post show the only place iconv was mentioned with phpinfo.

Here is a screenshot of the Server API.


$ cat /etc/php/7.4/fpm/conf.d/20-iconv.ini
; configuration for php common module
; priority=20
extension=iconv.so

$ sudo systemctl reload php7.4-fpm.service

$ sudo systemctl restart php7.4-fpm.service

Still getting the same error.


In reply to cyber sec

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
But you haven't run a phpinfo() test script like we asked you to. That proves whether it is installed or not one way or another.
In reply to Howard Miller

Re: Installing ICONV extension is required

by cyber sec -
I have run a phpinfo() test script like I was asked to. See screenshot above.

Again:







In reply to cyber sec

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This doesn't look anything like the usual phpinfo output. This is very strange.
Average of ratings: Useful (1)
In reply to cyber sec

Re: Installing ICONV extension is required

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

It looks like your web server is not using PHP-FPM (Server API: Apache 2.0 Handler) and so isn't reading configuration files from /etc/php/7.4/fpm/conf.d. In fact the server isn't reading any configuration files, both Loaded Configuration File and Additional .ini files should have files, e.g.:

PHP info excerpt showing which .ini files were read

So could it be that Apache is configured to use mod_php, but PHP and its extensions are configured for use with PHP-FPM?

I'm not an Ubuntu expert but setting up PHP for use with Apache is such a common operation I would expect the packages to just work on install. If I get time I'll set up an Ubuntu VM to see if I can work out how this should be set up. Or you could share with us any steps you followed to set up PHP and Apache.

But somehow the Apache and/or PHP configuration on this server isn't set up correctly.

Average of ratings: Useful (3)
In reply to Leon Stringer

Re: Installing ICONV extension is required

by cyber sec -
Before I set up Apache, I tried using Lighttpd. The problem I had with Lighttpd is: I could not get my SSL cert to work. So I removed lighttpd (#apt remove lighttpd) and installed apache. Getting SSL setup on apache was not difficult.

It may be that lighttpd was setup to use PHP-FPM. But even if it was, shouldn't that have been fixed by removing lighttpd, and installing apache?

Maybe I should completely remove php and apache. Then re-install?
In reply to cyber sec

Re: Installing ICONV extension is required

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It would suggest that PHP has not installed properly. I have no idea why.

As Leon says, installing PHP and Apache on Ubuntu is so common that I have never known it to go wrong. You might also want to check your /etc/apt sources to make sure you aren't pulling PHP from somewhere else - it's the only thing I can think of.
Average of ratings: Useful (2)
In reply to cyber sec

Re: Installing ICONV extension is required

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The theory about Lighttpd makes sense: Lighttpd would need PHP-FPM so these were the packages and configuration files that got installed installed.

Erasing both PHP and Apache and then reinstalling these sounds like a good plan. Afterwards check that PHP's .ini files are present in /etc/php7.4/apache2/conf.d as shown in Howard's screenshot, e.g. /etc/php7.4/apache2/conf.d/20-iconv.ini.

If it still doesn't work, could you set up a new Ubuntu VM and install Apache with PHP, and then check PHP Info on the VM. This should work, i.e. iconv and other extensions should be there. You could then compare this VM's packages and configuration with the Moodle server.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Installing ICONV extension is required

by cyber sec -
Removing apache2 and all php, then reinstalling, worked like a charm. Turns out to be much faster than digging through configuration files, and trouble shooting, etc.

I am not sure why I had to do this. But it worked.

Moodle site is up and running, and seems to work with ssl cert.