原创日志

win2003下apache运行php的方式 fastcgi方式mod_fcgid 和 isapi方式php5apache2_4.dll

[ 2020-06-03 10:45:18 | 作者: admin ]
字号: | |
p.s. 虽然win2003非常非常悠久,不过资源消耗低,系统稳定,运行小项目绝对没问题,特别是企业站。这里选择apache的原因是可以作为服务运行,比较方便,也支持虚拟目录Alias。并发过高还是老实点转到 centos+nginx。

首先是版本选择,根据https://www.apachelounge.com/download/win32/ 的说法,最后一个支持win2003的是vc10编译版本,可选apache2.2和apache2.4,下方有下载链接。
Build with Windows® Platform SDK 7.1 and Visual Studio C++ 2010 SP1 aka VC10. VC10 has improvements, fixes and optimizations over VC9 in areas like Performance, MemoryManagement and Stability. Note: a VC10 binary loads VC9 and VC10 modules, and can be used with for example PHP 5.4 VC9 as module.

VC10 is the latest Visual Studio which supports XP and 2003.

Supported Windows Operating System: XP+, Server 20013+, 7+, Vista+, Server 2008+, 8+, Server 2012+, 10, Server 2016.


【fastcgi方式安装apache_vc10 + mod_fcgid_vc10 + php_nts_vc9 】

fastcgi方式安装需要下3个软件,版本都要兼容vc9,因为php5.4是vc9编译且是最后支持win2003的版本,所以其他软件也尽量兼容vc9才行,mod_fcgid是vc10兼容vc9

apache一开始找了个vc9版本 httpd-2.4.27-x86-vc9.zip,安装后apache的error中发现fcgi模块兼容错误,每隔数小时会导致apache2.4意外终止。
重新在apachelounge下载vc10版本的 httpd-2.2.34-win32-vc10.zip和mod_fcgid-2.3.9-apache2.2-win32.zip,安装顺利。

mod_fcgid 各版本apache和各种mod模块下载地址:
apache2.2-vc10:https://www.apachelounge.com/download/win32/ Win2003可下此vc10版本,这是最后的apache2.2版
apache2.4-vc10 : https://www.apachelounge.com/download/vc10/ 此版未测试,理论vc10编译的肯定可用
apache2.4-vc11 : https://www.apachelounge.com/download/vc11/ 此版介绍里明确说不支持win2003,但是测试也能用,兼容估计不行
apache的httpd.conf中加入支持php运行如下:
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
       FcgidInitialEnv PHPRC "E:/php5.4.45.nts"
       FcgidInitialEnv TEMP "E:/php5.4.45.nts/tmp"
       FcgidInitialEnv TMP "E:/php5.4.45.nts/tmp"
         IdleTimeout 600
         ProcessLifeTime 3600
         MaxProcessCount 30
         DefaultMinClassProcessCount 3
         DefaultMaxClassProcessCount 30
         IPCConnectTimeout 30
         IPCCommTimeout 300
         MaxRequestsPerProcess 500
         #上传文件的最大尺寸 100MB
         FcgidMaxRequestLen 104857600

         <Files ~ (\.php)>
               AddHandler fcgid-script .php
               FcgidWrapper "E:/php5.4.45.nts/php-cgi.exe -c E:/php5.4.45.nts//php.ini" .php
         </Files>
</IfModule>

php的话, win2003最后支持版本是5.4,vc9编译的最后版本找了下就是 php-5.4.45-nts-Win32-VC9-x86.zip,需要注意非线程安全nts
下载: https://windows.php.net/downloads/releases/archives/

ionCube Loader,另外PHP加密解密插件还是需要安装(PHP5.2/5.3/5.4需要装vc9_x86 VC2008 ): https://www.ioncube.com/loaders.php
[Zend]
zend_extension = "E:/php5.4.45.nts/ext/ioncube_loader_win_5.4.dll"

Zend Guard Loader,另外PHP加密解密和优化加速插件需要安装,PHP5.3开始 Zend Guard Loader 代替了PHP5.2 ZendOptimizer
[Zend.loader]
zend_loader.enable=1
zend_loader.disable_licensing=1
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
zend_extension="E:/php5.4.45.nts/ext/ZendLoader.dll"

安装后效果如下
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
         with the ionCube PHP Loader v10.2.1, Copyright (c) 2002-2018, by ionCube Ltd.
         with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

注意:运行中发现有wait_close过多的问题,参考 http://blog.xg98.com/article.asp?id=2685


【isapi方式安装apache_vc9 + php_ts_vc9 】

这种方式安装php支持后,高并发或者过1天就发现会出现内存溢出,修改了多次配置不见效,应该是版本兼容问题,最后放弃isapi改用fastcgi模式
错误应用程序 httpd.exe,版本 2.4.27.0,错误模块 libaprutil-1.dll,版本 1.6.0.0,错误地址 0x00001e4f。
apache 同上 httpd-2.4.27-x86-vc9.zip
php 因为是isapi方式,需要下线程安全ts版本,文件名没有nts字样就是ts版本, php-5.4.45-Win32-VC9-x86.zip
下载后在php目录下能找到 php5apache2_4.dll ,然后在apache的配置文件 httpd.conf里面配置支持php如下
LoadModule php5_module E:/php5.4.45.ts/php5apache2_4.dll
PHPIniDir "E:/php5.4.45.ts/"
AddType application/x-httpd-php .php






关于windows下面mod_fcgid的配置项
FcgidInitialEnv PHPRC "C:/serveur/php7"
<Files ~ (\.php)>
     FcgidWrapper "C:/serveur/php7/php-cgi.exe -c C:/serveur/php7/php.ini" .php
</Files>
FcgidInitialEnv TEMP "R:/php-httpd_temp"
FcgidInitialEnv TMP "R:/php-httpd_temp"
FcgidInitialEnv windir "C:\WINDOWS"
FcgidInitialEnv SystemRoot "C:\Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv PROCESSOR_ARCHITECTURE "AMD64"
FcgidInitialEnv PROCESSOR_IDENTIFIER "Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
FcgidInitialEnv PROCESSOR_LEVEL "6"
FcgidInitialEnv PROCESSOR_REVISION "2a07"
FcgidInitialEnv NUMBER_OF_PROCESSORS 4
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 0
FcgidInitialEnv PHP_FCGI_CHILDREN 0
FcgidFixPathinfo 1
FcgidWin32PreventOrphans On
FcgidMaxRequestsPerProcess 0
FcgidMaxProcesses 40
FcgidMaxProcessesPerClass 40
FcgidMinProcessesPerClass 16
FcgidIdleScanInterval 1
FcgidErrorScanInterval 1
FcgidZombieScanInterval 1
FcgidIdleTimeout 60
FcgidProcessLifeTime 60
FcgidConnectTimeout 1
FcgidIOTimeout 600
FcgidBusyTimeout 600
FcgidBusyScanInterval 600
FcgidMaxRequestLen 134217728
FcgidOutputBufferSize 0
FcgidPassHeader Authorization




参考:
PHP安装ioncube扩展 https://blog.csdn.net/forLightWay/article/details/78888583
PHP加密工具Zend Guard Loader(原php引擎Zend Optimizer升级版) https://blog.csdn.net/z507263441/article/details/40131185/

各版本ioncube_loader_win下载: 点击下载
[最后修改由 admin, 于 2020-06-06 09:07:38]
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2680

这篇日志没有评论。

此日志不可发表评论。