如何使用APPCMD更改IIS7中网站的物理路径?

发布于 2024-08-08 15:45:55 字数 59 浏览 2 评论 0原文

我需要通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

提笔落墨 2024-08-15 15:45:55

您应该这样做:

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

归属感 2024-08-15 15:45:55

以下内容适用于 IIS 7.5。它会更改网站的物理路径:

appcmd set site /site.name:"website name" /application[path='/'].virtualDirectory[path='/'].physicalPath:"C:\new\path"

键入以下内容以获得可以设置的属性的完整列表:

appcmd set site /site.name:"website name" /?

参考

The following works for me on IIS 7.5. It changes the physical path of the website:

appcmd set site /site.name:"website name" /application[path='/'].virtualDirectory[path='/'].physicalPath:"C:\new\path"

Type the following to get a complete list of properties that you can set:

appcmd set site /site.name:"website name" /?

Reference

瑾兮 2024-08-15 15:45:55

上面的答案是正确的。以下是设置默认网站和其他几个虚拟目录的样子。我们希望默认网站位于 D: 上,并为应用程序提供一个特殊的唯一路径名,但其中两个虚拟目录属于 C: 并具有自己的路径:

C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/" -physicalPath:"D:\MyUniquePath"
C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/OtherWebSite" -physicalPath:"C:\OtherWeb\ApplicationServer\web"
C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/ExtraPlugins" -physicalPath:"C:\OtherWeb\ApplicationServer\plugins"

语法很简单,但要确定 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:

C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/" -physicalPath:"D:\MyUniquePath"
C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/OtherWebSite" -physicalPath:"C:\OtherWeb\ApplicationServer\web"
C:\windows\system32\inetsrv\appcmd.exe set vdir "Default Web Site/ExtraPlugins" -physicalPath:"C:\OtherWeb\ApplicationServer\plugins"

The syntax is easy, but determining the exact string that appcmd takes for the virtual directory can be tricky.

岁月流歌 2024-08-15 15:45:55

如果您尝试更改 Web 应用程序的物理路径,以下示例将在网站“默认网站”下创建的 Web 应用程序“Spockadoodle”更改为物理路径“C:_junk”。

appcmd set app /app.name:"Default Web Site/spockadoodle"  -[path='/'].physicalPath:c:\_junk

我通过运行命令来解决这个问题:

appcmd set app /app.name:"Default Web Site/spockadoodle"  /?

在我观察到的输出中

ERROR (message:-path
-applicationPool
-enabledProtocols
...
-[path='string'].physicalPath

,在此之前,在命令的输出中

appcmd set apps /?

提到的输出:

示例:appcmd set app "Default Web Site/" /enabledProtocols:http

设置应用程序“Default Web”的“enabledProtocols”属性
地点/”。

因此,从引用如何设置“enabledProtocols”的示例中,我替换了 [path='string'].physicalPath 的示例

来了解属性表达式的值[路径='字符串']
我在命令输出中观察

appcmd list app "Default Web Site/spockadoodle" /config

到,Web App Spockadoodle 的路径属性值为“/”:

<应用程序路径=“/spockadoodle”applicationPool=“IRServices”>

<虚拟目录默认值/>

另外,我想出了使用网站上示例中的 /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".

appcmd set app /app.name:"Default Web Site/spockadoodle"  -[path='/'].physicalPath:c:\_junk

I figured this out by running the command:

appcmd set app /app.name:"Default Web Site/spockadoodle"  /?

and in the output I observed

ERROR (message:-path
-applicationPool
-enabledProtocols
...
-[path='string'].physicalPath

and prior to that, in the output of the command

appcmd set apps /?

the output mentioned:

Example: appcmd set app "Default Web Site/" /enabledProtocols:http

Sets the "enabledProtocols" property of the application "Default Web
Site/".

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

appcmd list app "Default Web Site/spockadoodle" /config

output shows that the Web App Spockadoodle has path attribtue value "/":

<application path="/spockadoodle" applicationPool="IRServices">

<virtualDirectoryDefaults />

<virtualDirectory path="/" physicalPath="c:_junk" />

</application>

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

無處可尋 2024-08-15 15:45:55

按站点和应用程序名称获取虚拟目录列表,以帮助确保您尝试设置正确的内容。

C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml

可选择通过管道传输 |more 和/或 mode con cols=160
这个正则表达式提取了我想要的部分

var q= from siteApp in config.XPathSelectElements("appcmd/APP")
        let appName=siteApp.Attribute(XNamespace.None+"APP.NAME").Value
            from app in siteApp.XPathSelectElements("application")
        let appPath=app.Attribute(XNamespace.None+"path").Value
        let pool=app.Attribute(XNamespace.None+"applicationPool").Value
        let vd=app.XPathSelectElements("virtualDirectory[@path]")
        let virtuals=vd.Select (v => new{VirDir=v.Attribute(XNamespace.None+"path").Value,PhysicalPath=v.Attribute(XNamespace.None+"physicalPath").Value})
        let xvirtuals=virtuals.Select (v => new{ VirDir=v.VirDir,
            PhysicalPath=v.PhysicalPath,
            EnvRoot=v.PhysicalPath.ToString().StartsWith("%")})
        select new{AppName=appName,AppPath=appPath, Pool=pool,Virtuals=xvirtuals};

,所以对于一个特定的网站,它变成了
appcmd.exe set vdir "DefaultWebSite/jms" -physicalPath:"c:\inetpub\wwwroot\mytargetPath"

以下是变量替换:

appcmd.exe set vdir " + appName + virt.VirDir + " -physicalPath:" + targetPath+"

并查看该站点的配置设置:

    C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml /path:/jms

需要注意的另一种用法:

    C:\Windows\System32\inetsrv\appcmd.exe list apps /metadata /config:* /xml

To get a list of virtual directories by site and app name to help ensure you are attempting to set the right thing.

C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml

optionally pipe that |more and/or mode con cols=160
this regex pulled out the parts I wanted

var q= from siteApp in config.XPathSelectElements("appcmd/APP")
        let appName=siteApp.Attribute(XNamespace.None+"APP.NAME").Value
            from app in siteApp.XPathSelectElements("application")
        let appPath=app.Attribute(XNamespace.None+"path").Value
        let pool=app.Attribute(XNamespace.None+"applicationPool").Value
        let vd=app.XPathSelectElements("virtualDirectory[@path]")
        let virtuals=vd.Select (v => new{VirDir=v.Attribute(XNamespace.None+"path").Value,PhysicalPath=v.Attribute(XNamespace.None+"physicalPath").Value})
        let xvirtuals=virtuals.Select (v => new{ VirDir=v.VirDir,
            PhysicalPath=v.PhysicalPath,
            EnvRoot=v.PhysicalPath.ToString().StartsWith("%")})
        select new{AppName=appName,AppPath=appPath, Pool=pool,Virtuals=xvirtuals};

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:

    C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml /path:/jms

another usage to be aware of:

    C:\Windows\System32\inetsrv\appcmd.exe list apps /metadata /config:* /xml
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文