1

我已经有这个问题大约一个星期了。但是,似乎只有在此服务器上才会出现所有这些错误。我尝试使用不同的分区多次重新安装操作系统,并且发生了完全相同的事情。现在,我不知道为什么会这样。

问题是,由于某种原因,当运行命令lsPHP 时,会返回很多关于文件/目录权限和所有者的问号。例如,当运行命令时,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)之类的命令时,这变得更加成问题。Screen 需要使用位于 的目录/var/run/screen。不幸的是,每次从 PHP 运行 screen 时,它都会返回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 服务器用户。

尽管这是一个修复程序,但这并不总是意味着一切都会正常工作。如果我随后尝试java在屏幕内启动 JVM(命令),则会返回此错误:

Error occurred during initialization of VM
Could not reserve enough space for code cache

在这一点上,我只是屈服了,因为我不知道发生了什么。

任何人都可以了解我的情况并尝试解释发生了什么或为我提供解决方案。

发生这种情况的机器是运行 CentoOS 6.4 的专用服务器,具有 16GB 的 RAM、500gb 的 HDD 和 Intel(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 /`;
?>
4

1 回答 1

0

这个问题与SELinux. 禁用它解决了这个问题。这是因为该进程正在尝试执行子进程。

于 2015-03-20T18:18:03.487 回答