您的位置:首页 > 运维架构 > Nginx

记Linux安装nginx的过程

2017-02-03 00:40 10 查看

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

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

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

tar -xvzf pcre-8.35

3、编译安装

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

5、查看pcre版本

pcre-config --version

三、安装 Nginx

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


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

tar -xvzf nginx-1.10.3.tar.gz

3、编译安装

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

4、查看ngnix版本

在nginx安装目录下

cd sbin
./nginx -v

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

yum -y install gcc gcc-c++

2、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

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

yum -y install openssl openssl-devel

4、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步中查找出来的目录

4、如果编译安装的时候,用这个命令

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

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

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

 

转载于:https://my.oschina.net/u/1420452/blog/831109

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: