Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java PHP返回ls命令的问号_Java_Php_Linux_Apache_Permissions - Fatal编程技术网

Java PHP返回ls命令的问号

Java PHP返回ls命令的问号,java,php,linux,apache,permissions,Java,Php,Linux,Apache,Permissions,我已经有这个问题大约一个星期了。然而,似乎只有在这台服务器上我才能得到所有这些错误。我曾多次尝试用不同的分区重新安装操作系统,但都发生了完全相同的事情。现在,我不知道为什么会这样 问题是,出于某种原因,当运行命令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 Oc

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

问题是,出于某种原因,当运行命令
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
Error occurred during initialization of VM
Could not reserve enough space for code cache
可以理解,目录
/root
/lost+found
返回问号,因为它们的权限不允许所有用户(如drwx------)读取和执行。但是,目录
/boot
也会返回问号,尽管它允许所有用户读取和执行(
dr-xr-xr-x.

当我运行诸如
screen
(GNU-screen)之类的命令时,问题就更大了。Screen需要使用位于
/var/run/Screen
的目录。不幸的是,每次从PHP运行screen时,它都会返回说
无法生成目录'/var/run/screen':文件存在
。当通过SSH运行screen时,它会按预期工作

通过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
在用户根目录下通过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
来重新创建它。更改目录的权限没有任何作用,从根用户重新创建目录并使所有者成为web服务器用户也没有任何作用

尽管这是一个解决方案,但并不总是意味着一切都会顺利进行。如果然后尝试在屏幕内启动JVM(命令
java
),则返回此错误:

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
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 /`;
?>


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

用于调用
ls
的PHP代码在哪里?您的PHP用户是什么?是否与您通过SSH登录并执行命令相同?也许
sudo
(如果在CentOS下可用)可以帮助您获得正确的权限(您只需要提升该脚本的权限)?@Fleshgrinder PHP用户是
apache
。我使用用户
root
登录到SSH。使用命令
su-s/bin/bash apache
将sudo输入到用户
apache
,然后运行代码返回的结果与从用户
root
运行命令返回的结果相同。Akward,我无法在基于Debian的服务器上重现这一点,我想我需要从这里得到很多帮助。