1、首先修改nginx的配置文件(標色的為我修改過或添加過的內容)

vim /etc/nginx/conf/nginx.conf

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

worker_rlimit_nofile 51200;                           //需要在shell下執行ulimit  -SHn  512 00

events {

use epoll;    worker_connections  51200;

}

http {

include       mime.types;

default_type  application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

'"$status" $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log  logs/access.log  access;

sendfile        on;

tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  60;

tcp_nodelay on;

#gzip  on;

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

root  /home/web;

index  index.phpindex.html index.htm;

if (-f $request_filename/index.html){

rewrite (.*) $1/index.html break;

}

if (-f $request_filename/index.php){

rewrite (.*) $1/index.php;

}

if (-f $request_filename){

rewrite (.*) /index.php;

}        }

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ /.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ /.php$ {

root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  /home/web$fastcgi_script_name;    //home/web 為php網站的目錄

include        fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ //.ht {

#    deny  all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

#    listen       8000;

#    listen       somename:8080;

#    server_name  somename  alias  another.alias;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

# HTTPS server

#

#server {

#    listen       443;

#    server_name  localhost;

#    ssl                  on;

#    ssl_certificate      cert.pem;

#    ssl_certificate_key  cert.key;

#    ssl_session_timeout  5m;

#    ssl_protocols  SSLv2 SSLv3 TLSv1;

#    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

#    ssl_prefer_server_ciphers   on;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

}

以上是我的nginx.conf文件內容

2、安裝php5-cgi模塊

apt-get install php5-cgi php5-gd php5-curl

修改/etc/php5/cgi/php.ini文件,里面有一項cgi.fix_pathinfo數據為1,默認為0 cgi.fix_pathinfo=1; 這樣php5-cgi方能正常使用SCRIPT_FILENAME這個變量。

這里還要裝一個php加速的軟件ZendOptimizer,在輸入php.ini位置的時候輸入

/etc/php5/cgi/

3、安裝spawn-fcgi spawn-fcgi是lighttpd的一個用來控制php-cgi的工具

如果系統沒有安裝GCC編譯環境,剛需要在安裝lighttpd之前要安裝build-essential工具包,執行以下命令

aptitude install build-essentiallibpcre3-dev

tar xzvf  lighttpd-1.4.19.tar.gz

cd lighttpd-1.4.19/

./configure –without-zlib –without-bzip2

make

cd src

cp spawn-fcgi  /usr/local/bin/spawn-fcgi

這樣cgi控制器就安裝完成了。

4、啟動cgi

spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www -g www -f /usr/bin/php5-cgi

注意:ip,端口與nginx服務器中的fastcgi-pass要對應. -C表示打開幾個cgi進程

啟動nginx ,在啟動之前先測試下配置文件是否正確

nginx -t -c /etc/nginx/conf/nginx.conf

2009/02/03 15:27:12 [info] 21782#0: the configuration file /etc/nginx/conf/nginx.conf syntax is ok

2009/02/03 15:27:12 [info] 21782#0: the configuration file /etc/nginx/conf/nginx.conf was tested successfully

出現以上信息說明配置文件准確。

/etc/init.d/nginx start

好了,如果沒有出錯信息,則說明配置成功了,現在寫個phpinfo測試下吧

cd /home/web

nano index.php

輸入

phpinfo();

?>

保存。

測試是否出現phpinfo

