Nginx服务搭建

###配置环境

Linux A 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

nginx版本:nginx-1.6.2.tar.gz

1、nginx安装之前关闭selinux 关闭防火墙iptables;

2、nginx 官方网站 http://nginx.org/  (注意找stable稳定版本)

3、跟新yum源:此处是阿里的yunm源

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 

3、安装准备(包括gcc、pcre-devel、zlib-devel)

    yum install pcre* -y

    yum install openssl openssl-devel -y

------------------------------------------------------------------------------------------

pcre简介:

Pcre全称(Perl Compatible Regular Expressions),中文perl兼容正则表达式;

官方站点为http://www.pcre.org/,安装 pcre 库是为了使 Nginx 支持 HTTP Rewrite模块。

编译pcre安装方法:

#wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz

wget http://sourceforge.net/projects/pcre/files/pcre/8.30/pcre-8.30.tar.gz

tar zxf pcre-8.30.tar.gz

cd pcre-8.30/

./configure

make && make install

cd ../

如果安装完后需要重装pcre,则需要rm -fr /usr/local/share/man/man3/pcre*


===================================nginx==================================================

4、创建用户:useradd -s /sbin/nologin -M nginx

5、下载nginx软件包

    wget -q http://nginx.org/download/nginx-1.6.2.tar.gz

6、解压tar xf nginx-1.6.2.tar.gz后编译

    ./configure  

    --user=nginx 

    --group=nginx 

    --prefix=/application/nginx1.6.2 

    --with-http_stub_status_module 

    #启用nginx stub_status模块,以监控nginx的当前状态 

    --with-http_ssl_module 

    --with-pcre=/home/oldboy/tools/pcre-8.30

-------------------------------------------------------------------------------------------

    cd nginx-1.6.2

    ./configure  --user=nginx --group=nginx --prefix=/application/nginx1.6.2 --with-http_stub_status_module  --with-http_ssl_module

    echo $?

    make && make install

    echo $?

-------------------------------------------------------------------------------------------

7、创建软连接

    ln -s /application/nginx1.6.2/ /application/nginx

8、检查语法启动nginx

    /application/nginx/sbin/nginx -t

    /application/nginx/sbin/nginx

    netstat -lntup|grep nginx

9、如果启动报错:
    /application/nginx1.6.2/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

    解决:find / -name "*libpcre.so*"

        /lib64/libpcre.so.0
        /lib64/libpcre.so.0.0.1
        /root/pcre-8.30/.libs/libpcre.so.1
        /root/pcre-8.30/.libs/libpcre.so
        /root/pcre-8.30/.libs/libpcre.so.1.0.0
        /usr/lib64/libpcre.so
        /usr/local/lib/libpcre.so.1
        /usr/local/lib/libpcre.so
        /usr/local/lib/libpcre.so.1.0.0

    把路径/usr/local/lib/添加到vi /etc/ld.so.conf使用ldconfig
生效即可。




本文出自 “思想大于技术” 博客,谢绝转载!

你可能感兴趣的:(nginx,服务搭建)