Install php iconv extension ubuntu

How To Install "php-iconv" Package on Ubuntu

Quick Install Instructions of php-iconv on Ubuntu Server. It’s Super Easy! simply click on Copy button to copy the command and paste into your command line terminal using built-in APT package manager.

See below for quick step by step instructions of SSH commands, Copy/Paste to avoid miss-spelling or accidently installing a different package.



Quick Install Steps:

Step 1

Step 2

sudo apt-get install -y php-iconv

Step 3

Check the system logs to confirm that there are no related errors. You can use ZoomAdmin to check the logs, manager servers, host multiple websites and apps on your servers and more. The apps run in docker containers, to learn more
see ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.

Execute the commands above step by step. You can simply hit the copy button to copy the command and paste into the command line interface.
Note: -y flag means to assume yes and silently install, without asking you questions in most cases.



Detailed Instructions:
Step 1

Run update command to update package repositories and get latest package information.

Step 2

Run the install command with -y flag to quickly install the packages and dependencies.

sudo apt-get install -y php-iconv

Step 3

Check the system logs to confirm that there are no related errors. You can use ZoomAdmin to check the logs, manager servers, host multiple websites and apps on your servers and more. The apps run in docker containers, to learn more
see ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.

Installing and upgrading help

Installing ICONV extension is required

  • ◄ Moodle to Moodle Migration - Best Strategy - Approach
  • New Install, appears there is no CSS styling ►

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

Thanks 

Install php iconv extension ubuntu

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,

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 which case... it's not really a Moodle problem. The best people to help you will be the support provided by your hosting.

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

Thanks for Reply
I am trying to enable the required extension but no option which is required for my moodle
Image here

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

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.

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."

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!

Install php iconv extension ubuntu

'SoS', Ken

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..

Run that from your browser. is iconv in there somewhere?

BTW: trying to install Moodle 3.9

Ran 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

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.

"Ran it does show iconv." – So you see something like this?:

Install php iconv extension ubuntu

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

This is all I get about iconv

Install php iconv extension ubuntu

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.

That doesn't look like the output from phpinfo() to me.

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

Install php iconv extension ubuntu

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...

Install php iconv extension ubuntu

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

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.

Unless I missed something, nobody mentioned fpm. That's not the default on Ubuntu. Although, good spot if it turns out to be

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.

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?

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

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.

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

Here is a screenshot of the Server API.

Install php iconv extension ubuntu

$ 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.

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.

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

Again:

Install php iconv extension ubuntu

Install php iconv extension ubuntu

This doesn't look anything like the usual phpinfo output. This is very strange.

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.:

Install php iconv extension ubuntu

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.

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?

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.

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.

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.

  • ◄ Moodle to Moodle Migration - Best Strategy - Approach
  • New Install, appears there is no CSS styling ►

How to install PHP iconv extension?

See http://www.php.net/manual/en/iconv.installation.php for details..
Open the php. ini file found in the moodle/apache/bin folder..
Find the line: ;extension=php_iconv. dll..
Remove the ; at the beginning of the line..
Restart apache for the change to take effect..

How to enable iconv in PHP WHM?

First, we log in to WHM. Then, we choose EasyApache 4 or EasyApache 3 depending on the WHM version. After that, choose PHP extensions from the list of options available. Next, we choose the iconv extension based on the PHP version we use.