我这个问题已经持续了大约一个星期了。但是,它似乎只是在这台服务器上我得到了所有这些错误。我尝试使用不同的分区多次重新安装操作系统,完全相同的事情发生了。现在,我不知道它为什么会发生。
问题在于,由于某种原因,在运行命令ls
时,PHP会为文件/目录权限和所有者返回大量问号。例如,在运行命令ls -al /
时,这是返回的内容:
total 96
dr-xr-xr-x. 25 root root 4096 Oct 14 12:52 .
dr-xr-xr-x. 25 root root 4096 Oct 14 12:52 ..
-rw-r--r--. 1 root root 0 Oct 14 12:45 .autofsck
dr-xr-xr-x. 2 root root 4096 Oct 14 13:12 bin
d?????????? ? ? ? ? ? boot
drwxr-xr-x. 17 root root 3740 Oct 14 12:46 dev
drwxr-xr-x. 2 root root 4096 Oct 14 12:52 downloads
drwxr-xr-x. 102 root root 12288 Oct 14 13:12 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 home
dr-xr-xr-x. 11 root root 4096 Oct 14 12:41 lib
dr-xr-xr-x. 9 root root 12288 Oct 14 13:11 lib64
d?????????? ? ? ? ? ? lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 2 root root 0 Oct 14 12:46 misc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 mnt
drwxr-xr-x. 2 root root 0 Oct 14 12:46 net
drwxr-xr-x. 3 root root 4096 Oct 14 12:41 opt
dr-xr-xr-x. 225 root root 0 Oct 14 12:45 proc
d?????????? ? ? ? ? ? root
dr-xr-xr-x. 2 root root 12288 Oct 14 13:12 sbin
drwxr-xr-x. 7 root root 0 Oct 14 12:45 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x. 13 root root 0 Oct 14 12:45 sys
drwxrwxrwt. 5 root root 4096 Oct 14 13:11 tmp
drwxr-xr-x. 13 root root 4096 Oct 14 12:37 usr
drwxr-xr-x. 22 root root 4096 Oct 14 12:52 var
可以理解,目录/root
和/lost+found
会返回问号,因为它们的权限不允许所有用户的读取和执行(例如drwx ------。)。但是,目录/boot
也会返回问号,尽管它允许读取并执行所有用户(dr-xr-xr-x.
)。
当我运行诸如screen
(GNU Screen)之类的命令时,这会变得更成问题。屏幕需要使用位于/var/run/screen
的目录。不幸的是,每次从PHP运行屏幕时,都会返回Cannot make directory '/var/run/screen': File exists
。通过SSH运行屏幕时,它按预期工作。
通过PHP运行命令ls -al /var/run
以检查目录的权限时,它返回以下内容:
total 48
drwxr-xr-x. 23 root root 4096 Oct 14 12:52 .
drwxr-xr-x. 22 root root 4096 Oct 14 12:52 ..
d?????????? ? ? ? ? ? ConsoleKit
drwxr-xr-x. 2 root root 4096 Oct 14 12:46 abrt
-rw-r--r--. 1 root root 5 Oct 14 12:46 abrtd.pid
-?????????? ? ? ? ? ? acpid.pid
s?????????? ? ? ? ? ? acpid.socket
-?????????? ? ? ? ? ? atd.pid
-?????????? ? ? ? ? ? auditd.pid
-?????????? ? ? ? ? ? autofs-running
p?????????? ? ? ? ? ? autofs.fifo-misc
p?????????? ? ? ? ? ? autofs.fifo-net
-?????????? ? ? ? ? ? autofs.pid
drwxr-xr-x. 2 root root 4096 Feb 22 2013 certmonger
-?????????? ? ? ? ? ? certmonger.pid
d?????????? ? ? ? ? ? console
-?????????? ? ? ? ? ? console-kit-daemon.pid
-?????????? ? ? ? ? ? cron.reboot
-?????????? ? ? ? ? ? crond.pid
d?????????? ? ? ? ? ? cups
-?????????? ? ? ? ? ? cupsd.pid
drwxr-xr-x. 2 root root 4096 Oct 14 12:46 dbus
drwxr-xr-x. 2 root root 4096 Feb 21 2013 faillock
d?????????? ? ? ? ? ? hald
-?????????? ? ? ? ? ? haldaemon.pid
drwx--x---. 2 root apache 4096 Oct 14 13:04 httpd
d?????????? ? ? ? ? ? lvm
d?????????? ? ? ? ? ? mdadm
-?????????? ? ? ? ? ? messagebus.pid
drwxr-xr-x. 2 mysql mysql 4096 Oct 14 12:52 mysqld
drwxrwxr-x. 2 root root 4096 Feb 22 2013 netreport
d?????????? ? ? ? ? ? plymouth
d?????????? ? ? ? ? ? pm-utils
d?????????? ? ? ? ? ? portreserve
-?????????? ? ? ? ? ? rpc.statd.pid
-?????????? ? ? ? ? ? rpcbind.lock
-?????????? ? ? ? ? ? rpcbind.pid
s?????????? ? ? ? ? ? rpcbind.sock
d?????????? ? ? ? ? ? saslauthd
d?????????? ? ? ? ? ? screen
d?????????? ? ? ? ? ? sepermit
drwxr-xr-x. 2 root root 4096 May 10 05:06 setrans
-?????????? ? ? ? ? ? sm-notify.pid
-?????????? ? ? ? ? ? sshd.pid
-?????????? ? ? ? ? ? syslogd.pid
-?????????? ? ? ? ? ? utmp
drwxr-xr-x. 2 root root 4096 Feb 21 2013 winbindd
在用户root下通过SSH运行相同的命令时,交叉检查所发生的所有目录的权限:
total 164
drwxr-xr-x. 23 root root 4096 Oct 14 12:52 .
drwxr-xr-x. 22 root root 4096 Oct 14 12:52 ..
drwxr-xr-x. 2 root root 4096 Oct 14 12:46 abrt
-rw-r--r--. 1 root root 5 Oct 14 12:46 abrtd.pid
-rw-r--r--. 1 root root 5 Oct 14 12:46 acpid.pid
srw-rw-rw-. 1 root root 0 Oct 14 12:46 acpid.socket
-rw-r--r--. 1 root root 5 Oct 14 12:46 atd.pid
-rw-r-----. 1 root root 5 Oct 14 12:46 auditd.pid
prw-------. 1 root root 0 Oct 14 12:46 autofs.fifo-misc
prw-------. 1 root root 0 Oct 14 12:46 autofs.fifo-net
-rw-r--r--. 1 root root 5 Oct 14 12:46 autofs.pid
----------. 1 root root 5 Oct 14 12:46 autofs-running
drwxr-xr-x. 2 root root 4096 Feb 22 2013 certmonger
-rw-------. 1 root root 5 Oct 14 12:46 certmonger.pid
drwxr-xr-x. 2 root root 4096 Feb 21 2013 console
drwxr-xr-x. 2 root root 4096 Oct 14 12:46 ConsoleKit
-rw-r--r--. 1 root root 5 Oct 14 12:46 console-kit-daemon.pid
-rw-r--r--. 1 root root 5 Oct 14 12:46 crond.pid
----------. 1 root root 0 Oct 14 12:46 cron.reboot
drwxr-xr-x. 3 root lp 4096 Oct 14 12:46 cups
-rw-r--r--. 1 root root 5 Oct 14 12:46 cupsd.pid
drwxr-xr-x. 2 root root 4096 Oct 14 12:46 dbus
drwxr-xr-x. 2 root root 4096 Feb 21 2013 faillock
drwx------. 2 haldaemon haldaemon 4096 Jul 19 2011 hald
-rw-r--r--. 1 root root 5 Oct 14 12:46 haldaemon.pid
drwx--x---. 2 root apache 4096 Oct 14 13:04 httpd
drwx------. 2 root root 4096 Feb 22 2013 lvm
drwx------. 2 root root 4096 Feb 21 2013 mdadm
-rw-r--r--. 1 root root 5 Oct 14 12:46 messagebus.pid
drwxr-xr-x. 2 mysql mysql 4096 Oct 14 12:52 mysqld
drwxrwxr-x. 2 root root 4096 Feb 22 2013 netreport
drwxr-xr-x. 2 root root 4096 Feb 22 2013 plymouth
drwxr-xr-x. 4 root root 4096 Oct 14 12:40 pm-utils
drwxr-xr-x. 2 root root 4096 Oct 14 12:45 portreserve
-r--r--r--. 1 root root 0 Oct 14 12:45 rpcbind.lock
-rw-r--r--. 1 root root 5 Oct 14 12:45 rpcbind.pid
srw-rw-rw-. 1 root root 0 Oct 14 12:45 rpcbind.sock
-rw-r--r--. 1 rpcuser rpcuser 5 Oct 14 12:45 rpc.statd.pid
drwxr-xr-x. 2 root root 4096 Nov 27 2012 saslauthd
drwxrwxr-x. 2 root screen 4096 Jul 19 2011 screen
drwxr-xr-x. 2 root root 4096 Feb 21 2013 sepermit
drwxr-xr-x. 2 root root 4096 May 10 05:06 setrans
-rw-------. 1 root root 5 Oct 14 12:45 sm-notify.pid
-rw-r--r--. 1 root root 5 Oct 14 12:46 sshd.pid
-rw-------. 1 root root 5 Oct 14 12:45 syslogd.pid
-rw-rw-r--. 1 root utmp 3456 Oct 14 12:47 utmp
drwxr-xr-x. 2 root root 4096 Feb 21 2013 winbindd
同样,与/boot
目录一样,该目录似乎尽管具有允许所有用户(drwxrwxr-x.
- chmod 0775)读写的权限,但仍返回权限和所有者的问号
我只是设法找到一个或两个问题,询问屏幕返回的这个错误,其中没有一个被回答。我设法快速解决这个问题,让它工作就是删除/var/run/screen
目录并让PHP通过允许用户写入目录/var/run
来重新创建它。更改目录的权限不会执行任何操作,因此从root用户重新创建目录并使所有者成为Web服务器用户。
即使这是一个修复,它并不总是意味着一切都会正常工作。如果我然后尝试在屏幕内启动JVM(命令java
),则会返回此错误:
Error occurred during initialization of VM
Could not reserve enough space for code cache
此时,我只是放弃了,因为我不知道发生了什么。
任何人都可以对我的情况有所了解并尝试解释发生的事情或为我提供解决方案。
这是一台运行CentoOS 6.4的专用服务器,配备16GB内存,500GB硬盘和英特尔(R)Xeon(R)CPU E3-1230 V2 @ 3.30GHz。使用命令parted
然后print
这是关于分区返回的内容:
Model: ATA WDC WD5003AZEX-0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 466GB 466GB primary ext3 boot
2 466GB 500GB 34.4GB primary linux-swap(v1)
PHP未以安全模式运行。
这是我运行以获取ls
命令等的代码。它每次都从Web服务器运行。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
echo `whoami`;
echo "\n";
echo `ls -al /var/run`;
echo "\n";
echo `ls -al /`;
?>
答案 0 :(得分:0)
此问题与SELinux
有关。 停用它解决了问题。这是因为该过程正在尝试执行子流程。