[root@nginx nginx-1.12.2]# sed -i '12a #include <openssl/sha.h>' /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c
[root@nginx nginx-1.12.2]# sed -i '12a #include <openssl/md5.h>' /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c
重新编译:
[root@nginx nginx-1.12.2]# make && make install
3.6 nginx命令全局执行设置
[root@nginx bin]# cd /usr/local/nginx/sbin/
[root@nginx sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
4. Nginx相关命令
4.1 版本查看
[root@nginx ~]# nginx -v
nginx version: nginx/1.12.2
4.2 查看加载的模块
[root@nginx ~]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
configure arguments: --add-module=/root/nginx-sticky-1.2.5/
4.3 启停命令
4.3.1 启动
[root@nginx nginx-1.12.2]# nginx
4.3.2 停止
[root@nginx nginx-1.12.2]# nginx -s stop
[root@nginx nginx-1.12.2]# nginx -s quit
4.3.3 动态加载
[root@nginx nginx-1.12.2]# ngins -s reload
4.3.4 测试配置文件nginx.conf正确性
[root@nginx ~]# 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
nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
nginx -s reload:动态加载,当配置文件nginx.conf有变化时执行该命令动态加载。
4.4 开机自启动
编辑/etc/rc.d/rc.local文件,新增一行/usr/local/nginx/sbin/nginx
[root@nginx rc.d]# cd /etc/rc.d
[root@nginx rc.d]# sed -i '13a /usr/local/nginx/sbin/nginx' /etc/rc.d/rc.local
[root@nginx rc.d]# chmod u+x rc.local
5. 更改默认端口
编辑配置文件/usr/local/nginx/conf/nginx.conf,将默认端口80修改为81:
[root@nginx ~]# view /usr/local/nginx/conf/nginx.conf
加载配置:
[root@nginx ~]# nginx -s reload
6. 访问Nginx
6.1 关闭防火墙
[root@nginx ~]# firewall-cmd --state
running
[root@nginx ~]# systemctl stop firewalld.service
[root@nginx ~]# firewall-cmd --state
not running
6.2 访问Nginx
:81
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx