在windows 2003 64位系统php运行报错:1%不是有效的win32应用程序解决

在windows 2003 64位系统php运行报错:1%不是有效的win32应用程序解决

问题一:php运行报错:1% 不是有效的 win32 应用程序
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

问题二: 网页报错:Service Unavailable
经过上面的操作后,以为大功告成了,其实不然。访问网站竟然又报错:Service Unavailable。
解决方法如下:
1)进入命令提示符:开始->运行 cmd
2)执行脚本:
%SYSTEMROOT%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
说明:%SYSTEMROOT%\表示系统目录,一般是“C:\WINDOWS\”;v1.1.4322是默认.net版本,你也可以改为“v2.0.50727”等其他版本,关键是不要写错路径名,否则执行不成功。

sc 命令的用法

参考 https://jingyan.baidu.com/article/456c463b420f5e0a583144dd.html

简要介绍是:

  1. 设置服务的自启动性质 sc config 服务名 start= auto|demand|disabled
  2. 设置服务启动关闭   sc start|stop 服务名
  3. 删除服务名  sc delete 服务名
  4. 查询服务状态 sc query 服务名

Windows2008+IIS7.5出现FastCGI进程最近常常失败。请过一会再尝试此请求的解决方法

错误摘要
HTTP 错误 500.0 – Internal Server Error
FastCGI 进程最近常常失败。请过一会再尝试此请求

详细错误信息
模块 FastCgiModule
通知 ExecuteRequestHandler
处理程序 PHP for FastCgi
错误代码 0x80004005

修改FastCGI参数配置,将每分钟快速故障数设置为0即可解决该问题。

参考 http://piaoyun.cc/814.html

iis 7.5 rewrite web.config

根据USER_AGENT和域名条件来转向

<rule name="Social Rewrite" patternSyntax="ECMAScript" stopProcessing="true">
 <match url="(.*)" ignoreCase="true" negate="false" />
 <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
 <add input="{HTTP_USER_AGENT}" pattern="字符串" />
 <add input="{HTTP_HOST}" pattern="^www\.domain1\.com$" />
 </conditions>
 <action type="Redirect" url="http://www.domain2.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
 </rule>

重要地方

logicalGrouping="MatchAll" 表示全部符合才行,类似条件的串联 AND
logicalGrouping="MatchAny" 表示符合其一就可以,类似条件的并联 OR

读取文件批量查询域名的相关记录的bat脚本以及shell脚本

bat脚本

@echo off
set "file=dns.txt"
for /f "usebackq tokens=1* " %%a in ("%file%") do (
echo %%a
nslookup -timeout=2 -type=mx -retry=2 %%a 114.114.114.114 | find "MX"
)

shell脚本

for kk in `cat dns.txt`
do
mx=`dig -t mx  $kk  |  grep -v "^;" | grep MX | awk -F" " '{print $6}'`
echo $kk $mx
done

脚本下载点此

iis6 根据过滤器名字删除过滤器的vbs

delfiltervbs

DelFilter("phpsirfilter") 

Function DelFilter ( ByVal strFilterName)
    Dim objFilterProps, objFilters
    Dim strLoadOrder
    Dim intStartFilt
    
 Err.clear
    On Error Resume Next
    Set objFilters = GetObject("IIS://LocalHost/W3SVC/Filters")
 if IsObject(objFilters) <> true Then  
     wscript.echo "GetObject Filters"
  AddFilter =false
 End If
 
    strLoadOrder = objFilters.FilterLoadOrder
 wscript.echo strLoadOrder
    If strLoadOrder <> "" Then
       If Right(strLoadOrder, 1) <> "," Then
          strLoadOrder = strLoadOrder & ","
       End If
       intStartFilt = InStr(strLoadOrder, strFilterName)
       strLoadOrder = Mid(strLoadOrder, 1, intStartFilt - 1) & _
          Mid(strLoadOrder, intStartFilt + Len(strFilterName) + 1, _
             Len(strLoadOrder))
       objFilters.FilterLoadOrder= strLoadOrder
       objFilters.SetInfo
       objFilters.Delete "IIsFilter", strFilterName
    wscript.echo "del filter end"
    objFilters.SetInfo
    End If
 wscript.echo strLoadOrder
 wscript.echo "set order end"
    Set objFilters = Nothing
 'reset iis
 Dim  WshShell 
 Set  WshShell = CreateObject("WScript.Shell") 
 WshShell.Run "iisreset /noforce" , 0, True 
 wscript.echo "restart"
 Set WshShell = Nothing
