二、安装PHP 5.2.6(FastCGI模式) 1、编译安装PHP 5.2.6所需的支持库: tar zxvf libiconv-1.12.tar.gz cd libiconv-1.12/ ./configure --prefix=/usr/local make make install cd ../
tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure make make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make make install cd ../../
tar zxvf mhash-0.9.9.tar.gz cd mhash-0.9.9/ ./configure make make install cd ../
4、编译安装PHP5扩展模块 tar zxvf memcache-2.2.3.tgz cd memcache-2.2.3/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config make make install cd ../
tar jxvf eaccelerator-0.9.5.3.tar.bz2 cd eaccelerator-0.9.5.3/ /usr/local/webserver/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config make make install cd ../
5、修改php.ini文件 手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./" 修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/" 并在此行后增加以下几行,然后保存: extension = "memcache.so" 再查找output_buffering = Off 修改为output_buffering = On 自动修改:若嫌手工修改麻烦,可执行以下shell命令,自动完成对php.ini文件的修改: sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\n#' /usr/local/webserver/php/etc/php.ini sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/webserver/php/etc/php.ini
8、创建php-fpm配置文件(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi): 在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件: rm -f /usr/local/webserver/php/etc/php-fpm.conf vi /usr/local/webserver/php/etc/php-fpm.conf 输入以下内容(如果您安装 Nginx + PHP 用于程序调试,请将以下的0改为1,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页): 1. 2. 3. 4. All relative paths in this config are relative to php's install prefix 5. 6. 7. 8. Pid file 9. /usr/local/webserver/php/logs/php-fpm.pid 10. 11. Error log file 12. /usr/local/webserver/php/logs/php-fpm.log 13. 14. Log level 15. notice 16. 17. When this amount of php processes exited with SIGSEGV or SIGBUS ... 18. 10 19. 20. ... in a less than this interval of time, a graceful restart will be initiated. 21. Useful to work around accidental curruptions in accelerator's shared memory. 22. 1m 23. 24. Time limit on waiting child's reaction on signals from master 25. 5s 26. 27. Set to 'no' to debug fpm 28. yes 29. 30. 31. 32. 33. 34. 35. 36. Name of pool. Used in logs and stats. 37. default 38. 39. Address to accept fastcgi requests on. 40. Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket' 41. 127.0.0.1:9000 42. 43. 44. 45. Set listen(2) backlog 46. -1 47. 48. Set permissions for unix socket, if one used. 49. In Linux read/write permissions must be set in order to allow connections from web server. 50. Many BSD-derrived systems allow connections regardless of permissions. 51. 52. 53. 0666 54. 55. 56. Additional php.ini defines, specific to this pool of workers. 57. 58. /usr/sbin/sendmail -t -i 59. 1 60. 61. 62. Unix user of processes 63. www 64. 65. Unix group of processes 66. www 67. 68. Process manager settings 69. 70. 71. Sets style of controling worker process count. 72. Valid values are 'static' and 'apache-like' 73. static 74. 75. Sets the limit on the number of simultaneous requests that will be served. 76. Equivalent to Apache MaxClients directive. 77. Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi 78. Used with any pm_style. 79. 128 80. 81. Settings group for 'apache-like' pm style 82. 83. 84. Sets the number of server processes created on startup. 85. Used only when 'apache-like' pm_style is selected 86. 20 87. 88. Sets the desired minimum number of idle server processes. 89. Used only when 'apache-like' pm_style is selected 90. 5 91. 92. Sets the desired maximum number of idle server processes. 93. Used only when 'apache-like' pm_style is selected 94. 35 95. 96. 97. 98. 99. 100. The timeout (in seconds) for serving a single request after which the worker process will be terminated 101. Should be used when 'max_execution_time' ini option does not stop script execution for some reason 102. '0s' means 'off' 103. 0s 104. 105. The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file 106. '0s' means 'off' 107. 0s 108. 109. The log file for slow requests 110. logs/slow.log 111. 112. Set open file desc rlimit 113. 51200 114. 115. Set max core size rlimit 116. 0 117. 118. Chroot to this directory at the start, absolute path 119. 120. 121. Chdir to this directory at the start, absolute path 122. 123. 124. Redirect workers' stdout and stderr into main error log. 125. If not set, they will be redirected to /dev/null, according to FastCGI specs 126. yes 127. 128. How much requests each process should execute before respawn. 129. Useful to work around memory leaks in 3rd party libraries. 130. For endless request processing please specify 0 131. Equivalent to PHP_FCGI_MAX_REQUESTS 132. 10240 133. 134. Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. 135. Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) 136. Makes sense only with AF_INET listening socket. 137. 127.0.0.1 138. 139. Pass environment variables like LD_LIBRARY_PATH 140. All $VARIABLEs are taken from current environment 141. 142. $HOSTNAME 143. /usr/local/bin:/usr/bin:/bin 144. /tmp 145. /tmp 146. /tmp 147. $OSTYPE 148. $MACHTYPE 149. 2 150. 151. 152. 153. 154. 155. 156.
三、安装Nginx 0.7.17 1、安装Nginx所需的pcre库: tar zxvf pcre-7.7.tar.gz cd pcre-7.7/ ./configure make && make install cd ../
2、安装Nginx tar zxvf nginx-0.7.17.tar.gz cd nginx-0.7.17/ ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module make && make install cd ../
六、在不停止Nginx服务的情况下平滑变更Nginx配置 1、修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确: /usr/local/webserver/nginx/sbin/nginx -t 如果屏幕显示以下两行信息,说明配置文件正确: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully