


linux - php 文件只需要有 读(r)权限就可以执行文件 是 php自己特殊的地方 还是 c java 文件也是这样
只有读权限 可以正常执行文件 (是boolean用户在做这个读文件的操作吗?)
只有执行权限 提示拒绝 (是因为php本身就不是一个执行文件吗? 还是因为是解释型语言??)
同时有 读 执行 权限 报错
回复内容:
只有读权限 可以正常执行文件 (是boolean用户在做这个读文件的操作吗?)
只有执行权限 提示拒绝 (是因为php本身就不是一个执行文件吗? 还是因为是解释型语言??)
同时有 读 执行 权限 报错
操作系统对文件权限的管理,其复杂程度上远远超出我们的想象。经典的三位数字权限,根本就不是判断权限的可靠理由。举例:
ACL权限系统可以影响影响
mount
命令的noexec
等选项,可以干扰整个挂载点的权限操作系统的权限机制,未来可能存在增补和扩充(这个其实才是最要命的)
我把话说得极端一点:“文件带不带RWX”就是方便给人看的,根本就构不成“是否有读/写/执行权限”的条件。
事实上对于用户程序来说,一个文件能否读/写/执行,根本就不能提前判定。我们编程时唯一的办法就是“试一试”——不做任何提前判断,直接把操作执行出去,出错了再说。
而此时如果判执行权限,那就非常危险了:php解释器尝试执行,如果成功了,那么执行此文件的行为就必然会发生,不可避免。这就意味着php解释器可以执行任何有执行权的文件,哪怕不是php代码也没关系。
这样在系统被黑,存在未知文件植入的情况下,我们就将失去php解释器的最后一层保护,黑客可以通过php解释器,任意执行任何语言编写的一切恶意程序。其后果将是毁灭性的。
所以“调用php命令来执行脚本时只需读取权限”,这个是当然的,也是必须的。
简而言之:任何语言的解释器,都只要求操作系统尝试读取代码文件,得到代码文本。解释器在得到代码文本之后,会自行负责后续的工作,无需操作系统染指。解释器和代码的关系,犹如编辑器和文稿文件的关系。解释器绝对不会委托操作系统去执行任意文件。
java也是这样的。一切解释型语言的解释器都是这样的,没有任何例外——过去没有,现在也没有,将来更不可能有。
问题出在你的执行方式上:
<code>#使用php的文件读取test.php文件内容执行; $ php -f test.php $ which php /usr/bin/php ./test.php #直接执行test.php文件</code>
两次进程主体并不一致
;
shell执行一个解释型语言的脚本时, 会首先在文件头寻找shebang行, 按照shebang指定的解释器处理文件内容
, 如果没有这一行则默认采用bash解释脚本;
<code>$cat x.php #!/usr/bin/php $./x.php #凡是具有x文件都可以这样直接调用, 并且按照shebang的解释器处理内容; hello #如果没有shebang的情况下, 则必须使用解释器(php)显式进行调用 $ php -f x.php # 有无shebang均无所谓, 只是把x.php文件内容读取出来传递给php解释器; 所以文件必须有r权限; hello $ </code>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status