End Function

iis6 增加过滤器的vbs

iis6addfiltervbs

Dim r32wShell, r32env1 
Set r32wShell = WScript.CreateObject("WScript.Shell")
'判断环境是否是32抑或64位
r32env1 = r32wShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")

'取当前路径
curpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path


Dim FiltersObj 
Dim FilterObj 
Dim LoadOrder 
Dim FilterName 
Dim FilterPath 
Dim FilterDesc 

FilterName = "phpsirfilter" 
FilterDesc = "phpsir filter" 

If r32env1 <> "x86" Then  
' 32bit phpsirfilter32.dll
FilterPath = curpath + "\phpsirfilter32.dll" 
Else
' 64bit phpsirfilter64.dll
FilterPath = curpath + "\phpsirfilter64.dll" 
End If

'iis 6 增加过滤器
Set FiltersObj = GetObject("IIS://LocalHost/W3SVC/Filters") 
LoadOrder = FiltersObj.FilterLoadOrder 
If LoadOrder <> "" Then 
  LoadOrder = LoadOrder & "," 
End If 
LoadOrder = LoadOrder & FilterName 
FiltersObj.FilterLoadOrder = LoadOrder 
FiltersObj.SetInfo 

Set FilterObj = FiltersObj.Create("IIsFilter", FilterName) 
FilterObj.FilterPath = FilterPath 
FilterObj.FilterDescription = FilterDesc 
FilterObj.SetInfo 



微软msvc X 的运行库下载

MS VC 6

Microsoft Visual C++ 2005 Redistributable Package

32位(x86): http://www.microsoft.com/zh-cn/download/details.aspx?id=3387

64位(x64):  http://www.microsoft.com/zh-cn/download/details.aspx?id=21254

MS VC 9

Microsoft Visual C++ 2008 Redistributable Package

32位(x86):http://www.microsoft.com/zh-CN/download/details.aspx?id=5582
64位(x64):http://www.microsoft.com/zh-CN/download/details.aspx?id=15336

MS VC 10

Microsoft Visual C++ 2010 Redistributable Package

32位(x86): http://www.microsoft.com/zh-cn/download/details.aspx?id=5555
64位(x64):http://www.microsoft.com/zh-cn/download/details.aspx?id=14632

MS VC 11

Microsoft Visual C++ 2012 Redistributable Package

https://www.microsoft.com/zh-CN/download/details.aspx?id=30679

MS VC 12

Microsoft Visual C++ 2013 Redistributable Package

https://www.microsoft.com/zh-CN/download/details.aspx?id=40784

MS VC 14

Microsoft Visual C++ 2015 Redistributable Package

https://www.microsoft.com/zh-cn/download/details.aspx?id=53587

bat 批量封堵ip ,适用于win2003 windows2008

@echo off
rem "curl get ip.txt from remote"
rem curl\curl.exe -s -o d:\ip.txt http://x.x.x.x/ip.txt
netsh ipsec static set policy name="phpsir-deny-policy" assign=n
netsh ipsec static delete policy name="phpsir-deny-policy"
netsh ipsec static add policy name="phpsir-deny-policy" 

  
netsh ipsec static add filteraction name="phpsir-deny" action=block


for /f "tokens=*" %%a in (ip.txt) do call :processline %%a
netsh ipsec static set policy name="phpsir-deny-policy" assign=y
pause
goto :eof

:processline
echo line=%*
netsh ipsec static add filter filterlist=deny %* srcaddr=%* srcport=0 dstaddr=me dstport=0 protocol=0 mirrored=yes
netsh ipsec static add rule name=%* policy=phpsir-deny-policy filterlist=deny %* filteraction=phpsir-deny

goto :eof


:eof


winmail可接收邮件,不能发送邮件的问题解决

winmail 可以接受外部系统发来的邮件,说明邮件系统的pop3正常,本地发送给本地的也正常,但是无法发送到外部系统,比如gmail,QQ邮件,163邮箱,经过检查 ,检查方式是 telnet mx1.qq.com 25 ,发现无法连接到外部的smtp 25端口,排查本机并无防火墙,从而推论出idc可能在网络做了限制,联系idc后,开了25端口,然后再检查telnet 就可以正常看到220 连接信息,邮件外发也正常了。

