在Windows 2012 上的 IIS 8.5 + PHP 环境中设置 SMTP 服务

当前项目是架设在 IIS 8.5 + PHP 5.4环境下的。需要有发送邮件的功能,最常见的方式就是使用 PHP 的 Mail 函数,但是默认情况下,此函数在 IIS 中调用是失败的,需要做如下配置:

  1. 在服务器上『添加角色和功能』中的功能界面找到『 SMTP 服务器』并添加,它需要IIS6控制台,所以安装完成后需要使用IIS6管理界面进入管理
  2. 在开启 SMTP 服务器中中继功能:方法是进入 IIS 6 管理器,在SMTP Virtual server上点右键,选择属性,再选择访问选项卡,点『中继限制』中的『中继』按钮,选择『以下列表除外』(也可以保持『仅一下列表』,此时需要在下表中添加127.0.0.1)
  3. 设置SMTP服务为自动启动,进入系统服务,着大哦『简单邮件传输协议(SMTP)』,设置该服务启动模式为自动即可

 

 

 

直接使用Git部署网站到IIS上

Git可以直接部署网站到服务器上,想必已经是人尽皆知的事情了。主要是用到了Git hook技术,不过网上的资料大多都是Linux下的操作,仅有的Windows平台的文章也讲的是将Git Server安装到服务器上。其实当你用过了Azure的“网站”功能后就会觉得直接将Git中的文件部署到IIS上是多么爽的一件事,不过并不是所有的网站都可以部署到Azure的“网站”上。 下面就介绍一个来自Azure的开源项目,有了它你也可以实现直接通过Git发布你的项目了。 首先,项目的地址是 https://github.com/projectkudu/kudu 有几个坑需要注意:

  1. kudu只能用Visual Studio直接运行,如果放到IIS中运行会提示你不允许
  2. 必须把Git文件的文件夹放到C:\Program Files (x86)下,文件夹名称必须叫Git
  3. 下面官方文档中要求安装的那堆东西最好安上,免得出现稀奇古怪的错误

由于很简单,原文直接粘贴如下:

Deploying: Add Git support to your IIS server

Build n’ start!

Below I’ll assume that you have IIS 7.x installed on your local machine. If you want to go live with Kudu, simply deploy the Kudu.Web project to a site on your production/online IIS as usual.

Now open up the Kudu.sln in Visual Studio. Mark the Kudu.Web project as active (makes it bold) and hit CTRL+F5.

If everything went well you should now see the Kudu dashboard, looking like this:

Kudu Dashboard

Create your first Git enabled site

In your Kudu dashboard:

  • Click the “Create application” link in the top menu.
  • Enter a preferred name for the IIS site (I.e. “jhovgaardnet”).
  • Click the blue “Create application” button.

Kudu is now creating a brand new IIS site directly on your IIS (!!) and showing you some geeky stuff:

Kudu website created

It tells the URL to the Git remote we can push apps to, the URL to the site itself and the service URL which actually is the Git remote from before.

Let’s take a quick look in IIS to see what happend:

Kudu sites in IIS

So Kudu is creating 2 sites with a kudu_ prefix. The first is the main site, the one hosting your application. The second is the “git remote site”/service site. Both sites is running on the same application pool.

If we go to the application URL we see a default screen:

Kudu IIS default site

Let’s push it!

Alright, let’s assume that you want to push a FunnelWeb blog like mine to the newly created site. First clone your fork of FunnelWeb (or whatever application you like) to your disk. Next open up a git shell (if you’re using Github for Windows, go to the repository, select tools then open a shell here). We now need to add a new remote, using the Git URL we got from Kudu. In my case I typed this:

git remote add kudu http://localhost:63185/jhovgaardnet.git

Git now knows about the repository located on our local IIS, making us able to do a simple push of our master like this:

git push kudu master

Awesome! If you didn’t mess it up, this is what you should see (not necessary the dependency installations of course):

Now updating the application URL shows my fully deployed blog, just as expected. Yes, it’s freaking awesome!

Conclusion

The next thing for you will be to deploy Kudu on your production IIS, setting up sites as Kudu sites, setting correct bindings, etc.

I really think Kudu is swell and I hope to see some interesting forks of Kudu that moves it closer to a continuous integration system with Github hooks, unit testing abilities, etc. TeamCity is cool, but it’s expensive and heavy. We need a slick open source .NET alternative and I hope Kudu is the beginning!

What do you think? Can you see the possibilities? Are you going to use Kudu?

Thanks for reading guys!

  ——————————–另外还有一篇官方的文档———————————–

Manual Setup Instructions

  • Visual Studio 2012. Note that you need to run it as admin. Install/Update to the latest version of NuGet Package Manager (Tools -> Extensions and Updates).
  • IIS >= 7, configured to run ASP.NET 4.0. This can be installed using WebPI.
  • Install Git (http://git-scm.com/downloads) to the default location (we expect it in C:\Program Files (x86)\Git\bin).
  • Install Node. Node is used as part of the build process for sites.

Note: If you manually install IIS, here is what needs to be enabled: Windows Features

Additional prerequisites to run the functional tests

  • Install the XUnit.net runner for VS 2012, which you install from Tools / Extensions & Updates
  • Open your %WINDIR%\System32\inetsrv\config\applicationHost.config and look for<applicationPoolDefaults>. Under <processModel>, make sure you don’t havesetProfileEnvironment="false". If you do, set it to true (or remove the attribute if you are running the latest Windows 8.1).
  • Install the URL rewrite module for IIS.
  • Install IISNode
  • Install TypeScript Plugin (for VS2012)
  • Pretend to have the 32 bit version of Node to fool the version detection logic:
    • Copy your \Program Files\nodejs folder to \Program Files (x86)\nodejs.
    • Under \Program Files (x86)\nodejs, you need to have a folder named 0.8.2, and containing node.exe version 0.8.2. And then same deal for Node 0.10.5. Yes, this is kind of painful, and we need to make it easier!
  • The Web and WebApplications folders need to be present under \Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0. If you don’t have them, you may need to copy them from a machine that has VS 2010 installed. This is needed because some of the test apps target these. TODO: we need to make this easier!
  • Install Mercurial to the default location (we expect it in C:\Program Files (x86)\Mercurial)

Deploying your first application

  1. First clone the repository.
    git clone git://github.com/projectkudu/kudu.git
    
  2. Open Kudu.sln as Administrator and build it.
  3. Set Kudu.Web as the startup project and run!

After running Kudu.Web, you should be able to use the dashboard to manage your application. Below is a walk through on how to create and deploy your first application using git.

Step 1

Create an application. Step 1

Step 2

Give it a name. Step 2

Step 3

Copy the git url and push. Step 3

Step 4

You’re live! Step 4

错误代号为800706ba时的解决方案

当开发的软件在运行时报出类似如下错误时:

检索COM类工厂中的 CLSID 为{00024500-0000-C000-000000000046}} 的组件时失败, 原因是出现以下错误: 800706ba

看到800706ba时首先就要想到是不是系统服务 “DCOM Server Process Launcher” 没启动

进入服务将其启动,十有八九就会好。

本次遇见的问题是老ERP订单系统中导出Excel时发生的。