PHP-CLI 无法在来宾虚拟机(Centos 6)内的 Samba Share(使用 cifs)上执行脚本

PHP-CLI 无法在来宾虚拟机(Centos 6)内的 Samba Share(使用 cifs)上执行脚本

我在 Virtualbox 中以客户机身份运行了一台 centos 6 VM。我设置了一个 LAMP 堆栈,可以从主机 (Windows) 环境访问它。

我已经使用“mount -t cifs”安装了 SMB 共享,并且能够使用 apache 从该共享提供文件(到目前为止一切顺利)

问题 我现在正尝试从命令行运行一个简单的 test.php 脚本这是我得到的输出(如下)

注意如果我没有正确拼写文件名(不同的消息)会发生什么,所以文件在那里,就好像 php 无法执行它一样。

我将其作为图像包含进来,因为我找不到从 VM 终端复制的方法。任何帮助都值得感激,我已经花费了比我想象的更多的时间来启动和运行它。

编辑3:当我不尝试从 samba 共享运行文件时,我能够从命令行运行 php,因此它与安装有关。我这样安装了驱动器...

mount -t cifs -o username=xxxx,password=xxxx,nounix,fir_mode=0777,file_mode=0777,gid=48,uid=48 //path/to/samba/share /var/www/vhosts

在此处输入图片描述

编辑1: -bash:十六进制转储测试.php 0000000 6574 7473 6620 6c69 0a65 000000a

编辑2:

strace -o mystraceoutput.txt -f -e trace=文件 php test.php

