在Amazon Ec2上为apache用户设置路径变量

时间:2021-12-01 11:08:30

I've been on this for a good few hours and I'm not getting anywhere.

我已经在这几个小时了,我没有到达任何地方。

I can't add /usr/local/bin to the apache users PATH variable. The user doesn't have a .profile, I can't su to the user, I can't export to the PATH from php using exec and adding

我无法将/ usr / local / bin添加到apache用户PATH变量中。用户没有.profile,我不能su给用户,我无法使用exec从php导出到PATH并添加

SetEnv PATH /usr/local/bin

SetEnv PATH / usr / local / bin

To either the http.conf or the .htaccess file doesn't make a difference. I can't find the envvars file to change that but I suspect there's some other problem.

要么http.conf或.htaccess文件没有区别。我找不到envvars文件来改变它,但我怀疑还有其他一些问题。

I have restarted apache, and indeed my server.

我重新启动了apache,确实是我的服务器。

Any help please?

有什么帮助吗?

2 个解决方案

#1


6  

Ended up following what Alfe suggested in his answer, except rather than in the /etc/init.d/httpd file (which could be overwritten easily on update) I added to /etc/sysconfig/httpd

结束了Alfe在他的回答中建议的内容,除了在/etc/init.d/httpd文件中(可以在更新时轻松覆盖),我添加到/ etc / sysconfig / httpd

export PATH=${PATH:+$PATH:}/usr/local/bin

#2


1  

Have a look at the /etc/passwd to see which login shell the apache user has (on EC2 Ubuntu instances it should be /bin/sh which is a link to /bin/dash). Then have a look at the man page of that shell and find out which configuration files are read upon login. (For /bin/dash that would be .login in the user's home directory.) In those you should be able to extend your $PATH as you like.

看一下/ etc / passwd,看看apache用户有哪个登录shell(在EC2 Ubuntu实例上它应该是/ bin / sh,它是/ bin / dash的链接)。然后查看该shell的手册页,找出登录时读取的配置文件。 (对于/ bin / dash,在用户的主目录中是.login。)在那些你应该能够扩展你的$ PATH。

EDIT:

Since you seem to have no login shell for that user: Have a look at the /etc/init.d/* scripts which start the system services. Apache will be one of them. They are started as root and may change the current user (e. g. to the apache user). In there you might be able to adjust the PATH as you like it.

由于您似乎没有该用户的登录shell:查看启动系统服务的/etc/init.d/*脚本。 Apache将成为其中之一。它们以root身份启动,可能会更改当前用户(例如,更改为apache用户)。在那里你可以根据自己的喜好调整PATH。

Patching those scripts, however, is not considered typical configuration. Updates might overwrite what ever you patch there.

但是,修补这些脚本不被视为典型配置。更新可能会覆盖您在那里修补的内容。

#1


6  

Ended up following what Alfe suggested in his answer, except rather than in the /etc/init.d/httpd file (which could be overwritten easily on update) I added to /etc/sysconfig/httpd

结束了Alfe在他的回答中建议的内容,除了在/etc/init.d/httpd文件中(可以在更新时轻松覆盖),我添加到/ etc / sysconfig / httpd

export PATH=${PATH:+$PATH:}/usr/local/bin

#2


1  

Have a look at the /etc/passwd to see which login shell the apache user has (on EC2 Ubuntu instances it should be /bin/sh which is a link to /bin/dash). Then have a look at the man page of that shell and find out which configuration files are read upon login. (For /bin/dash that would be .login in the user's home directory.) In those you should be able to extend your $PATH as you like.

看一下/ etc / passwd,看看apache用户有哪个登录shell(在EC2 Ubuntu实例上它应该是/ bin / sh,它是/ bin / dash的链接)。然后查看该shell的手册页,找出登录时读取的配置文件。 (对于/ bin / dash,在用户的主目录中是.login。)在那些你应该能够扩展你的$ PATH。

EDIT:

Since you seem to have no login shell for that user: Have a look at the /etc/init.d/* scripts which start the system services. Apache will be one of them. They are started as root and may change the current user (e. g. to the apache user). In there you might be able to adjust the PATH as you like it.

由于您似乎没有该用户的登录shell:查看启动系统服务的/etc/init.d/*脚本。 Apache将成为其中之一。它们以root身份启动,可能会更改当前用户(例如,更改为apache用户)。在那里你可以根据自己的喜好调整PATH。

Patching those scripts, however, is not considered typical configuration. Updates might overwrite what ever you patch there.

但是,修补这些脚本不被视为典型配置。更新可能会覆盖您在那里修补的内容。