下载安装
[kevin@hadoop112 software]$ tar -zxvf nginx-1.18.0.tar.gz
# 可能使用到root权限,安装完成依赖记得使用回普通用户
[root@hadoop112 software]$ yum -y install openssl openssl-devel pcre pcre-devel zlib zlib-devel gcc gcc-c++
[kevin@hadoop112 software]$ cd nginx-1.18.0
[kevin@hadoop112 nginx-1.18.0]$ ./configure --prefix=/opt/module/nginx-1.18.0
[kevin@hadoop112 nginx-1.18.0]$ make && make install
# nginx占用80端口,默认情况下非root用户不允许使用1024以下端口
[kevin@hadoop112 nginx-1.18.0]$ cd /opt/module/nginx-1.18.0
[kevin@hadoop112 nginx-1.18.0]$ sudo setcap cap_net_bind_service=+eip /opt/module/nginx-1.18.0/sbin/nginx
[kevin@hadoop112 nginx-1.18.0]$ cd /opt/module/nginx-1.18.0
# 启动命令
[kevin@hadoop112 nginx-1.18.0]$ cd sbin/
[kevin@hadoop112 sbin]$ ./nginx
# 关闭命令
[kevin@hadoop112 sbin]$ ./nginx -s stop
# 重启
[kevin@hadoop112 sbin]$ ./nginx -s reload
[kevin@hadoop112 sbin]$ ln -s /usr/local/lib/libpcre.so.1 /lib64
[kevin@hadoop112 sbin]$ cd /opt/module/nginx-1.18.0/conf/
[kevin@hadoop112 conf]$ vim nginx.conf
http{
..........
upstream logserver{
server hadoop112:8080 weight=1;
server hadoop113:8080 weight=1;
server hadoop114:8080 weight=1;
}
server {
listen 80; #监听端口
server_name localhost; #域名
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost; #域名
proxy_connect_timeout 10;
}
..........
}
[kevin@hadoop112 sbin]$ ps -ef | grep nginx
kevin 21040 1 0 18:13 ? 00:00:00 nginx: master process ./nginx
kevin 21041 21040 0 18:13 ? 00:00:00 nginx: worker process
kevin 21044 20975 0 18:13 pts/2 00:00:00 grep nginx
网友评论