我在用浏览器访问服务器上的php文件,然后用exec()删除某目录文件,提示权限不够,经过一顿搜索之后,我已根据很多文章的描述进行下面的权限设置,请问还有什么漏了设置的地方导致权限还是不够?
代码test.php:
$a = exec("rm /var/test/test.txt 2>&1",$result,$status);
print_r($result);
关于权限的服务器设置:
1、apache的httpd.conf中的user和group现在是apache。
2、利用visudo给了apache和root一样的权限,并把Defaults requiretty注释了。
3、将/var/test文件夹的权限给足,用户和用户组设为apache
4、test.txt的权限和用户、用户组也设置了
访问192.168.1.xxx/test.php还是不能删掉,还是提示这个:
回复内容:
我在用浏览器访问服务器上的php文件,然后用exec()删除某目录文件,提示权限不够,经过一顿搜索之后,我已根据很多文章的描述进行下面的权限设置,请问还有什么漏了设置的地方导致权限还是不够?
代码test.php:
$a = exec("rm /var/test/test.txt 2>&1",$result,$status);
print_r($result);
关于权限的服务器设置:
1、apache的httpd.conf中的user和group现在是apache。
2、利用visudo给了apache和root一样的权限,并把Defaults requiretty注释了。
3、将/var/test文件夹的权限给足,用户和用户组设为apache
4、test.txt的权限和用户、用户组也设置了
访问192.168.1.xxx/test.php还是不能删掉,还是提示这个:
通过
<code><?php echo shell_exec('whoami'); </code></code>
你就可以知道为何你没有权限删除了啊
另外, 在PHP中直接创建一个文件, 看看他是什么权限,也能看到你的php的执行用户和用户组
根据上面的权限配置,应该是能删除的呀。
LZ要不试试重启下apache服务器,然后再执行代码。
注意到php.ini里提供有一个open_basedir配置,也就是只有在open_basedir里的目录,PHP才能进行操作,所以如果你开启了open_basedir限制,那你就应该把/var/test这个目录加到open_basedir里,重启Apache:
<code>open_basedir="/tmp/:/var/www/html/:/var/test/" </code>
Linux上目录用冒号(:)分隔,Windows上用分号(;)分隔.
很奇怪,你把apache加入了visudo里,为什么sudo -u apache 还是不能删除文件?也就是说sudo并没有成功赋给apache这个用户了

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software