简体   繁体   English

为什么我的php脚本只在文件权限读写时执行?

[英]Why my php-script executed when file permissions only read and write?

My name lebnik, and information about me: 我的名字是lebnik,以及关于我的信息:

# id lebnik
uid=1000(lebnik) gid=1000(lebnik) groups=1000(lebnik),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)

My web-server Apache run php-scripts from user www-data, check this: 我的Web服务器Apache从用户www-data运行php脚本,请检查:

root@debian /etc/apache2 # grep -R "APACHE_RUN_USER=" .
./envvars:export APACHE_RUN_USER=www-data

Information about user www-data: 有关用户www-data的信息:

# id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)

I create php-script file.php: 我创建php-script file.php:

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);

echo 'script executed';
?>

Next, I check permissions my file.php 接下来,我检查权限我的file.php

# ls -la
total 16
drwxrwxrwx 1 www-data www-data 4096 Oct 18 00:49 .
drwxrwxr-x 1 www-data www-data 4096 Oct 18 00:36 ..
-rw-rw-r-- 1 www-data www-data  225 Oct 18 00:46 file.php

I try call my script with Apache: curl http://starsite.l/file.php and see: 我尝试用Apache调用我的脚本:curl http://starsite.l/file.php并查看:

script executed

Why my php-script executed when file permissions only read and write? 为什么我的php脚本只在文件权限读写时执行?

The execution permission prevents the shell from executing the file, but it doesn't prevent another application from reading the text file and executing it. 执行权限阻止shell执行该文件,但它不会阻止另一个应用程序读取文本文件并执行它。 the php engine doesn't care about the executable permission bit. php引擎不关心可执行权限位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM