欢迎来到资源库(www.zyku.net)

Debian

当前位置:首页 > 服务器教程 > Debian > Debian

Debian系统下安装PHP和Nginx环境

时间:2017-02-20|栏目:Debian|点击:|我要投稿

1、安装php

apt-get install php5-cgi php5-mysql php5-gd -yf --force-yes;

2、安装nginx

首先安装一些必须的软件(pcre和zlib):

  apt-get install libpcre3-dev -yf --force-yes;
  apt-get install zlib1g-dev -yf --force-yes;

debian下用apt-get可以安装nginx的0.6.32版,但我通常不用这个版本,比较旧了,所以下载nginx编译安装:

  wget http://sudone.com/download/nginx/nginx-0.7.30.tar.gz -O /tmp/nginx.tar.gz
  cd /tmp/
  tar -zxf nginx.tar.gz
  cd nginx-0.7.30
  ./configure --with-http_realip_module --prefix=/usr/local/nginx/ --with-poll_module --with-cpu-opt=pentium4 --with-md5=/usr/lib --with-sha1=/usr/lib --with-openssl=/usr/lib --with-http_sub_module --with-cc-opt="-I /usr/include/pcre"
  make -j10
  make install

3、使用spawn-fcgi启动php

  cd /usr/local/nginx/sbin
  wget http://sudone.com/download/spawn-fcgi
  chmod +x spawn-fcgi
  spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20
  echo "/usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20" >> /etc/rc.local

4、配置nginx(例子)

server {
  include port.conf;
  server_name test.com;
  location / {
  root   /www;
  index  index.html index.htm index.php;
  }
  
location ~ .php$ {
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME  /www$fastcgi_script_name;
  include        fastcgi_params;
  }
  }

启动和重启nginx:

  启动:/usr/local/nginx/sbin/nginx
  重启:kill -HUP `cat /usr/local/nginx/logs/nginx.pid`或killall -9 nginx;/usr/local/nginx/sbin/nginx

5、php的配置

php配置文件php.ini位置在/etc/php5/cgi/php.ini,有需要就修改这个文件,并用下面这条语句重启php-cgi:

killall -9 php-cgi; spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20

(资源库 www.zyku.net)

上一篇:Debian系统下安装virtualbox的详细方法

栏    目:Debian

下一篇:Debian 7 修改为字符界面登陆的方法

本文标题:Debian系统下安装PHP和Nginx环境

本文地址:https://www.zyku.net/debian/803.html

关于我们 | 版权申明 | 寻求合作 |

重要申明:本站所有的文章、图片、评论等内容,均由网友发表或上传并维护或收集自网络,仅供个人学习交流使用,版权归原作者所有。

如有侵犯您的版权,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:95148658 | 邮箱:mb8#qq.com(#换成@)

苏ICP备2020066115号-1

本网站由提供CDN加速/云存储服务