php5.2 nginx,Nginx+PHP5.2配置文档

本文详细介绍了如何在服务器上安装和配置Nginx,包括安装pcre库,编译并安装Nginx,设置启动脚本,以及配置http和upstream模块。同时,也讲解了如何利用Lighttpd编译spawn-fcgi工具来启动PHP服务,以实现PHP功能。通过这些步骤,可以搭建起一个具备动态内容处理能力的Web服务器。
摘要由CSDN通过智能技术生成

一、安装Nginx

1.安装Nginx所需的pcre库

用rpm包安装pcre/pcre-devel两个包

2.安装配置

#tar zxvf nginx-xx.tar.gz

#cd nginx-xx

#./configure --with-http_stub_status_module  //可添加统计模块

#make; make install

4.#ln -sf /opt/app/nginx/sbin/nginx /usr/sbin

5.编辑启动脚本

#!/bin/bash

#chkconfig: - 99 20

#description: Nginx Service Control Script

case "$1" in

start)

/opt/app/nginx/sbin/nginx

echo "Nginx is running"

;;

stop)

/usr/bin/killall -s QUIT nginx

echo "Nginx is stopped"

;;

restart)

$0 stop

$0 start

;;

*)

echo "Usage: $0{start|stop|restart}"

exit 1

esac

exit 0

6.调整配置文件

user  nobody;

worker_processes  10;

error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

use epoll;

worker_connections  2048;

}

http {

include       mime.types;

default_type  application/octet-stream;

log_format  main  '$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  main;

sendfile        on;

tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

upstream www {

ip_hash;

server 192.168.2.10:80;

server 192.168.2.20:80;

}

server {

listen     80;

server_name        www.chinaunix.net;

location / {

proxy_pass      http://www;

proxy_set_header x-real-IP $remote_addr;

}

}

server {

listen       80;

server_name  localhost;

#charset koi8-r;

charset utf-8;

access_log  logs/host.access.log  main;

location / {

root   html;

index  index.php index.html index.htm;

}

#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  /scripts$fastcgi_script_name;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

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

# concurs with nginx's one

#

#location ~ /\.ht {

#    deny  all;

#}

#### http_stub_status 

location ~^/status {

stub_status on;

access_log  off;

}

# 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;

#    }

#}

}

}

7.编辑lighttpd,取出spawn-fcgi工具,利用该工具启动php

#tar zxvf lighttpd-xx.tar.gz

#cd lighttpd-xx

#./configure && make (只编译不安装)

#cp src/spawn-fcgi /usr/sbin

#spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -C 16

在配置文件中开启php功能,重启服务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值