using appcmd to set physical path of an IIS10 website - iis

How can I use appcmd in IIS10 to set the physical path of a website?
Something like...
appcmd set site summit /[path='/'].path:c:\newpath
This is the setting I am trying to change...

You could change the site physical path using below command:
appcmd set site /site.name:"site name" /application[path='/'].virtualDirectory[path='/'].physicalPath:"D:\newpath"
Do not forget to run the command prompt as administrator.

Related

IIS 7 - Enable and Remove Kerberos & NTLM authentication

I've read a number of web articles explaining how to enabled Kerberos and NTML authentication. What is the process of removing these settings?
appcmd.exe set config "mysite" -section:system.webServer/security/authentication/windowsAuthentication /-"providers.[value='Negotiate']" /commit:apphost
appcmd.exe set config "mysite" -section:system.webServer/security/authentication/windowsAuthentication /-"providers.[value='NTLM']" /commit:apphost
Thanks!
Note here the -"providers... is to remove the settings, so if the above commands are executed, you would be first removing 'Negotiate' and then 'NTLM'
If you have additional other providers just add commands for the same and you would be able to remove the same.
Note: To add a new setting use +"providers... instead of -"providers... in the command.

How to configure Default Website in IIS 5.1 through command line script?

I need to configure IIS 5.1 default website to change the port number, home directory.
Is there any way to configure it without using IIS manager.
Can we do it in command line scripts or can we programmatically achieve it?

Symlink created with mklink not working with IIS7.5 -- Windows 7

So while in my IIS root directory (c:\inetpub\wwwroot) I've created a symlink to a network drive using:
mdlink /D truthuniversal "U:\Truth Universal Full Site\public"
The symlink was created just fine, and if I issue the cd truthuniversal command, while in the IIS root dir, I do indeed end up in the "U:\Truth Universal Full Site\public" directory area.
My problem is that when I type:
http://localhost/truthuniversal
in my browser's address bar IIS does not serve the index page which resides in the public directory. Instead, I get the following error:
Server Error in Application "DEFAULT WEB SITE"
Internet Information Services 7.5
Error Summary
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Please advise.
-TU
You need to create a virtual directory mapping to that directory in IIS in order for it to serve up the page. In IIS, right click on "Default Website", then click "Add Virtual Directory". Also, doing this, there is no reason why you even need the symlink. Just map it to the target to begin with.
I agree that virtual directory in IIS may be what you want, but if you want to minimize IIS maintenance, consider this:
Instead of directory symbolic link: mklink /D
try directory junction: mklink /J
This worked for me and the web apps are able to write to the same directory.
mklink /J App_Data d:\shared\App_Data
worked for me on Windows Server 2008 R2.

Windows Azure Ping Site

I am running a site using Windows Azure Cloud. Is there a way I can ping my site every 20 minutes? My site has low traffic and I need to stop the site from starting and stopping the app pool all the time.
You might be able to setup a Cron Job to do a ping, check out Task 'Scheduling with Windows Azure Web Sites using a Cron Job Service' for an example
If you're using a full Cloud Service (a.k.a. Web Role) you can use a startup task to set the app pools to never shut down. This script does that, as well as a few other IIS configuration changes that I found useful.
#ECHO OFF
#REM A file to flag that this script has already run
#REM because if we run it twice, it errors out and prevents the Azure role from starting properly
#REM %~n0 expands to the name of the currently executing file, without the extension
SET FLAGFILE=c:\%~n0-flag.txt
IF EXIST "%FLAGFILE%" (
ECHO %FLAGFILE% exists, exiting startup script
exit /B
) ELSE (
date /t > %FLAGFILE%
)
#REM Enable IIS compression for application/json MIME type
#REM This will fail the second time you run it on a machine (eg, your desktop). So don't do that.
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
#REM Set IIS to automatically start AppPools
%windir%\system32\inetsrv\appcmd.exe set config -section:applicationPools -applicationPoolDefaults.startMode:AlwaysRunning /commit:apphost
#REM Set IIS to not shut down idle AppPools
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00 /commit:apphost
#REM remove IIS response headers
%windir%\system32\inetsrv\appcmd.exe set config /section:httpProtocol /-customHeaders.[name='X-Powered-By']

How to Run PHP on IIS7.5 Express?

I have Win XP SP3 and have installed IIS7.5 Express and want to run PHP on it.
I am able to run simple HTML code on the server, I am able to start and stop the server by running iisservices.exe, but I am not able to run php scripts on it.
If I have the following PHP file:
<? php
echo "hello world";
?>
<html>HI</html>
The output is HI but the PHP script doesn't run.
I have followed the steps described in this article to install PHP:
http://learn.iis.net/page.aspx/724/install-and-configure-php/
But can't proceed from step 10 onwards because IIS Express doesn't have an IIS Management Console MMC snap-in.
How do I configure IIS Express to run PHP?
Assuming you've carried out steps 1 - 9 in the article you linked to and have your PHP files extracted to c:\php then complete the following steps using a cmd.exe command prompt:
Firstly we need to configure IIS Express and setup a handler for PHP
cd "\Program Files\IIS Express"
appcmd set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\php-cgi.exe',arguments='',maxInstances='4',idleTimeout='300',activityTimeout='30',requestTimeout='90',queueLength='1000',instanceMaxRequests='200',protocol='NamedPipe',flushNamedPipe='False',rapidFailsPerMinute='10']" /commit:apphost
appcmd set config -section:system.webServer/handlers /+"[name='PHP-FastCGI',path='*.php',modules='FastCgiModule',verb='*', scriptProcessor='c:\php\php-cgi.exe']" /commit:apphost
Assuming your PHP website resides in c:\MyPHPWeb we create a site in IIS Express that listens on http://localhost:32701:
appcmd add site /name:"MyPHPApp" /bindings:http/*:32701: /physicalPath:"c:\MyPHPWeb"
Next start the site:
iisexpress.exe /site:MyPHPApp
And finally browse to your PHP page:
http://localhost:32701/test.php
Option-1: (From command line)
Go to IIS Express installation folder (%programfiles%\iis express)
Run following two commands
appcmd.exe set config /section:system.webServer/fastCGI /+[fullPath=**'c:{php_installation-folder}\php-cgi.exe'**]
appcmd.exe set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='.php',verb='',modules='FastCgiModule',scriptProcessor='c:{php_installation-folder}\php-cgi.exe',resourceType='Unspecified']
Option-2: (Using UI)
Install WebMatrix (from http://www.microsoft.com/web/webmatrix/)
Start WebMatrix and choose 'Site From Folder' option and select your php file folder and click OK
In the WebMatrix left pan select Settings (bottom of the left pan select 'Site' and on the top of the left pan select 'Settings')
In the settings tab, check the PHP check box, this would install PHP and configure for you.
Click 'Restart' button in WebMatrix to restart IIS Express
In WebMatrix left pan bottom select 'Files' and on the top of the left pan (tree view), you should see your php page and now right click on this page node and select 'Launch in Browser'
Download php installer.
It should let you choose what type of server, so choose IIS and then it should work from there.

Resources