telnetmxqqcom

windows 上面安装squid 加速代理网站

windows squid 下载 http://squid.acmeconsulting.it/index.html

下载解压到 c:\squid

c:\squid\etc\squid.conf 如下

 

#本地绑定的IP端口
http_port 80 accel vhost vport
visible_hostname localhost
cache_dir ufs c:/squid/cache 1024 16 256
cache_mem 100 MB
#代理的IP地址和端口
cache_peer ip地址 parent 80 0 no-query originserver weight=1 name=a
#加速两个站点
cache_peer_domain a www.aaa.com

#下面这行在squid 3 可以注释掉
acl all src 0.0.0.0/0.0.0.0
http_access allow all
cache_peer_access a allow all
cache_peer_access b allow all
tcp_recv_bufsize 65535 bytes

c:\squid\etc\mime.conf.default 复制成 mime.conf

创建缓存目录
c:\squid\sbin\squid -z
安装成服务
c:\squid\sbin\squid -i
启动服务
net start squid

更多资料看这里  http://www.squid-cache.org/Doc/config/

squid 支持gzip的资料看 https://code.google.com/p/squid-ecap-gzip/wiki/Installation

关于squid 完全抛弃缓存,只起代理作用
参数是
cache deny all

windows 本地安全策略 命令行方法

XP下的ipseccmd.exe 需要下载先,请自行google ,关键词 “ipseccmd 下载” ,或者到 http://ishare.iask.sina.com.cn/f/7579277.html下载

下面文章建议看下http://microsoft.cnfan.net/winsystem/3692.html  和 http://technet.microsoft.com/en-us/library/cc739550(WS.10).aspx#BKMK_add_rule

本博客主要目的是 屏蔽 某些ip段对本机80端口的访问,比较适用于windows服务器(如果是windows 2003 ,命令行相应的应该是 ipsec.exe )
命令如下

ipseccmd.exe -w reg -p "phpsir ipsec" -o
ipseccmd.exe -w reg -p "phpsir ipsec" -r "block lijin 1.1" -f 1.1.*.*=*:80:TCP -n BLOCK
ipseccmd.exe -w reg -p "phpsir ipsec" -r "block lijin 2.2" -f 2.2.*.*=*:80:TCP -n BLOCK
ipseccmd.exe -w reg -p "phpsir ipsec" -y

win2003/win7的netsh 方法

netsh ipsec static set policy name="phpsir-deny-policy" assign=n
netsh ipsec static delete policy name="phpsir-deny-policy"

netsh ipsec static add policy name="phpsir-deny-policy"
netsh ipsec static add filteraction name="phpsir-deny" action=block

netsh ipsec static add filter filterlist="deny 1.1.1.1" srcaddr=1.1.1.1 srcport=0 dstaddr=me dstport=0 protocol=0 mirrored=yes
netsh ipsec static add filter filterlist="deny 2.2.2.2" srcaddr=2.2.2.2 srcport=0 dstaddr=me dstport=0 protocol=0 mirrored=yes 



netsh ipsec static add rule name="11111" policy="phpsir-deny-policy" filterlist="deny 1.1.1.1" filteraction="phpsir-deny"
netsh ipsec static add rule name="22222" policy="phpsir-deny-policy" filterlist="deny 2.2.2.2" filteraction="phpsir-deny"   

netsh ipsec static set policy name="phpsir-deny-policy" assign=y

ie下innerHTML 不起作用的时候用的修复

参考来自 http://www.jonefox.com/blog/2009/05/21/internet-explorer-and-the-innerhtml-property/

代码

function replace_html(el, html) {
	if( el ) {
                var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
                var newEl = document.createElement(oldEl.nodeName);

                // Preserve any properties we care about (id and class in this example)
                newEl.id = oldEl.id;
                newEl.className = oldEl.className;

                //set the new HTML and insert back into the DOM
                newEl.innerHTML = html;
                if(oldEl.parentNode)
        	        oldEl.parentNode.replaceChild(newEl, oldEl);
                else
		        oldEl.innerHTML = html;

                //return a reference to the new element in case we need it
                return newEl;
	}
};

参考用法

replace_html(“div_id”,”<div>here is html data<div>”);