linux安装nginx 简单版
1安装依赖包
安装pcre
yum install pcre*
安装openssl
yum install openssl*
安装zlib
yum install zlib
yum install zlib-devel
安装gcc
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
2安装nginx
下载
wgt http://nginx.org/download/nginx-1.19.0.tar.gz
解压缩。
tar -xvzf nginx-1.19.0.tar.gz
检查编译
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/opt/soft/openssl-1.1.1g
(其中/opt/soft/openssl-1.1.1g是你本地安装的openssl路径,如果不加这些参数,则编译通过但 make时报错No rule to make target `/usr/local/ssl/include/openssl/ssl.h', needed by `objs/src/core/nginx.o'. Stop.)
编译
make
安装
make install
make出现如下错误时
[root@localhost nginx-1.19.1]# make
make -f objs/Makefile
make[1]: Entering directory `/opt/nginx-1.19.1'
cd /usr/local/ssl \
&& if [ -f Makefile ]; then make clean; fi \
&& ./config --prefix=/usr/local/ssl/.openssl no-shared no-threads \
&& make \
&& make install_sw LIBDIR=lib
/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/ssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `/opt/nginx-1.19.1'
make: *** [build] Error 2
解决方案
找到/opt/nginx/nginx-1.19.1/auto/lib/openssl/conf 中
CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL//.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
CORE_LIBS="$CORE_LIBS $NGX_LIBPTHREAD"
改为 (去掉多余/.openssl)
CORE_INCS="$CORE_INCS $OPENSSL/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"
CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
CORE_LIBS="$CORE_LIBS $NGX_LIBPTHREAD"