centos下源码安装nginx

作者:admin 发布:2018-03-29 浏览:1662次

1.安装PCRE库

$ cd /usr/local/
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
$ tar -zxvf pcre-8.36.tar.gz
$ cd pcre-8.36
$ ./configure
$ make
$ make install

2.安装zlib库

$ cd /usr/local/ 
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./configure
$ make
$ make install

3.安装ssl

$ cd /usr/local/
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
$ tar -zxvf openssl-1.0.1j.tar.gz
$ ./config
$ make
$ make install

4.安装nginx

$ cd /usr/local/
$ wget http://nginx.org/download/nginx-1.13.10.tar.gz
$ tar -zxvf nginx-1.13.10.tar.gz
$ cd nginx-1.13.10  
$ ./configure --prefix=/usr/local/nginx 
$ make
$ make install

在--prefix后面接以下命令:

--with-pcre=/usr/local/pcre-8.38 指的是pcre-8.38 的源码路径。
--with-zlib=/usr/local/zlib-1.2.11 指的是zlib-1.2.11 的源码路径。
--with-zlib=/usr/local/openssl-1.0.1j 指的是openssl-1.0.1j 的源码路径。

添加环境变量:

修改/root/.bash_profile

blob.png

source /root/.bash_profile
nginx -s reload

nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

执行:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf


错误:

error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决:

如果是32位系统

[root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib

如果是64位系统

[root@lee ~]#  ln -s /usr/local/lib/libpcre.so.1 /lib64



Comments (0)