这能办到吗?
基本上,我使用xampp处理多个项目,我喜欢http://localhost作为项目根(而不是http://localhost/project_name/ )。
问题是,我必须在apache文件夹中打开httpd.conf文件,更改文档根,然后重新启动apache!
我想知道这件事能不能在多斯莱斯小姐身上完成?
假设我编写了一个批处理文件,该文件:
opens the file,
finds the document root,
changes it,
stop apache,
start apache然后,我需要做的就是打开cmd提示符,然后写:
http_change.bat new_project_name
问题是,我只知道基本的ms- to和例子以及网上的学费都令人吃惊,难以理解!
编辑
我真的很纠结,所以我提供赏金。
到目前为止,我已经尝试过:
for /f "eol=# tokens=* delims=*" %%a in (httpd.conf) do echo %%a它成功地读取了文件,但是我尝试了
for /f "eol=# tokens=* delims=*" %%a in (httpd.conf) do (
echo %%a
)这起作用了。然后
for /f "eol=# tokens=* delims=*" %%a in (httpd.conf) do (
set line=%%a
echo %line%
)但失败了..。它只是回响“回声关闭”。这让我假设它没有设置行变量..。
我的计划是检查每一行,看看前12个字符是否为== "DocumentRoot“,如果有,我将行保存到一个新文件中,而不是将行保存到一个新文件中。
发布于 2012-03-30 13:33:43
通过编辑配置文件,您会给自己带来不必要的痛苦。这里有一个更好的主意:
httpd.conf文件中删除DocumentRoot设置。将其替换为Include指令,如下所示:包含\path\to\documentroot.conf
documentroot.conf文件的文件,该文件包含表单的一行:DocumentRoot \path\to\my\documentroot
这里还有另一个想法:
您可以使用-C指令(或-c )在命令行上传递Apache选项,这取决于您希望在Apache读取其配置文件之前(-C)还是(-c)之前应用您的指令。与前面的想法一样,从您的DocumentRoot中删除httpd.conf指令,然后在重新启动httpd时,按如下方式启动它:
httpd -C 'DocumentRoot \path\to\my\documentroot'发布于 2014-08-29 07:18:14
我不能告诉你如何:
1. find the directory with batch, or, 2. start/stop apache
但我可以告诉你怎么编辑。
如果您使用XP或之前,请使用
edit <drive:\path\file.ext>,
如果您使用64位,或者Vista或更高版本,请使用
copy con <drive:\path\file.ext>
因为16位edit应用程序已经从64位版本的Windows中删除了.
https://stackoverflow.com/questions/9906189
复制相似问题