- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我已经遇到这个问题大约一个星期了。但是,似乎只有在这台服务器上我才会收到所有这些错误。我已经尝试使用不同的分区多次重新安装操作系统,并且发生了完全相同的事情。现在,我不知道为什么会这样。
问题是,出于某种原因,当运行命令 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) 之类的命令时,这会变得更成问题。 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/运行
。更改目录的权限没有任何作用,从 root 用户重新创建目录并使所有者成为 Web 服务器用户也是如此。
尽管这是一个修复,但并不总是意味着一切都会正常工作。如果我随后尝试在屏幕内启动 JVM(命令 java
),则会返回此错误:
Error occurred during initialization of VM
Could not reserve enough space for code cache
在这一点上,我只是屈服了,因为我不知道发生了什么。
任何人都可以阐明我的情况并尝试解释发生了什么或为我提供解决方案。
发生这种情况的机器是一台运行 CentoOS 6.4 的专用服务器,配备 16GB 内存、500GB 硬盘和 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
有关。 禁用它解决了问题。这是因为进程正在尝试执行子进程。
关于java - PHP 为 ls 命令返回问号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19370790/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!