Loading

nginx linux 安装

nginx linux 安装

进入http://nginx.org/en/download.html 下载

n  gcc

       安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:

yum install gcc-c++

n  PCRE

       PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。

yum install -y pcre pcre-devel

注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。

n  zlib

       zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。

yum install -y zlib zlib-devel

 n  openssl

       OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。

       nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。

yum install -y openssl openssl-devel

 

第一步:把nginx的源码上传到linux系统

第二步:把压缩包解压缩。

第三步:进行configure。

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi

 

注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录

第四步:make

第五步:make install

================================================================

学习了:https://www.cnblogs.com/jimisun/p/8057156.html  脱水版;

===================================================================

学习了:https://www.cnblogs.com/taiyonghai/p/6728707.html

如果不能联网,需要手动安装;

http://nginx.org/download/nginx-1.14.0.tar.gz
https://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
http://zlib.net/zlib-1.2.11.tar.gz
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

openssl  : ./config && make && make install
pcre: ./configure && make && make install
zlib: ./configure && make && make install
nginx: ./configure && make && make install
ln -s /usr/local/lib/libpcre.so.1 /lib64
使用whereis nginx进行nginx目录的查找,在/usr/local/nginx

如果需要增加stream模块,需要增加--with-stream命令

nginx: ./configure --with-stream
make
make install

 

posted @ 2018-06-06 09:44  stono  阅读(160)  评论(0编辑  收藏  举报