4423  execve("/usr/bin/php", ["php", "test.php"], [/* 19 vars */]) = 0
4423  access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
4423  open("/etc/ld.so.cache", O_RDONLY) = 3
4423  open("/lib/libcrypt.so.1", O_RDONLY) = 3
4423  open("/usr/lib/libedit.so.0", O_RDONLY) = 3
4423  open("/lib/libncurses.so.5", O_RDONLY) = 3
4423  open("/usr/lib/sse2/libgmp.so.3", O_RDONLY) = 3
4423  open("/lib/libbz2.so.1", O_RDONLY) = 3
4423  open("/lib/libz.so.1", O_RDONLY)  = 3
4423  open("/lib/libpcre.so.0", O_RDONLY) = 3
4423  open("/lib/libm.so.6", O_RDONLY)  = 3
4423  open("/lib/libdl.so.2", O_RDONLY) = 3
4423  open("/lib/libnsl.so.1", O_RDONLY) = 3
4423  open("/usr/lib/libxml2.so.2", O_RDONLY) = 3
4423  open("/lib/libgssapi_krb5.so.2", O_RDONLY) = 3
4423  open("/lib/libkrb5.so.3", O_RDONLY) = 3
4423  open("/lib/libk5crypto.so.3", O_RDONLY) = 3
4423  open("/lib/libcom_err.so.2", O_RDONLY) = 3
4423  open("/usr/lib/libssl.so.10", O_RDONLY) = 3
4423  open("/usr/lib/libcrypto.so.10", O_RDONLY) = 3
4423  open("/lib/libc.so.6", O_RDONLY)  = 3
4423  open("/lib/libresolv.so.2", O_RDONLY) = 3
4423  open("/lib/libfreebl3.so", O_RDONLY) = 3
4423  open("/lib/libtinfo.so.5", O_RDONLY) = 3
4423  open("/lib/libkrb5support.so.0", O_RDONLY) = 3
4423  open("/lib/libkeyutils.so.1", O_RDONLY) = 3
4423  open("/lib/libpthread.so.0", O_RDONLY) = 3
4423  open("/lib/libselinux.so.1", O_RDONLY) = 3
4423  statfs64("/selinux", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=2711275, f_bfree=2380713, f_bavail=2242985, f_files=689520, f_ffree=642048, f_fsid={-1727257207, 1632688387}, f_namelen=255, f_frsize=4096}) = 0
4423  open("/proc/filesystems", O_RDONLY|O_LARGEFILE) = 3
4423  getcwd("/var/www/vhosts/vhosts/user/mysite.co.uk/web", 4096) = 45
4423  open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
4423  open("/etc/localtime", O_RDONLY)  = 3
4423  lstat64("/usr/local/sbin/php", 0xbfe43dec) = -1 ENOENT (No such file or directory)
4423  lstat64("/usr/local/bin/php", 0xbfe43dec) = -1 ENOENT (No such file or directory)
4423  lstat64("/sbin/php", 0xbfe43dec)  = -1 ENOENT (No such file or directory)
4423  lstat64("/bin/php", 0xbfe43dec)   = -1 ENOENT (No such file or directory)
4423  lstat64("/usr/sbin/php", 0xbfe43dec) = -1 ENOENT (No such file or directory)
4423  lstat64("/usr/bin/php", {st_mode=S_IFREG|0755, st_size=3281860, ...}) = 0
4423  lstat64("/usr/bin", {st_mode=S_IFDIR|0555, st_size=20480, ...}) = 0
4423  lstat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
4423  access("/usr/bin/php", X_OK)      = 0
4423  open("/usr/bin/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
4423  open("/etc/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
4423  open("/usr/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
4423  open("/etc/php.ini", O_RDONLY)    = 3
4423  lstat64("/etc/php.ini", {st_mode=S_IFREG|0644, st_size=69109, ...}) = 0
4423  lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
4423  open("/etc/php.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
4423  stat64("/etc/php.d/curl.ini", {st_mode=S_IFREG|0644, st_size=49, ...}) = 0
4423  open("/etc/php.d/curl.ini", O_RDONLY) = 3
4423  stat64("/etc/php.d/fileinfo.ini", {st_mode=S_IFREG|0644, st_size=57, ...}) = 0
4423  open("/etc/php.d/fileinfo.ini", O_RDONLY) = 3
4423  stat64("/etc/php.d/json.ini", {st_mode=S_IFREG|0644, st_size=49, ...}) = 0
4423  open("/etc/php.d/json.ini", O_RDONLY) = 3
4423  stat64("/etc/php.d/phar.ini", {st_mode=S_IFREG|0644, st_size=49, ...}) = 0
4423  open("/etc/php.d/phar.ini", O_RDONLY) = 3
4423  stat64("/etc/php.d/zip.ini", {st_mode=S_IFREG|0644, st_size=47, ...}) = 0
4423  open("/etc/php.d/zip.ini", O_RDONLY) = 3
4423  open("/usr/lib/php/modules/curl.so", O_RDONLY) = 3
4423  open("/etc/ld.so.cache", O_RDONLY) = 3
4423  open("/usr/lib/libcurl.so.4", O_RDONLY) = 3
4423  open("/lib/libidn.so.11", O_RDONLY) = 3
4423  open("/usr/lib/libldap-2.4.so.2", O_RDONLY) = 3
4423  open("/lib/librt.so.1", O_RDONLY) = 3
4423  open("/usr/lib/libssl3.so", O_RDONLY) = 3
4423  open("/usr/lib/libsmime3.so", O_RDONLY) = 3
4423  open("/usr/lib/libnss3.so", O_RDONLY) = 3
4423  open("/usr/lib/libnssutil3.so", O_RDONLY) = 3
4423  open("/lib/libplds4.so", O_RDONLY) = 3
4423  open("/lib/libplc4.so", O_RDONLY) = 3
4423  open("/lib/libnspr4.so", O_RDONLY) = 3
4423  open("/usr/lib/libssh2.so.1", O_RDONLY) = 3
4423  open("/usr/lib/liblber-2.4.so.2", O_RDONLY) = 3
4423  open("/usr/lib/libsasl2.so.2", O_RDONLY) = 3
4423  open("/usr/lib/php/modules/fileinfo.so", O_RDONLY) = 3
4423  open("/usr/lib/php/modules/json.so", O_RDONLY) = 3
4423  open("/usr/lib/php/modules/phar.so", O_RDONLY) = 3
4423  open("/usr/lib/php/modules/zip.so", O_RDONLY) = 3
4423  open("/proc/sys/crypto/fips_enabled", O_RDONLY) = 3
4423  stat64("/root/.terminfo", 0xbfe454b0) = -1 ENOENT (No such file or directory)
4423  stat64("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
4423  access("/etc/terminfo/l/linux", R_OK) = -1 ENOENT (No such file or directory)
4423  stat64("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
4423  access("/usr/share/terminfo/l/linux", R_OK) = 0
4423  open("/usr/share/terminfo/l/linux", O_RDONLY|O_LARGEFILE) = 3
4423  open("/root/.editrc", O_RDONLY)   = -1 ENOENT (No such file or directory)
4423  open("/etc/nsswitch.conf", O_RDONLY) = 3
4423  open("/etc/ld.so.cache", O_RDONLY) = 3
4423  open("/lib/libnss_files.so.2", O_RDONLY) = 3
4423  open("/etc/protocols", O_RDONLY|O_CLOEXEC) = 3
4423  open("/etc/protocols", O_RDONLY|O_CLOEXEC) = 3
4423  open("test.php", O_RDONLY)        = 3
4423  getcwd("/var/www/vhosts/vhosts/user/mysite.co.uk/web", 4096) = 45
4423  lstat64("/var/www/vhosts/vhosts/user/mysite.co.uk/web/test.php", {st_mode=S_IFREG|0777, st_size=10, ...}) = 0
4423  lstat64("/var/www/vhosts/vhosts/user/mysite.co.uk/web", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
4423  lstat64("/var/www/vhosts/vhosts/user/mysite.co.uk", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
4423  lstat64("/var/www/vhosts/vhosts/user", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
4423  lstat64("/var/www/vhosts/vhosts", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
4423  lstat64("/var/www/vhosts", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
4423  lstat64("/var/www", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
4423  lstat64("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0

然后执行被与之前相同的错误中断(PHP 致命错误:等等......)

答案1

通过在挂载参数中添加“noserverino”来解决

答案2

你确定 test.php 确实包括test.php?这可能会导致严重的后果。

答案3

如果你能跑相同当从 CLI 将 PHP 文件复制到本地文件存储时,我认为这可能是 SELinux 安全问题。

尝试在消息中查找 SELinux 通知或暂时禁用它。我们遇到过很多问题(直到我们弄清楚),即使在本地文件系统上,SELinux 阻止访问文件。

相关内容