我似乎無法在 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
目錄的擁有者是“user [505]”,群組是“user[508]”(如 WinSCP 所示)
我可以做什麼來將 Apache 處理程序更改為正確的所有者和群組以允許我的 PHP 腳本運行?
聚苯乙烯
我的 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
答案1
它將需要與運行網頁伺服器的使用者相同的權限。這將根據您的作業系統而有所不同。它可能是“apache”或“www-data”或完全是其他東西。
除非你正在使用蘇執行,該腳本由網頁伺服器執行,因此以與該使用者相同的權限運行。
因此,要解決此問題,您需要確定 apache 進程在哪個使用者下運行,並對您希望腳本能夠修改的檔案/資料夾套用適當的權限。
您可以使用以下命令在conf檔案中指定apache運行的使用者和群組帳戶
User=[username]
Group=[groupname]
指令。
查看您的conf 文件,該文件的名稱和位置將根據作業系統的不同而有所不同。在這裡提供更多細節可能有助於獲得更直接的答案。
編輯:對於 Centos,conf 檔案位於
/etc/httpd/conf/httpd.conf
答案2
更新!如果您也遇到此問題,請嘗試以下操作:
在 WHM 中,轉到:
主要>>服務配置>>Apache配置>>PHP和SuExec配置
我變了 PHP 5 處理程序至:suphp。
工作了一場款待
答案3
更改WHM Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration php hadler >> fcgi,,它將解決問題..