记Linux安装nginx的过程

1、需先确保linux上安装了这些工具linux

zlib、zlib-dev、gcc、openssl、libssl-dev(不一样linux下安装方式不同,请自行搜索对应安装方式)nginx

2、安装 PCRE
一、下载PCRE安装包,下载地址 https://sourceforge.net/projects/pcre/files/pcre/pcre-8.35
二、解压压缩包c++

tar -xvzf pcre-8.35

三、编译安装工具

cd pcre-8.35
./configure
make && make install

五、查看pcre版本ui

pcre-config --version

3、安装 Nginx.net

注意:下文中的nginx安装目录,不能是nginx-1.10.3这个目录。code


一、下载 Nginx,下载地址:http://nginx.org/download/nginx-1.10.3.tar.gz
二、解压压缩包ip

tar -xvzf nginx-1.10.3.tar.gz

三、编译安装ssl

cd nginx-1.10.3
./configure --prefix=nginx安装目录/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-pcre=pcre安装目录
make
make install

四、查看ngnix版本openssl

在nginx安装目录下

cd sbin
./nginx -v

安装过程可能会出现一些报错:
一、error: C compiler cc is not found 或者 configure: error: You need a C++ compiler for C++ support    没安装gcc。安装步骤:

yum -y install gcc gcc-c++

二、error: the HTTP gzip module requires the zliblibrary      没安装zlib相关软件。安装步骤:

tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=zlib安装目录
make && make install

三、./configure: error: SSL modules require the OpenSSL library    没安装openssl,openssl-devel。安装步骤:

yum -y install openssl openssl-devel

四、error while loading shared libraries: libpcre.so.1     这个错误会在nginx运行时候出现,接着按照如下步骤修复:
1)确保已经安装了openssl、libssl-dev、libssl
2)查找libpcre 的文件位置:

find / -name libpcre.so.1

3)修改环境变量,在/etc/profile文件的最后加上这一行:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

LD_LIBRARY_PATH后面的路径就填第2步中查找出来的目录

四、若是编译安装的时候,用这个命令

./configure --prefix=nginx安装目录

可能会出现如下错误:
cp:  'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file
那么将命令改成

./configure --prefix=nginx安装目录/nginx.conf
相关文章
相关标签/搜索