Linux Nginx 安装配置说明

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

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

软件我都下载到 /software/nginx

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

1、先安装 openssl

yum install openssl

 2、 下载 pcre 软件 Rewrite 配置的使用

cd /software/nginx

http://jaist.dl.sourceforge.net/project/pcre/pcre/8.32/pcre-8.32.zip

unzip pcre-8.32.zip
 cd pcre-8.32

./configure

make

make install

3、安装 zlib

cd /software/nginx

wget http://zlib.net/zlib-1.2.7.tar.gz
 tar -zxvf zlib-1.2.7.tar.gz
 cd zlib-1.2.7
 ./configure
 make
 make install

4、下载 Nginx 软件

http://nginx.org

配置和安装

./configure –prefix=/usr/local/nginx –with-pcre=/software/nginx/pcre-8.32 –with-http_ssl_module –with-http_stub_status_module –with-http_sub_module

make

make install

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

 
在 nginx.conf 的 server 中添加 :
rewrite_log on;
 error_log logs/rewrite.error.log notice; #可以查看rewrite是否正确

5、启动 Nginx

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

出现如下则正确:

/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

解决办法如下:

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

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

更多Nginx相关教程见以下内容

Nginx 的详细介绍请点这里
Nginx 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2015-08/121383.htm
今日推荐