T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

windows��FastCGI��php-cgi���Ĺ���ԭ��������

�� ���� ����ʱ�䣺2010-07-02 | ���壺�� �� С��
[����]һ��FastCGI��ʲô�� ���� ����FastCGI�������޹صġ��������ܹ���CGI������չ������Ҫ��Ϊ�ǽ�CGI���������̱������ڴ��в����˻��ýϸߵ����ܡ�������֪��CGI�������ķ���������CGI���ܵ��µ���Ҫԭ��������CGI����...

һ��FastCGI��ʲô��
����
����FastCGI�������޹صġ��������ܹ���CGI������չ������Ҫ��Ϊ�ǽ�CGI���������̱������ڴ��в����˻��ýϸߵ����ܡ�������֪��CGI�������ķ���������CGI���ܵ��µ���Ҫԭ��������CGI�������������ڴ��в�����FastCGI���̹��������ȣ��������ṩ���õ����ܡ������ԡ�Fail- Over���Եȵȡ�
����
����FastCGI�Ĺٷ�վ����http://www.fastcgi.com
����
����FastCGI�Ĺ���ԭ���ǣ�
����
����1��Web Server ����ʱ����FastCGI���̹�������IIS ISAPI��Apache Module��;
����
����2��FastCGI���̹�����������ʼ������������CGI���������� (�������������пɼ�����php-cgi.exe)���ȴ�����Web Server�����ӡ�
����
����3�����ͻ������󵽴�Web Serverʱ��FastCGI���̹�����ѡ�������ӵ�һ��CGI��������Web server��CGI���������ͱ�׼���뷢�͵�FastCGI�ӽ���php-cgi.exe��
����
����4��FastCGI�ӽ������ɴ����󽫱�׼�����ʹ�����Ϣ��ͬһ���ӷ���Web Server����FastCGI�ӽ��̹ر�����ʱ���������洦�����ɡ�FastCGI�ӽ��̽��ŵȴ�����������FastCGI���̹������������� WebServer�У�����һ�����ӡ� ��������CGIģʽ�У�php-cgi.exe�ڴ˱��˳��ˡ�
����
���������������У����������� CGIͨ���ж�����ÿһ��Web����PHP���������½���php.ini����������ȫ��dll��չ���س�ʼ��ȫ�����ݽṹ��ʹ��FastCGI��������Щ��ֻ�ڽ�������ʱ����һ�Ρ�һ�������ĺô��ǣ��������ݿ�����(Persistent database connection)���Թ�����
����
��������ΪʲôҪʹ��FastCGI�������Ƕ��߳�CGI��������
����
���������ܳ��ڶ෽���Ŀ��ǣ����磺
����
����1������������Ҳ������windowsƽ̨���ȶ���ʹ�ö��߳�CGI��������������IIS ISAPI��ʽ����APACHE Module��ʽ��������������һ��ʱ���ͱ����ˡ�����ô������ȷʵ����������������
����
������Ȼ��Ҳ�кܶ�ʱ�����ܹ��ȶ���ʹ�ö��߳�CGI�����������ǣ����п��ܷ�����ҳ��ʱ�������ִ�������������Ҳ�Ҳ���ԭ�򣬶�����FastCGI��ʽʱ���ִ����ĸ��ʻ������Ľ��͡���Ҳ����������Ϊʲô������������ַ�ռ���CGI�����������վ��ȹ�����ַ�ռ�����ʽ�����ȶ�һ���㡣
����
����2�����ܣ����ܣ�����ô���ѵ�FastCGI�ȶ��߳�CGI���������죿����ʱ��ȷʵ��������ֻ�в���һ��������վ�����������½��ۡ�ԭ����Ҿ��ú��ѽ�����������˵��Zend WinEnabler��ʱ����Zendԭ��Ҳ�ǽ�����Windowsƽ̨��ʹ��FastCGI������IIS ISAPI��Apache Module����������Zend�Ѿ�����������Ʒ�ˡ�
����
����������ʹ��FastCGI������
����
����1�������̱ȶ��߳����ĸ����ķ������ڴ棬php-cgi.exe������ÿ��������7��25���ڴ棬���������ֳ���50��100���ԡ�
����
����2�����ܡ�ȷʵ��ʱ�����߳�CGI���������죬�Ǻǣ�������ʱ������Ҳ���ȶ���
����
����3��CGI���������ͺ������Ǻ�
����
�����ġ�IIS FastCGI���÷���
����
����1������ȷ��������ȷ��װ��PHP 4.3.x�����µİ汾�����ڰ汾��PHP��δĬ�ϼ���FastCGI֧�֣��������������ڰ汾�й�������Ҫ���±����������Ǽ���PHP��װ�� c:\php��֧��FastFCGI�Ŀ�ִ���ļ�����php-cgi.exe��
����
����ע�⣺������Php.ini�йر�cgi.force_redirect������fastcgi.impersonate������ cgi.rfc2616_header
����
����2������http://www.caraveo.com/fastcgi/fastcgi-0.6.zip�������е�isapi_fcgi.dll��ѹ����c:\phpĿ¼�£����DZ����ڴ�Ŀ¼������ֻ���������㣩��
����
����3��ʹ��regedit.exe��������ע�����
����
����HKEY_LOCAL_MACHINE:Software\FASTCGI\.php�������裩
����
����4���ڴ����½������¼�ֵ��
����
�����ַ������ͣ�AppPath��ֵΪc:\php\php-cgi.exe�������裩
����
�����ַ������ͣ�BindPath��ֵΪphp-fcgi���������� �����裩
����
���������ǿ�ѡ���ü�ֵ��
����
����DWORD���ͣ�StartServers������ʱĬ�������Ľ�����������Ĭ��ֵ5
����
����DWORD���ͣ�MaxServers������������������Ĭ��25
����
����DWORD���ͣ�IncrementServers����������������ʱ����������Ĭ��2
����
����DWORD���ͣ�Timeout������������������StartServers��Ŀ�ģ�����ʱ�䣬Ĭ��600���룩
����
����DWORD���ͣ�ThreadPoolSize���̳߳ش�С����IIS����Ч��Ĭ��10
����
����DWORD���ͣ�Impersonate����IIS��Ч������Ϊ1��ʹ��IIS��ȫ��־��Ϊ0���رմ����ԡ���Ҫ�ر��������㲻���İ�ȫ���⡣Ĭ��1
����
����DWORD���ͣ�MaxPostData��Post����Ԥ��Byte���ƣ�Ĭ��0
����
����DWORD���ͣ�BypassAuth����IIS��Ч������Ϊ1����isapi_fcgi.dll������ΪIIS Filter��ͬʱIIS������Ϊʹ��BASIC Authentication���⽫ǿ��������֤����ʹ��IIS�����û�����һѡ����Ŀ���������ű�ʵ���Լ��İ�ȫ���ơ�Ĭ��0
����
����BINARY���ͣ�CustomVars�����ӻ�������ֵ�����зָ���Null����
����
����5��������IIS6������һ��Web������չָ��c:\php\isapi_fcgi.dll����������Ӧ�ó������е�“��������������”�뱣��Ϊ 1��
����
����6������Ӧ�ó�����չӳ����ϵ��
����
����1). ��Internet��Ϣ�����������У�ѡ����վ��Ӧ�ó����ĸ�Ŀ¼��
����
����2). ����Ŀ¼����ҳ���Ҽ�ѡ��“����”������ѡ��“��Ŀ¼”��
����
����3). ����“����”��ť��ѡ��“ӳ��”Tabҳ��
����
����4). ����“����...”����“��ִ���ļ�”��Ϊ: c:\php\isapi_fcgi.dll����չ����Ϊ.php��һ��Ҫѡ��“ȷ���ļ��Ƿ�����”��Ȼ��“ȷ��”�������á�
����
����5). ��ͬ�����Ӷ�.php3��.phtml��չ����֧�֣���ѡ����
����
����6). �����趨����������IIS��
����
����7������һ�£�ͬʱ��������Webҳ�棬Ȼ���쿴�����������еĽ��̣�ҳ�����ɺ�php-cgi.exe���̳������в����˳���
����
�����塢Apache���÷���
����
����1������ȷ��������ȷ��װ��PHP 4.3.x�����µİ汾�����ڰ汾��PHP��δĬ�ϼ���FastCGI֧�֣��������������ڰ汾�й�������Ҫ���±����������Ǽ���PHP��װ�� c:\php��֧��FastFCGI�Ŀ�ִ���ļ�����php-cgi.exe��
����
����ע�⣺������Php.ini�д���cgi.force_redirect���ر�fastcgi.impersonate���ر� cgi.rfc2616_headers��
����
����2������http://www.fastcgi.com/dist/mod_fastcgi-2.4.2-AP20.dll���ŵ�Apache 2.x��ModulesĿ¼�С�
����
����3��ȷ��Apache 2.x��CGI��ʽ�¿�����������PHP��httpd.conf�д������¼��У�
����
����ScriptAlias /php/ "c:/php/"
����
����Action application/x-httpd-php "/php/php-cgi.exe"
����
����SetEnv PHPRC "C:/php"
����
����AddType application/x-httpd-php .php
����
����4����httpd.conf������:
����
����LoadModule fastcgi_module modules/mod_fastcgi-2.4.2-AP20.dll
����
����# ˵�����˴��� -processes 3 ��ʾ�������� php-cgi.exe ���̣�
����
����# ���� FastCgiServer ����ϸ�������ο� FastCGI �ĵ���
����
����FastCgiServer "c:/php/php-cgi.exe" -processes 3
����
����5����������Apache������ͬ�ϡ�
����
���������߼�����
����
������������һ�ֳ��������ķ�������ͬʱ��Apache 2��IIS 6������Web����������phpӦ�á���ô�����������ֿ��ܣ�
����
����A��phpʹ��iis isapi��apache module��װ����Ϊ���̷߳�ʽ���С�������FastCGIû�й�ϵ��
����
����B������һ��������ʹ��FastCGI��ʽ����һ��ʹ�ö��̷߳�ʽ������������������
����
����C��������ʹ��FastCGI��ʽ������������������һ������Ϊ��
����
����������������������һЩphp-cgi.exe���̣�Ȼ��������֮һ������phpҳ�棬���߸�һ�����������µ�php-cgi.exe���̣�����ѽ����
����
����Ϊʲô�أ�������������Ϊ����ʹ�õ�����������iis isapi��apache module�������ߴ��Ų�û������Ҫ�ͶԷ�ͬʱʹ�ðɣ��Ǻǡ������룬Apache 2��IIS 6�������Թ���һ��php-cgi.exe�������ͺ��ˣ��Ȳ��˷��ڴ棬����Ҳ�����е��������ˡ�
����
���������о��Ͳ���֤���������뷨�ǿ��еġ����ǣ�����Shane Caraveo��δ��ISAPI DLL���ṩʹ������FastCGI�����Ĺ��ܣ������ڴ˳�����ֻ������IIS���������͹���php-cgi.exe��Ȼ������Apacheȥʹ����Щ�� IIS������php-cgi.exe���̡�
����
�������÷�����
����
����1�����������еķ�������IIS FastCGI��
����
����2���������������еķ�������Apache FastCGI����.4��Ϊ��httpd.conf������:
����
����LoadModule fastcgi_module modules/mod_fastcgi-2.4.2-AP20.dll
����
����# ʹ���ⲿFastCGI�����������ο� FastCGI �ĵ���
����
����FastCgiExternalServer "c:/php/php-cgi.exe" -socket "php-fcgi"
����
����ע�⣺-socket��������ֵ������HKEY_LOCAL_MACHINE:Software\FASTCGI\.php��BindPath��ֵһ�£���������FastCGI���̹������Ż�ʹ��ͬһ�������ܵ�����php-cgi.exe��
����
����ע�⣺��������php-cgi.exe����ֻ��IIS�е�FastCGI���̹����������� Apache�ķ�æ���󲢲���ʹIIS�е�FastCGI���ȸ�����php-cgi.exe���̡����ˣ���IIS������FastCGIʱӦ��ʹ StartServersֵ�㹻�����Ա���php�������������㡣ͬ�������������ǣ�����IIS�ر��ˣ���ôApache�ͻ��Ҳ���Php�������ˣ�����Ҫ���ġ�
����
�����ɴ˴�����һ�������ǣ���ʱ��php.ini��cgi.force_redirect��fastcgi.impersonate�� cgi.rfc2616_headersӦ����ô�趨�أ�������������ȥ˼����……�Ǻ�
����
��������һ�����������������ǣ�IIS�dz����У�һ��ʱ������IIS������php-cgi.exe�˳��ˣ���apache�ͽ��Ͳ��� Php�ˣ���ô���أ���ʱ���Է���һ��iis��վ��php-cgi.exe���������ˣ���Ŷ��һ��������ʹ��IIS 6�Ľ��̳ع�������Ӧ�ó������йص�“���г�ʱ”�����ң���“Ӧ�ó����ر�ʶ”�н������˺��趨Ϊ��Apache���������˺�һ�¡�

����Ϊ�˷��������Ķ��ر�עԭ�ĵ�ַ��http://blog.myspace.cn/e/406775941.htm
 

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:6.47ms QueryTime:7