debian架设php,Debian 下搭建php-fastcgi方式,nginx相关推荐

  1. .nwt+core+2.0+mysql_Centos7系统下搭建.NET Core2.0+Nginx+Supervisor环境

    一.Linux .NET Core简介 一直以来,微软只对自家平台提供.NET支持,这样等于让这个"理论上"可以跨平台的框架在Linux和macOS上的支持只能由第三方项目提供(比 ...

  2. nginx php7 fastcgi,Windows下搭建PHP7+FastCGI+Nginx环境

    注意这里说的是FastCGI,不是FPM,FPM全称是FastCGI Process Manager,它是FastCGI进程管理器,在Windows下是没有这个的,只能手动启动FastCGI进程由它自 ...

  3. FastDFS - Linux下搭建FastDFS 文件服务器与Nginx配置(部署和运维)

    朋友做了个视频在线App,线上运维我来帮他折腾.此篇记录部署步骤,方便下次直接查看使用.部分内容来源于网络,如侵联删. 本篇文章只叙述FastDFS的部署与运维,简介请点击FastDFS - 快速的分 ...

  4. debian部署mysql和tomcat_【超级详细】在Debian/kali/linux服务器下搭建Tomcat7+mysql+jdk8环境...

    JDK安装 Tomcat安装 MySQL安装 [JDK安装] 1.首先下载一个JDK 下载地址:http://www.oracle.com/technetwork/java/javase/downlo ...

  5. kali_vps,debian,Ubuntu下搭建LAMP环境

    文章目录 一.Apache2 web服务器的安装: 更新服务器出现以下问题: 安装Apache: 开启 .关闭和重启Apache服务器: 二.数据库的安装,这里安装MySQL5.7: 三.PHP的安装 ...

  6. win2003 php5.2.17,win2003下搭建FastCGI+php5.2.17

    因为之前安装的西数版集成PHP环境出现了phpMyAdmin无法显示中文等各种错误,所以被迫无奈重装服务器,在网上浏览的时候无意的发现PHP5.3的全新特效及改进,原有的ISAPI方式解析PHP脚本已 ...

  7. Ubuntu 下搭建 Nginx 部署 vue 项目

    Ubuntu 下搭建 Nginx 部署 vue 项目 上一篇:Ubuntu 下部署 SpringBoot 第一步: Ubuntu 上安装 nodejs 执行 apt install nodejs 命令 ...

  8. Linux下搭建jenkins+svn+http+maven自动化部署

    Linux下搭建jenkins+svn+http+maven自动化部署 服务器设置: 卸载redhat的yum,安装centos的yum,配置第三方yum 1.删除redhat原有的rpm -qa | ...

  9. kali dvwa php mysql,kali linux 2.0下搭建DVWA渗透测试演练平台

    DVWA (Dam Vulnerable Web Application)DVWA是用PHP+MySQL编写的一套用于常规WEB漏洞教学和检测的WEB脆弱性测试程序.包含了SQL注入.XSS.盲注等常 ...

最新文章

  1. python读excel字体颜色_python 设置 excel 单元格颜色填充和字体效果
  2. 如何利用css使PNG图片透明
  3. jquery ajax 异步分页,jquery 分页 Ajax异步
  4. 不要再纠结卷积的公式啦!0公式深度解析全连接前馈网络与卷积神经网络!
  5. python小明爬楼梯_爬楼梯(Python and C++解法)
  6. plt.Circle()
  7. 【软件测试】使用C++ Test进行动态测试
  8. 微前端 Micro-Frontnds - Single-SPA Application API
  9. 【SSD-Caffe】安装使用教程
  10. 【C#】【Unity】第三人称摄像机跟随人物移动时碰撞到墙壁等,摄像机不穿越墙壁
  11. 通过Dreamweaver建立一个简单的网页音乐盒模型效果/css/h5/
  12. 你不得不了解的人工智能基础知识
  13. mybatis源码(一)
  14. 奇偶校验(附代码实现)
  15. celery英语_蔬菜介绍:芹菜 Celery
  16. v–meca仿真软件下载_进入工作软件–简介
  17. 诺基亚n1平板电脑刷机教程_诺基亚N1平板电脑做工如何?诺基亚N1拆机图解评测...
  18. Selenium的使用
  19. php 写入txt换行_php数组写入txt换行
  20. 数字信号处理 | 实验二 MATLAB z换和z逆变换分析+求解差分方程+求解单位冲击响应+求解幅频相频特性曲线+求解零极点

热门文章

  1. .net 访问mysql链接池_c# – .NET SqlConnection类,连接池和重新连接逻辑
  2. 三星手机com.android.settings,三星手机恢复出厂设置方法【具体步骤】
  3. python模块搜索原则_详解python模块路径查找规则及定义
  4. 数据集特征提取_基于PCA算法实现鸢尾花数据集的特征提取任务
  5. 数据结构与算法 / 编辑器和编译器如何判定括号是否合法
  6. java正则 找出数字,Java顶用正则表达式找出数字
  7. 百度安全 TrustZone SDK 正式成为 OP-TEE 官方推荐 Rust 开发环境
  8. java.library.path hadoop_关于java:Hadoop“无法为您的平台加载本机Hadoop库”警告
  9. qrcodejs2--Vue生成二维码组件封装
  10. Node.js event loop 和 JS 浏览器环境下的事件循环的区别