注:安装问题请参考文章最后!
1.服务器版本
# lsb_release -a
LSB Version: :core-4.1 -amd64:core-4.1 -noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5 .1804 (Core)
Release: 7.5 .1804
Codename: Core
2.下载Nginx相关:lua-nginx-module
# cd /home/install-files/
# wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
# wget https://github.com/openresty/lua-nginx-module/archive/v0.10.10.tar.gz
# wget http://nginx.org/download/nginx-1.14.0.tar.gz
# ls
LuaJIT-2.0 .5 .tar .gz nginx-1.14 .0 .tar .gz v0.10 .10 .tar .gz
3.安装LuaJIT
# tar zxvf LuaJIT-2.0.5.tar.gz -C /usr/local/src
# cd /usr/local/src/LuaJIT-2.0.5/
# make && make install
4.配置环境变量
# vim /etc/profile
注:最后添加
export LUAJIT_LIB=/usr/local /lib
export LUAJIT_INC=/usr/local /include /luajit-2.0
注:生效环境变量
# source /etc/profile
5.创建目录、用户、组
# mkdir -p /usr/local/nginx
# groupadd nginx
# useradd nginx -g nginx -d /usr/local/nginx -s /sbin/nologin
6.编译安装nginx
# cd /home/install-files/
# tar zxvf nginx-1.14.0.tar.gz
# ls
lua-nginx-module -0.10 .10 nginx-1.14 .0
# cd nginx-1.14.0
./configure --user=nginx --group =nginx --prefix=/usr/local/nginx --with -http_realip_module --with -http_v2_module --with -http_stub_status_module --with -http_ssl_module --with -http_flv_module --with -http_gzip_static_module --with -pcre --with -stream --add-module =../lua-nginx-module -0.10 .10 /
# make && make install
# chown -R nginx:nginx /usr/local/nginx
7.查看和检查nginx安装
# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.14 .0
# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14 .0
built by gcc 4.8 .5 20150623 (Red Hat 4.8 .5 -28 ) (GCC)
built with OpenSSL 1.0 .2 k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --user=nginx --group =nginx --prefix=/usr/local/nginx --with -http_realip_module --with -http_v2_module --with -http_stub_status_module --with -http_ssl_module --with -http_flv_module --with -http_gzip_static_module --with -pcre --with -stream --add-module =../lua-nginx-module -0.10 .10 /
# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# /usr/local/nginx/sbin/nginx
8.设置开机启动
8.1.设置开机启动脚本(自定义)可执行权限:
# chmod +x /opt/script/autostart.sh
# cat autostart.sh
# /usr/local/nginx/sbin/nginx
8.2.打开/etc/rc.d/rc/local文件,在末尾增加:
# /opt/script/autostart.sh
8.3.在centos7中,/etc/rc.d/rc.local的权限被降低了,需要执行命令赋予其可执行权限:
# chmod +x /etc/rc.d/rc.local
successfully.
附录1:
Error :/usr/local/nginx/sbin/nginx : error while loading shared libraries: libluajit-5.1 .so.2 : cannot open shared object file: No such file or directory
ln -s /usr/local/lib/libluajit-5.1 .so.2 /lib64/libluajit-5.1 .so.2
其他下载:
wget http://zlib.net /zlib-1.2 .11 .tar .gz
wget ftp://ftp.csx .cam .ac .uk /pub/software/programming/pcre/pcre-8.40 .tar .gz
wget http://www.openssl .org /source/openssl-1.0 .1 j.tar .gz
指定目录:
nginx -- prefix= /usr/local /nginx -- user= nginx -- group = nginx -- with -openssl = /nginx/openssl- 1.0 .2 l -- with -pcre = /nginx/pcre- 8.41 -- with -zlib = /nginx/zlib- 1.2 .8 -- with -http_ssl_module -- with -http_stub_status_module -- with -http_realip_module -- with -http_gzip_static_module -- with -http_flv_module