您的位置:首页 > 运维架构 > Nginx

nginx系列3__nginx与php(fastcgi)结合

2013-08-12 17:13 387 查看
nginxphp(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; } }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: