似乎我无法对我的VPS上的PHP脚本做任何事情。
当我尝试上传某个目录到某个目录时,它返回“权限被拒绝”。
是的,我已经将权限更改为777,并且可行,但我不喜欢这种不安全感
运行命令时:
ps axu|grep apache|grep -v grep
它返回
nobody 7689 0.1 3.8 50604 20036 ? S 21:38 0:00 /usr/local/apache/bin/httpd -k start -DSSL root 13600 0.0 3.8 50304 20348 ? Ss Jun06 0:46 /usr/local/apache/bin/httpd -k start -DSSL nobody 15733 0.1 3.8 50700 20156 ? S 21:39 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 15818 0.1 3.8 51492 20180 ? S 21:39 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 23843 0.1 3.7 51336 19592 ? S 21:40 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30335 0.0 3.5 50436 18496 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30406 0.0 3.5 50444 18544 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30407 0.0 3.5 50556 18696 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30472 0.0 3.6 50828 19348 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30474 0.0 3.5 50668 18868 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30476 0.0 3.6 50532 19064 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 30501 0.0 3.8 50556 20080 ? S 21:36 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32341 0.0 3.5 50444 18492 ? S 21:41 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32370 0.0 3.5 50444 18476 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32414 0.1 3.7 51336 19524 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32416 0.1 3.5 50668 18816 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32457 0.1 3.6 50828 19320 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32458 0.1 3.6 50772 19276 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32459 0.0 3.5 50444 18504 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32460 0.2 3.6 50828 19320 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32463 0.0 3.5 50444 18472 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL nobody 32466 0.0 3.4 50436 17960 ? S 21:42 0:00 /usr/local/apache/bin/httpd -k start -DSSL
该目录的所有者是“用户[505]”,该组是“用户[508]”(如在WinSCP中所见)
我能做些什么来改变Apache处理程序到合适的所有者和组以允许我的PHP脚本工作?
PS
我的PHP未设置为安全模式,并且open_basedir设置为无值
编辑 :
这就是我的httpd.conf的外观(对于关联域)
<VirtualHost *:80> ServerName domain.com ServerAlias www.domain.com DocumentRoot /home/domain/public_html ServerAdmin info@domain ## User <theUsername> # Needed for Cpanel::ApacheConf <IfModule mod_userdir.c> Userdir disabled Userdir enabled <userName> </IfModule> <IfModule mod_suphp.c> suPHP_UserGroup <userName> <userName> </IfModule> <IfModule !mod_disable_suexec.c> SuexecUserGroup <userName> <userName> </IfModule> CustomLog /usr/local/apache/domlogs/domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ." CustomLog /usr/local/apache/domlogs/domain.com combined ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/ #Options -ExecCGI -Includes #RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
它将需要与运行Web服务器的用户相同的权限。 这将取决于您的操作系统。 它可能是“apache”或“www-data”或其他东西。
除非您使用的是suEXEC ,否则该脚本将由networking服务器执行,并且以与该用户相同的权限运行。
所以,要解决这个问题,你需要确定Apache进程正在运行的是哪个用户,并且对脚本能够修改的文件/文件夹应用适当的权限。
您可以指定用户和组帐户apache运行在您的conf文件使用
User=[username] Group=[groupname]
指令。
看一下你的conf文件,文件的名称和位置也会随OS而变化。 在这里提供一些更具体的内容可能会带来更直接的答案。
编辑:对于CentOS的conf文件位于
/etc/httpd/conf/httpd.conf
UPDATE! 如果您遇到这个问题,请尝试以下操作:
在WHM去:
主页>>服务configuration>> Apacheconfiguration>> PHP和SuExecconfiguration
我更改了PHP 5处理程序:suphp。
工作了一种享受
更改WHM主页>>服务configuration>> Apacheconfiguration>> PHP和SuExecconfigurationphp hadler >> fcgi ,,它将解决问题..