q29191 发表于 2018-11-15 11:52:33

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

  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,内容如下:
  usertricky1997;
  worker_processes1;
  error_logoff;
  pid      /home/tricky1997/nginx/logs/php_nginx.pid;
  events {
  use epoll;
  worker_connections10;
  }
  http {
  include       mime.types;
  default_typeapplication/octet-stream;
  access_log      off;
  server_names_hash_bucket_size 128;
  client_header_buffer_size   32k;
  large_client_header_buffers4 32k;
  client_max_body_size 8m;
  tcp_nodelay on;
  sendfile      on;
  keepalive_timeout65;
  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_name192.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;
  }
  }
  }

页: [1]
查看完整版本: nginx系列3__nginx与php(fastcgi)结合