linux centos 6.4 安装nginx

来源:互联网 发布:mysql级联删除sql语句 编辑:程序博客网 时间:2024/04/27 16:08

一、安装文件准备

1、nginx 安装包nginx-1.10.1.tar.gz

2、nginx模块依赖包:

           1).gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )
2).rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
3).ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )
    

依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包

二、安装

 下一步,编译安装

openssl 

[root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz

[root@localhost] cd openssl-fips-2.0.9

[root@localhost] ./config && make && make install

pcre:

[root@localhost] tar zxvf pcre-8.36.tar.gz

[root@localhost] cd pcre-8.36

[root@localhost]  ./configure && make && make install

zlib:

[root@localhost]tar zxvf zlib-1.2.8.tar.gz

[root@localhost] cd zlib-1.2.8

[root@localhost]  ./configure && make && make install

最后安装nginx

[root@localhost]tar zxvf nginx-1.8.0.tar.gz

[root@localhost] cd nginx-1.8.0

[root@localhost]  ./configure && make && make install

三、启动

启动命令:/usr/local/nginx/sbin/nginx
发现报错了:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
经网上查询,这是linux的通病

[root@localhost nginx]# sbin/nginx 
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx   
                           
先找到libpcre.so.1所在位置,然后做个软链接就可以了。
查看是否已启动:

ps:

启动:/usr/local/nginx/sbin/nginx
停止/重新加载:/usr/local/nginx/sbin/nginx -s stop(quit、reload)
验证配置文件是否合法:/usr/local/nginx/sbin/nginx -t
命令帮助:/usr/local/nginx/sbin/nginx -h
0 0
原创粉丝点击