想在网页中利用php执行服务器端写好的脚本,
大致代码就是 exec("/bin/bash /var/www/html/***/run.sh",$ret);脚本run.sh里面会有一些对磁盘读写的操作,然后调用后发现run.sh的确执行了,不过发现貌似对磁盘IO操作的相关代码都没有执行,这是不是apache的权限问题呢?是否有解决办法呢?为了方便说明,在此假设run.sh 内容为:
#!/bin/bash
touch /var/www/html/***/test
echo 'hello world'PS:运行后发现只有hello world 显示出来,前面的test文件没有被touch出来
大致代码就是 exec("/bin/bash /var/www/html/***/run.sh",$ret);脚本run.sh里面会有一些对磁盘读写的操作,然后调用后发现run.sh的确执行了,不过发现貌似对磁盘IO操作的相关代码都没有执行,这是不是apache的权限问题呢?是否有解决办法呢?为了方便说明,在此假设run.sh 内容为:
#!/bin/bash
touch /var/www/html/***/test
echo 'hello world'PS:运行后发现只有hello world 显示出来,前面的test文件没有被touch出来
解决方案 »
- 我想做一个注册用户帐号激活的功能,请教高手
- 留言板中添加非本人写的内容不可修改的功能如何填写
- [PHP基础]类的问题,PARENT调用超类的函数出错了
- 用过mydb这个小包做备分数据库的请进来....
- 怎样不使用表单,直接发送post数据?
- 请问,创建一个表的时候,表名能不能用参数?怎么做?
- MySql升级到4.01后的问题
- 在www.abc.com中的表单Post数据到www.xyz.com/test.php,如何在test.php得到www.abc.com的url
- destoon 新建模块
- PHP SOAP调用WSDL参数设置问题,
- 急。PHP,ADODB 类库,如何连接oracle数据库并查询出数据
- 怎么提取域名中间的部分
返回值
The last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. To get the output of the executed command, be sure to set and use the output parameter. "The last line from the result of the command",是不是返回最后一行shell结果呢?
/etc/passwd 中关于apache的一行为:
apache:x:48:48:Apache:/var/www:/sbin/nologin也就是说 /var/www 就是其主目录啊,应该可以有写的权限吧?
ps aux | grep httpd | grep -v grep 看看httpd的worker进程有效用户是不是apache,看看/var/www目录worker进程有效用户是否可写
你的是什么linux?没记错的话现在基本都没什么用apache这个帐号来跑的
drwxrwxrwx 6 root root 4.0K Jun 21 2011 /var/www
/var/www 的worker进程有效用户是root,并且可写ps aux | grep httpd | grep -v grep 输出如下:
apache 995 0.0 0.0 424928 18900 ? S 13:39 0:00 /usr/sbin/httpd -k start
apache 1355 0.0 0.0 425776 21300 ? S 13:41 0:00 /usr/sbin/httpd -k start
apache 5760 0.0 0.0 425048 19692 ? S 13:49 0:00 /usr/sbin/httpd -k start
admin 6930 0.0 0.0 134088 6728 ? Ssl 11:37 0:00 /****/***/*** -c /***/***/***.conf -g -m httpd
apache 9675 0.0 0.0 426080 18804 ? S 13:57 0:00 /usr/sbin/httpd -k start
root 9691 0.0 0.0 420928 13348 ? Ss 11:39 0:00 /usr/sbin/httpd -k start
apache 9692 0.0 0.0 425312 21512 ? S 11:39 0:01 /usr/sbin/httpd -k start
apache 9693 0.0 0.0 422512 18048 ? S 11:39 0:00 /usr/sbin/httpd -k start
apache 9694 0.0 0.0 424320 19660 ? S 11:39 0:00 /usr/sbin/httpd -k start
apache 9695 0.0 0.0 422856 18884 ? S 11:39 0:00 /usr/sbin/httpd -k start
apache 9696 0.0 0.0 424800 21704 ? S 11:39 0:01 /usr/sbin/httpd -k start
apache 9697 0.0 0.0 425288 20896 ? S 11:39 0:00 /usr/sbin/httpd -k start
apache 9698 0.0 0.0 424816 19692 ? S 11:39 0:01 /usr/sbin/httpd -k start
apache 9699 0.0 0.0 422512 18628 ? S 11:39 0:01 /usr/sbin/httpd -k start
apache 10155 0.0 0.0 424832 19568 ? S 11:41 0:00 /usr/sbin/httpd -k start
apache 10179 0.0 0.0 424372 21220 ? S 11:41 0:01 /usr/sbin/httpd -k start
apache 10180 0.0 0.0 422548 18412 ? S 11:41 0:01 /usr/sbin/httpd -k start
apache 10578 0.0 0.0 425036 19420 ? S 13:57 0:00 /usr/sbin/httpd -k start
apache 13236 0.0 0.0 425036 17768 ? S 14:01 0:00 /usr/sbin/httpd -k start
apache 13241 0.0 0.0 424704 18268 ? S 14:01 0:00 /usr/sbin/httpd -k start
apache 13242 0.0 0.0 424828 19296 ? S 14:01 0:00 /usr/sbin/httpd -k start
apache 14850 0.0 0.0 426544 19200 ? S 14:03 0:00 /usr/sbin/httpd -k start
apache 14869 0.0 0.0 425028 19008 ? S 14:03 0:00 /usr/sbin/httpd -k start
apache 21399 0.0 0.0 424676 19476 ? S 13:14 0:00 /usr/sbin/httpd -k start
apache 21402 0.0 0.0 422264 17848 ? S 13:14 0:00 /usr/sbin/httpd -k start
apache 21403 0.0 0.0 423864 18744 ? S 13:14 0:00 /usr/sbin/httpd -k start
apache 26779 0.0 0.0 424712 16764 ? S 12:17 0:00 /usr/sbin/httpd -k starthttpd的worker进程有效用户大部分是apache,有一个是root另一个是admin,我要怎么修改才可以呢?