⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.fastcgi

📁 php-4.4.7学习linux时下载的源代码
💻 FASTCGI
字号:
Credits:Ben Mansell, Stephen Landamore, Daniel Silverstone, Shane CaraveoBuilding PHP------------You must add '--enable-fastcgi' to the configure command on Linux orOSX based systems to get fastcgi support in the php-cgi binary.  Youalso must not use '--enable-discard-path'.Running the FastCGI PHP module------------------------------There are two ways to run the resulting 'php' binary after the fastcgiversion has been built:1) Configure your web server to run the PHP binary itself.This is the simplest method, obviously you will have to configure yourweb server appropriately. Some web servers may also not support this method,or may not be as efficient.2) Run PHP separately from the web server.In this setup, PHP is started as a separate process entirely from the webserver. It will listen on a socket for new FastCGI requests, and deliverPHP pages as appropriate. This is the recommended way of running PHP-FastCGI.To run this way, you must start the PHP binary running by giving it an IPand a port number to listen to on the command line, e.g.:    ./php -b 127.0.0.1:8002The above line is the recommended way of running FastCGI.  You usuallywant the FastCGI server to provide services to the localhost, noteveryone on the Internet.If your web server sits on a remote host, you can make FastCGI listenon all interfaces:    ./php -b :8002    ./php -b "*:8002"Note that hostnames are not supported.You must also configure your web server to connect to the appropriate portin order to talk to the PHP FastCGI process.The advantage of running PHP in this way is that it entirely separates theweb server and PHP process, so that one cannot disrupt the other. It alsoallows PHP to be on an entirely separate machine from the web server if needbe, you could even have several web servers utilising the same running PHPprocess if required!Using FastCGI PHP with Apache=============================First of all, you may well ask 'Why?'. After all, Apache already has mod_php.However, there are advantages to running PHP with FastCGI. Separating thePHP code from the web server removes 'bloat' from the main server, and shouldimprove the performance of non-PHP requests. Secondly, having one permanentPHP process as opposed to one per apache process means that shared resourceslike persistent database connections are used more efficiently.First of all, make sure that the FastCGI module is enabled. You should havea line in your config like:    LoadModule fastcgi_module /usr/lib/apache/2.0/mod_fastcgi.soDon't load mod_php, by the way. Make sure it is commented out!    #LoadModule php4_module /usr/lib/apache/2.0/libphp4.soNow, we'll create a fcgi-bin directory, just like you would do with normalCGI scripts. You'll need to create a directory somewhere to store yourFastCGI binaries. We'll use /space/fcgi-bin/ for this example. Remember tocopy the FastCGI-PHP binary in there. (named 'php-cgi')  This sets upphp to run under mod_fastcgi as a dynamic server.    ScriptAlias /fcgi-bin/ /space/fcgi-bin/    <Location /fcgi-bin/>        Options ExecCGI        SetHandler fastcgi-script    </Location>To setup a specific static configuration for php, you have to usethe FastCgiServer configuration for mod_fastcgi.  For this, do notuse the above configuration, but rather the following.(see mod_fastcgi docs for more configuration information):    Alias /fcgi-bin/ /space/fcgi-bin/    FastCgiServer /path/to/php-cgi -processes 5For either of the above configurations,  we need to tell Apache to use the FastCGI binary /fcgi-bin/php to deliver PHP pages. All that is needed is:    AddType application/x-httpd-fastphp .php    Action application/x-httpd-fastphp /fcgi-bin/php-cgiNow, if you restart Apache, php pages should now be delivered!Using FastCGI PHP with IIS or iPlanet=====================================FastCGI server plugins are available at www.caraveo.com/fastcgi/Documentation on these are sparse.  iPlanet is not very tested,and no makefile exists yet for unix based iPlanet servers.Security--------Be sure to run the php binary as an appropriate userid. Also, firewall outthe port that PHP is listening on. In addition, you can set the environmentvariable FCGI_WEB_SERVER_ADDRS to control who can connect to the FastCGI.Set it to a comma separated list of IP addresses, e.g.:export FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71Tuning------There are a few tuning parameters that can be tweaked to control theperformance of FastCGI PHP. The following are environment variables that canbe set before running the PHP binary:PHP_FCGI_CHILDREN  (default value: 8)This controls how many child processes the PHP process spawns. When thefastcgi starts, it creates a number of child processes which handle onepage request at a time. So by default, you will be able to handle 8concurrent PHP page requests. Further requests will be queued.Increasing this number will allow for better concurrency, especially if youhave pages that take a significant time to create, or supply a lot of data(e.g. downloading huge files via PHP). On the other hand, having moreprocesses running will use more RAM, and letting too many PHP pages begenerated concurrently will mean that each request will be slow.PHP_FCGI_MAX_REQUESTS (default value: 500)This controls how many requests each child process will handle beforeexitting. When one process exits, another will be created. This tuning isnecessary because several PHP functions are known to have memory leaks. If thePHP processes were left around forever, they would be become very inefficient.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -