PHP执行Windows配置IIS [英] PHP exec on a Windows with IIS configuration

查看:220
本文介绍了PHP执行Windows配置IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我读了大约10个答案,每个人似乎都建议出于某种原因无效的想法。

so I have read about 10 answers and everyone seems to suggest ideas which for some reason don't work.

我正在尝试执行一个简单的命令行是svn更新,但它不工作,它返回NULL

i am trying to execute a simple command line which is "svn update" but it is not working and it returns NULL

所以我尝试了试验和错误的方式,现在这就是我能说的;

so i have tried trial and error the way and for now this is what i can say;

我尝试了几个命令,如

<?php
exec ("cmd /c ping 127.0.0.1 -n 1 > results.txt ");
?>

<?php
exec ("cmd /c chdir > results.txt ");
?>

并且都工作.. infact chdir说存储执行该行的php文件的确切位置电脑..

and both work.. infact chdir says the exact position where the php file executing the line is stored on the pc..

所以现在的问题是,为什么这样的命令如下:

so the problem now is, why do some commands like this:

<?php
exec ("cmd /c dir > results.txt ");
?>

不起作用?这个结果和空值即使在文件夹中我有几个文件和目录。

don't work? this results and empty value even though inside the folder i have several files and directories.

以及为什么我使用命令提示符移动到php文件所在的文件夹存储和输入svn更新它的工作原理和操作

and why if i use the command prompt to move into the folder where the php file is store and type svn update it works and doing

<?php
exec ("cmd /c svn update > results.txt ");
?>

返回NULL?

任何帮助非常感谢。

感觉我对配置设置有一些限制,因为当我在本地使用apache尝试时,我可以让大部分命令工作(shell_exec ,系统,执行,甚至没有cmd / c)

it feels like i have some restrictions dued to the configuration setup because when i try in local using apache i can get most of the commands to work (shell_exec, system, exec, even without the cmd /c)

推荐答案

好的。

我设法解决了这个问题..

i have managed to solve the issue..

这就是我所做的:

确切地检查特定网站正在运行的用户名..这样做:

first check exactly what username is running for the specific website.. to do so do:

<?php 
$out = array();
exec('cmd /c whoami 2>&1',$out,$exitcode);
echo "<br />EXEC: ( exitcode : $exitcode )";
echo "<hr /><pre>";
print_r($out);
echo "</pre>";
?>

这将返回计算机名后跟用户名..

this will return the computername followed by the username..

现在在运行网络服务器的计算机上运行

now on the computer running the webserver run

control userpasswords2

并授予管理员权限以用户名whoami表示

and give administrator powers to the username whoami said

这将允许您最终运行任何命令你想要使用exec或system_exec

this will allow you to finally run any command you want using exec or system_exec

另一方面继续我的SVN命令我发现我有另一个问题这就是当你运行它时,它会查找管理员帐户下的配置文件,并会发出错误信息:

on the other hand continuing with my SVN command i found out that I had another problem which is that when you run it, it will look for the config file which is under the administrator account and will give an error saying:

svn: E125001: Can't determine the user's config path

解决此问题你只需拥有通过这样做在命令中指定config_dir:

to solve this issue you simply have to specify in the command the config_dir by doing this:

exec('cmd /c svn update --config-dir C:\Users\Administrator\AppData\Roaming\Subversion C:\\inetpub\\vhosts\\websitename\\httpdocs\\folder 2>&1',$out,$exitcode);

希望这可以帮助那些遇到问题的人!

hope this helps others which are having problems like the ones i had!

这篇关于PHP执行Windows配置IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