1、Nginx-1.19.6安装
# 安装依赖
$ yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
# 解压缩到/usr/local/src/
$ tar -zxvf nginx-1.19.6.tar.gz -C /usr/local/src/
# 进入解压后目录,编译
$ cd /usr/local/src/nginx-1.19.6/
$ ./configure --with-http_ssl_module --prefix=/usr/local/nginx
$ make
$ make install
nginx可执行文件的路径为/usr/local/nginx/sbin
#查看版本
$/usr/local/nginx/sbin/nginx -V
2、初步使用
2.1、配置nginx.conf
进入/usr/local/nginx/conf/nginx.conf
$ cd usr/local/nginx/conf/nginx.conf
$vim nginx.conf
修改端口:8081
proxy_pass http://www.baidu.com
#重启nginx:
$../sbin/nginx -s reload
2.2、postman访问
访问http://10.1.1.235:8081 会跳转到:http://www.baidu.com页面
期间遇到无法访问时,查看防火墙是运行状态,关闭防火墙
[root@loaclhost conf]# firewall-cmd --state
running
[root@loaclhost conf]# systemctl stop firewalld
[root@loaclhost conf]# firewall-cmd --state
not running