如何使用APPCMD更改IIS7中网站的物理路径?
我需要通过 appcmd.exe 工具通过命令行更改网站的物理路径,但我无法弄清楚语法。有人可以帮忙吗?
I need to change the physical path of a web site through the command line via the appcmd.exe tool, but I can't figure out the syntax. Can someone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该这样做:
C:\Windows\System32\inetsrv>appcmd set vdir "MySite/" -physicalPath:"C:\inetpub\temp"
注意:“MySite/”是一个名称因此,如果您的虚拟目录位于默认网站下,您可能必须设置“默认网站/MySite/”
至于弄清楚如何执行其他 appcmd 命令,只需键入: appcmd set vdir /?
,您将获得有关如何设置虚拟目录的所有信息。
更具体地说,如果您想知道可以为特定虚拟目录类型更改哪些设置:appcmd set vdir "MySite/" /?
这些示例仅适用于虚拟目录,它们适用于其他 appcmd命令
希望这有帮助
This is how you should do:
C:\Windows\System32\inetsrv>appcmd set vdir "MySite/" -physicalPath:"C:\inetpub\temp"
Note: "MySite/" is a name of your virtual directory so if your virtual directory is under default web site you're likely have to set "Default Web Site/MySite/"
As for figuring out how to do other appcmd commands just type: appcmd set vdir /?
and you'll get all the info on what you can do to set your virtual directory.
Even more specifically, if you want to know what settings you can change for the specific virtual directory type:appcmd set vdir "MySite/" /?
These examples are just for virtual directory by they apply to other appcmd commands
Hope this helps
以下内容适用于 IIS 7.5。它会更改网站的物理路径:
键入以下内容以获得可以设置的属性的完整列表:
参考
The following works for me on IIS 7.5. It changes the physical path of the website:
Type the following to get a complete list of properties that you can set:
Reference
上面的答案是正确的。以下是设置默认网站和其他几个虚拟目录的样子。我们希望默认网站位于 D: 上,并为应用程序提供一个特殊的唯一路径名,但其中两个虚拟目录属于 C: 并具有自己的路径:
语法很简单,但要确定 appcmd 所采用的确切字符串对于虚拟目录可能很棘手。
The answer above is correct. Here's what it might look like for setting the default web site and a couple of other virtual directories. We want the default web site to be on D: with a special unique path name for the app, but two of the virtual directories belong back on C: with their own paths:
The syntax is easy, but determining the exact string that appcmd takes for the virtual directory can be tricky.
如果您尝试更改 Web 应用程序的物理路径,以下示例将在网站“默认网站”下创建的 Web 应用程序“Spockadoodle”更改为物理路径“C:_junk”。
我通过运行命令来解决这个问题:
在我观察到的输出中
,在此之前,在命令的输出中
提到的输出:
因此,从引用如何设置“enabledProtocols”的示例中,我替换了 [path='string'].physicalPath 的示例
来了解属性表达式的值[路径='字符串']
我在命令输出中观察
到,Web App Spockadoodle 的路径属性值为“/”:
另外,我想出了使用网站上示例中的 /app.name 标识符 http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmdexe
And in case you are trying to change the physical path of a Web Application, here is an example changing the Web Application "Spockadoodle" that is created under Web Site "Default Web Site" to have the physical path "C:_junk".
I figured this out by running the command:
and in the output I observed
and prior to that, in the output of the command
the output mentioned:
So, from the example citing how to set "enabledProtocols", I substituted the example of [path='string'].physicalPath
To know the value for the attribute expression [path='string']
I observed in the output of the command
output shows that the Web App Spockadoodle has path attribtue value "/":
Also, I figured out to use the /app.name identifier from examples on the website http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmdexe
按站点和应用程序名称获取虚拟目录列表,以帮助确保您尝试设置正确的内容。
可选择通过管道传输
|more
和/或mode con cols=160
这个正则表达式提取了我想要的部分
,所以对于一个特定的网站,它变成了
appcmd.exe set vdir "DefaultWebSite/jms" -physicalPath:"c:\inetpub\wwwroot\mytargetPath"
以下是变量替换:
appcmd.exe set vdir "
+ appName + virt.VirDir +" -physicalPath:"
+ targetPath+"
并查看该站点的配置设置:
需要注意的另一种用法:
To get a list of virtual directories by site and app name to help ensure you are attempting to set the right thing.
optionally pipe that
|more
and/ormode con cols=160
this regex pulled out the parts I wanted
so then for a specific site it becomes
appcmd.exe set vdir "DefaultWebSite/jms" -physicalPath:"c:\inetpub\wwwroot\mytargetPath"
here's the variable substitutions:
appcmd.exe set vdir "
+ appName + virt.VirDir +" -physicalPath:"
+ targetPath+"
and to look at the config settings for just that site:
another usage to be aware of: