我在Linux系统上运行Perl时遇到问题(Ubuntu):
# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2018-03-03 15:31:52 EST; 7min ago
Process: 12841 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 12841 (code=exited, status=78)
Mar 03 15:31:51 instance-1 systemd[1]: Starting The PHP FastCGI Process Manager...
Mar 03 15:31:52 instance-1 php-fpm[12841]: [03-Mar-2018 15:31:52] ERROR: [/etc/php-fpm.d/www.conf:12] unknown entry '#listen'
Mar 03 15:31:52 instance-1 php-fpm[12841]: [03-Mar-2018 15:31:52] ERROR: Unable to include /etc/php-fpm.d/www.conf from /etc/php-fpm.conf at line 12
Mar 03 15:31:52 instance-1 php-fpm[12841]: [03-Mar-2018 15:31:52] ERROR: failed to load configuration file '/etc/php-fpm.conf'
Mar 03 15:31:52 instance-1 php-fpm[12841]: [03-Mar-2018 15:31:52] ERROR: FPM initialization failed
Mar 03 15:31:52 instance-1 systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
Mar 03 15:31:52 instance-1 systemd[1]: Failed to start The PHP FastCGI Process Manager.
Mar 03 15:31:52 instance-1 systemd[1]: Unit php-fpm.service entered failed state.
Mar 03 15:31:52 instance-1 systemd[1]: php-fpm.service failed.
谷歌搜索显示,这通常与环境变量有关,指的是缺少的语言环境,但所有语言环境似乎都在那里:
user@Box:~$ perl -e exit
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_DK.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_DK.UTF-8").
我已尝试安装所有的en,但这似乎不会影响任何事情。
答案 0 :(得分:4)
在撰写问题时找到答案:
罪魁祸首是user@Box:~$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
C
en_DK.utf8
en_GB.utf8
en_US
en_US.iso88591
en_US.utf8
POSIX
,这显然在macOS中完全有效(而Perl会在那里接受它),但在Linux上则不然。为避免这种情况,可以按如下方式覆盖LC_CTYPE=UTF-8
:
LC_CTYPE
退出并重新登录后,Perl将不再抱怨。
root@Box:~# update-locale LC_CTYPE=en_US.UTF-8