Chinaunix首页 | 论坛 | 博客
  • 博客访问: 333518
  • 博文数量: 68
  • 博客积分: 405
  • 博客等级: 一等列兵
  • 技术积分: 1288
  • 用 户 组: 普通用户
  • 注册时间: 2013-01-09 15:39
个人简介

本人从事 Linux Nginx Mysql PHP 开发多年,联系v:luhuang2003 ,希望接触到更新的web开发软件,开此博客希望能把自己的经验和接触的东西与大家进行共享。

文章分类

全部博文(68)

文章存档

2024年(1)

2013年(67)

我的朋友

分类: Web开发

2013-05-18 17:07:56

Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。 Igor 将源代码以类 BSD 许可证的形式发布

1、为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Compatible Regular Expressions)包。您可以到下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包

Nginx的安装需要依赖于gcc、openssl-devel、pcre-devel、zlib-devel

1、先安装 openssl

yum install openssl

2、 下载 pcre 软件 Rewrite 配置的使用
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz
tar -zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make
make install

3、安装 zlib
wget
tar -zxvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure
make
make install

4、下载 Nginx 软件

解压配置和安装 进入目录
./configure –prefix=/usr/local/nginx –with-pcre=pcre-8.32的源码目录
make
make install

注: –with-pcre=pcre-8.32 指的是pcre-8.32 的源码路径

我的 nginx.conf 的 server 配置:
server {
listen 80;
server_name www.**.com;
#server_name ~^(?.+).**.com
index index.php;
root /usr/local/nginx/photo;

#charset koi8-r;

rewrite ^(.*)\.html$ /index.php?domain=111 break;

location ~ \.php$ {
#root /usr/local/nginx/huanglu;
#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;
}

rewrite_log on;
error_log logs/rewrite.error.log notice;

location / {
index index.php index.html index.htm;
}
}

5、测试 Nginx 配置文件是否正确
/usr/local/nginx/sbin/nginx -t #测试配置文件是否正确

6、启动Nginx:
/usr/local/nginx/sbin/nginx

7、测试:
http://域名或IP/index.html 是否正确 如果没有达到rewrite 请查看 日志: logs/rewrite.error.log

出现如下则正确:

 

/usr/local/nginx/sbin/nginx #启动Nginx

 

如出现以下错误:

/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决办法如下:

在redhat 64位机器上, nginx可能读取的pcre文件为/lib64/libpcre.so.1文件.

ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1

ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1

阅读(1613) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~