PS:root权限编译哦~
./configure --prefix=http://www.likecs.com/etc/nginx --sbin-path=http://www.likecs.com/usr/sbin/nginx --modules-path=http://www.likecs.com/usr/lib64/nginx/modules --conf-path=http://www.likecs.com/etc/nginx/nginx.conf --error-log-path=http://www.likecs.com/var/log/nginx/error.log --http-log-path=http://www.likecs.com/var/log/nginx/access.log --pid-path=http://www.likecs.com/var/run/nginx.pid --lock-path=http://www.likecs.com/var/run/nginx.lock --http-client-body-temp-path=http://www.likecs.com/var/cache/nginx/client_temp --http-proxy-temp-path=http://www.likecs.com/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=http://www.likecs.com/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=http://www.likecs.com/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=http://www.likecs.com/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' 3.2.3.进行编译安装接着编译安装:make && make install
PS:提速:make -j 4 && make install
3.2.4.配置systemctl利用systemctl添加自定义系统服务
# vi /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network-online.target remote-fs.target nss-lookup.target Wants=network-online.target [Service] Type=forking PIDFile=http://www.likecs.com/var/run/nginx.pid ExecStart=http://www.likecs.com/usr/sbin/nginx -c /etc/nginx/nginx.conf ExecReload=http://www.likecs.com/bin/kill -s HUP $MAINPID ExecStop=http://www.likecs.com/bin/kill -s TERM $MAINPID [Install] WantedBy=multi-user.targetPS:如果不生效可以重载下systemctl:systemctl daemon-reload
3.2.5.端口放行放行80端口:firewall-cmd --zone=public --add-port=80/tcp --permanent
PS:规则生效:firewall-cmd --reload
3.2.6.验证运行的时候如果出现nginx: [emerg] getpwnam("nginx") failed的错误可以参考我写这篇文章:https://www.cnblogs.com/dotnetcrazy/p/11304783.html
PS:核心:useradd -s /sbin/nologin -M nginx
3.3.编译安装Lua模块 大体思路默认是不支持Lua的,所以需要自己编译安装下
PS:记得安装下Lua库:yum install lua lua-devel -y
主要就3步走:
安装Lua即时编译器:LuaJIT
目前最新:
安装Nginx模块:ngx_devel_kit and lua-nginx-module
ngx_devel_kit:https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.tar.gz
lua-nginx-module:https://github.com/openresty/lua-nginx-module/archive/v0.10.15.tar.gz
重新编译Nginx:复制在线安装的编译参数(nginx -V)然后添加两个参数
--add-module=../ngx_devel_kit-0.3.1
--add-module=../lua-nginx-module-0.10.15
3.3.1.编译安装luajit并导入环境变量解压缩