Home > php教程 > php手册 > PHP shell函数的环境变量

PHP shell函数的环境变量

WBOY
Release: 2016-06-06 20:10:25
Original
933 people have browsed it

php 使用默认 LOCALE=C 来执行shell echo shell_exec('export LANG=zh_CN.UTF-8 locale cd /home/mydir mycmd 2 不然shelli不能使用zh_CN.UTF-8的中文选项或者参数 $locale = 'zh_CN.UTF-8';setlocale(LC_ALL, $locale);putenv('LC_ALL='.$locale); 上面这种

php 使用默认 LOCALE=C 来执行shell

echo shell_exec('export LANG=zh_CN.UTF-8 && locale && cd  /home/mydir && mycmd   2>&1');
Copy after login

不然shelli不能使用zh_CN.UTF-8的中文选项或者参数

$locale = 'zh_CN.UTF-8';
setlocale(LC_ALL, $locale);
putenv('LC_ALL='.$locale);
Copy after login

上面这种方式比较繁琐

至于path,在nginx可以通过
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin:/your/path; 来传递环境变量

参考资料

http://serverfault.com/questions/418952/setting-path-for-weberver-user

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template