nginx系列3__nginx与php(fastcgi)结合
2013-08-12 17:13
387 查看
nginx与php(fastcgi)结合目标:通过nginx反向代理到php(fastcgi)访问php页面。php网页所在路径为/home/tricky1997/nginx/php/index.php。通过http://192.168.159.133/index.php访问。
之前没接触过php,完全不会php开发,因此php的搭建花了很长时间。下载安装配置php(fastcgi)就花了将近一个小时。这里不再介绍,建议另找资料。安装完各种包之后,配置php.ini,配置php-fpm.conf。通过/usr/local/webserver/php/sbin/php-fpmstart启动php-cgi进程。然后启动nginx。配置文件路径为/home/tricky1997/nginx/php_nginx.conf,内容如下:
user tricky1997;worker_processes 1;
error_log off;pid /home/tricky1997/nginx/logs/php_nginx.pid;
events { use epoll; worker_connections 10;}
http { include mime.types; default_type application/octet-stream;
access_log off;
server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; tcp_nodelay on; sendfile on; keepalive_timeout 65;
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;
gzip on; gzip_buffers 4 16k; gzip_min_length 1k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plainapplication/x-javascript text/css application/xml; gzip_vary on;
server { listen 192.168.159.133:80; server_name 192.168.159.133 default; index index.html index.htm index.php;
root /home/tricky1997/nginx/php;
location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /usr/local/nginx/conf/fcgi.conf; }
error_page 404 500 502 503 504 /50x.html; location /50x.html{ root /home/tricky1997/nginx/error; } }
}
之前没接触过php,完全不会php开发,因此php的搭建花了很长时间。下载安装配置php(fastcgi)就花了将近一个小时。这里不再介绍,建议另找资料。安装完各种包之后,配置php.ini,配置php-fpm.conf。通过/usr/local/webserver/php/sbin/php-fpmstart启动php-cgi进程。然后启动nginx。配置文件路径为/home/tricky1997/nginx/php_nginx.conf,内容如下:
user tricky1997;worker_processes 1;
error_log off;pid /home/tricky1997/nginx/logs/php_nginx.pid;
events { use epoll; worker_connections 10;}
http { include mime.types; default_type application/octet-stream;
access_log off;
server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; tcp_nodelay on; sendfile on; keepalive_timeout 65;
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;
gzip on; gzip_buffers 4 16k; gzip_min_length 1k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plainapplication/x-javascript text/css application/xml; gzip_vary on;
server { listen 192.168.159.133:80; server_name 192.168.159.133 default; index index.html index.htm index.php;
root /home/tricky1997/nginx/php;
location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /usr/local/nginx/conf/fcgi.conf; }
error_page 404 500 502 503 504 /50x.html; location /50x.html{ root /home/tricky1997/nginx/error; } }
}
相关文章推荐
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[张宴原创]
- Nginx 0.8.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器(第5版)
- centos安装nginx+mysql+php+fastcgi+memcache最简单方法
- 在 Debian 上源码编译和安装 Nginx+PHP+FastCGI+MySQL
- highcharts 结合phantomjs纯后台生成图片系列二之php
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[转载]
- Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]
- nginx php fastcgi优化相关
- nginx系列1__nginx与tomcat结合
- 实战Nginx与PHP(FastCGI)的安装、配置与优化
- Nginx+php+fastcgi在win7下的配置
- yum安装nginx-mysql-php-fastcgi构建LNMP服务器
- nginx php fastcgi
- Varnish+nginx+php(FastCGI)+MYSQL5+MenCache+MenCachedb
- Nginx 0.7.x + PHP 5.2.6(FastCGI)+ MySQL 5.1 在128M小内存VPS服务器上的配置优化
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- 实战Nginx与PHP(FastCGI)的安装、配置与优化
- 使用nginx配置多个php fastcgi负载均衡
- LNMP基于fastcgi实现nginx,php,mysql的分离
- RHEL5+nginx+fastcgi+php实现lnmp环境