Thursday, April 20, 2017

How to clone IIS apppool and all website for another machine using command line

If you are working in IIS server. you have many websites listed under INSUPLTDVSG.
Suddenly you want same site setting on another laptop.

What you we do...
manual work.... no no...no...

Let me give you a quick solution.


Follow these step.

Step 1.  (Perform on the main machine)

1st you have to take backup of all settings such as apppool and websites.

Open Command Prompt and run this command

%windir%\system32\inetsrv\appcmd list apppool /config /xml > d:\apppools.xml
%windir%\system32\inetsrv\appcmd list site /config /xml > d:\websites.xml

---------------------------------
In D:/ drive, you will get two file. catch this file and sent it to another machine.


Step 2 ( (Perform on the another machine)

Now it's time to import all data so run this command

%windir%\system32\inetsrv\appcmd add apppool /in < d:\apppools.xml
%windir%\system32\inetsrv\appcmd add site /in < d:\websites.xml

----------------------------

Now if your site https:// then you have to make self-sign-certificate. you have to make a certificate,.. once done then bind it with your site.

So, How will do that.

Let's run this command

appcmd set site /site.name:"myapp.com" /+bindings.[protocol='https',bindingInformation='*:443:myapp.com']

run this command as many time as your have sites.

-----------------------------------------------------------------

I am hoping that this article will help you. However, if you got stuck and need additional help, please write a comment below.


How to send ANSI corrector in mail subject using mail function in PHP

Let's say your subject is - "Cómo estás" (that mean - cómo estás )
if you will send this subject then it will not show properly in an email.

So how to solve this issue-:

$subject = "cómo estás";
mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $body, $headers);

------------
if this code doesn't work for you then le tme know. I Have another solution too. :-)