实战Nginx与PHP(FastCGI)的安装、配置与优化
一篇介绍nginx和php-fmp配置,安装和使用的博文,文章将为何将nginx叫做反向代理服务器讲明白了,也能从中看出为什么ngnix会apache性能更加优异的一些端倪,因为nginx做的更加专注,只做好异步socket服务器这样的容器,其他的动态部分交给各自的语言通过server的形式去做就ok了(ps:语言与语言之间存在一个万能的socket),内容如下:
- gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel
- [root@localhost local]#tar zxvf php-5.2.13.tar.gz
- [root@localhost local]#gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1
- [root@localhost local]#cd php-5.2.13
- [root@localhost php-5.2.13]#./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm
- [root@localhost php-5.2.13]#make
- [root@localhost php-5.2.13]#make install
- [root@localhost php-5.2.13]cp php.ini-dist /usr/local/php/lib/php.ini
- /usr/local/php/bin/php-cgi --fpm
- 或者
- /usr/local/php/sbin/php-fpm start
- start,启动PHP的FastCGI进程。
- stop,强制终止PHP的FastCGI进程。
- quit,平滑终止PHP的FastCGI进程。
- restart, 重启PHP的FastCGI进程。
- reload, 重新加载PHP的php.ini。
- logrotate, 重新启用log文件。
- [root@localhost php]# netstat -antl|grep 9000
- tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
- [root@localhost php]# ps -ef|grep php-cgi
- root 3567 1 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- nobody 3568 3567 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- nobody 3569 3567 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- nobody 3570 3567 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- nobody 3571 3567 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- nobody 3572 3567 0 17:06 ? 00:00:00 /usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
- root 3583 3524 0 17:09 pts/1 00:00:00 grep php-cgi
- server {
- include port.conf;
- server_name www.ixdba.net ixdba.net;
- location / {
- index index.html index.php;
- root /web/www/www.ixdba.net;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME html$fastcgi_script_name;
- include fastcgi_params;
- }
- }
- fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2 keys_zone=TEST:10m inactive=5m;
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- fastcgi_cache TEST;
- fastcgi_cache_valid 200 302 1h;
- fastcgi_cache_valid 301 1d;
- fastcgi_cache_valid any 1m;
文章出处:http://ixdba.blog.51cto.com/2895551/806622,感谢作者奉献这么好的文章,共勉!
上一篇:PDO MySQL扩展模块 检测通不过的解决方法
下一篇:php类调用自己的函数