Php uses exec to execute shell scripts first: & nbsp; perform web-based operations on Linux, this allows you to perform basic operations on the web end, but now you are writing the code for creating a directory: & nbsp; $ mkdir_command & nbsp; ho php uses exec to execute shell scripts
Let's talk about what I want to do first:
Web-based operations in Linux allow you to perform basic operations on the web end, but now you are writing the code to create a directory:
$ Mkdir_command = "/home/myname/myshell/mkdir. sh/$ directory/$ name ";
Exec ($ mkdir_command, $ output, $ return );
.....
I also know that executing shell scripts on the web end is actually running with Apache permissions in Linux,
However, in Linux. sh has changed its permission to root at runtime. that is to say, any user who calls the file executes chmod 777 mkdir with the root permission. sh; chmod u + s mkdir. sh
However, the execution on the webpage is still unsuccessful.
In Linux alone, the execution is successful,
I hope you can express your comments or comments. thank you !!
------ Solution --------------------
Apache requires write permission on this directory
------ Solution --------------------
1. the web writes the results to a file. for example, you can create a file based on what you want to create.
2. linux root regularly calls shell to check whether there is any file that needs to be updated.
In this case, the root user is used to perform the operation.
Just create a timer.
------ Solution --------------------
You have to check whether you have the execution permission.
System/exec first executes a simple command such as ls and ifconfig to check whether the execution is successful.
Check the permission of the. sh file again.
------ Solution --------------------
In linux, enter do
Then we append the object at the end.
Apache ALL = NOPASSWD:/bin/sh
Then
Execute exec ("/usr/bin/sudo/bin/sh/xxx. sh") in php ")
/Xxx. sh is the script you want to execute
Let's take a look at this article to solve your problem.
Http://blog.csdn.net/vindo/article/details/3610587
------ Solution --------------------
Add sudo