
A broken pearl (generated by Midjourney). Credit: libre-software.net. License: CC BY-SA 4.0
Ubuntu: resolve the “perl: warning: Setting locale failed” problem
Last updated on October 11, 2022
Are you running Ubuntu 18.04, 20.04 or 22.04 desktop or server edition, and getting warning or errors when installing software via apt-get or aptitude?
Here is a typical error message:
perl: warning: Setting locale failed.perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_TIME = "es_ES.UTF-8", LC_MONETARY = "de_DE.UTF-8", LC_ADDRESS = "de_DE.UTF-8", LC_TELEPHONE = "de_DE.UTF-8", LC_NAME = "de_DE.UTF-8", LC_MEASUREMENT = "de_DE.UTF-8", LC_IDENTIFICATION = "de_DE.UTF-8", LC_NUMERIC = "de_DE.UTF-8", LC_PAPER = "de_DE.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system.perl: warning: Falling back to a fallback locale ("en_US.UTF-8").locale: Cannot set LC_ALL to default locale: No such file or directory
Sometimes, trying to solve the problem using the update-locale or locale commands does not work and generates following error messages:
~ # sudo update-locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "de_DE.UTF-8",
LC_ADDRESS = "de_DE.UTF-8",
LC_MONETARY = "de_DE.UTF-8",
LC_NUMERIC = "de_DE.UTF-8",
LC_TELEPHONE = "en_US.UTF-8",
LC_IDENTIFICATION = "en_US.UTF-8",
LC_MEASUREMENT = "en_US.UTF-8",
LC_TIME = "es_ES.UTF-8",
LC_NAME = "de_DE.UTF-8",
LANG = (unset),
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
or
~ # locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME=es_ES.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=
Solution to the perl locale problem
The solution is to export the missing locales to ~/.bash_profile. The following command is a one-command line:
echo "export LANGUAGE=en_US.UTF-8export LANG=en_US.UTF-8export LC_ALL=en_US.UTF-8">>~/.bash_profile
You could also run each command separately:
echo "export LANGUAGE=en_US.UTF-8">>~/.bash_profile
Alternatively, edit ~/.bash_profile “by hand” with nano, vim or a graphical editor like gedit or xed (Linux Mint).
Don’t forget to reboot and check if the new locales are applied with the locale command.
Another solution is to add the locale variables to /etc/environment instead of ~/.bash_profile.
By Johannes Eva, April 2017 – October 2022
4 thoughts on “How to install a LEMP stack on Ubuntu Server 20.04, 22.04 or 24.04”
Hi Eva…
Thanks for this complete tutorial, it is really very helpful for the community. But, for those who don’t want to bother installing the LEMP stack one by one, you can use the auto installer tools.
For this, I usually use the LEMPer Stack, it might be useful for auto-installing the LEMP stack and at the same time managing a vps/cloud server for hosting PHP websites without the need for cpanel 🙂
LEMPer Stack
This tool is free and open source, you can contribute to its development via the Github repo => https://github.com/joglomedia/LEMPer
Looking forward to your feedback/review..
🙏🏻🤗
MySQL might takeover MariaDB in the near future for at least like WordPress servers, unless Maria gets a lot more money/team size.
See the SlickStack readme https://github.com/littlebizzy/slickstack
However interesting seems Ubuntu 20.04 is now supporting both of them.
Hi, this question is answered in this article, have a look here:
2.4 Test Nginx
Short answer: for basic tasks, use
service.On some blogs, I see
sudo service mysql startfor starting mariadb server whereas on other sites I see the command assudo systemctl start mariadb.service.I want to know what’s the difference and which works correctly on Ubuntu 18.04?
Comments are closed.