安装依赖
yum -y install pcre-devel openssl-devel zlib-devel
创建用户和组
groupadd nginx
useradd -r -g nginx -s /bin/false nginx
编译安装
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module --with-http_ssl_module --with-http_flv_module
make && make install
配置为服务
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
nginx –t
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: 2345 99 20
# description: Nginx Server Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 (start|stop|restart|reload)"
exit 1
esac
exit 0
问题1
问题描述:
make[1]: *** [/home/zcty/nginx-1.15.1/auto/lib/openssl/.openssl/include/openssl/ssl.h] 错误 127
解决方案:
打开nginx源文件下的/usr/local/src/nginx-1.15.1/auto/lib/openssl/conf文件:
找到这么一段代码:
CORE_INCS="OPENSSL/.openssl/include"
CORE_DEPS="OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="OPENSSL/.openssl/lib/libcrypto.a"
CORE_LIBS="NGX_LIBDL"
修改成以下代码:
CORE_INCS="OPENSSL/.openssl/include"
CORE_DEPS="OPENSSL/include/openssl/ssl.h"
CORE_LIBS="OPENSSL/lib/libssl.a"
CORE_LIBS="OPENSSL/lib/libcrypto.a"
CORE_LIBS="NGX_LIBDL"
然后再进行Nginx的编译安装即可
网友评论