1.配置配置阿里epel源和base

[root@localhost ~]$ wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]$ wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]$ ls /etc/yum.repos.d/
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo         CentOS-Media.repo      CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo    epel.repo

2.安装nginxrpm

wget http://nginx.org/download/nginx-1.23.3.tar.gz
#解压
tar -zxvf nginx-1.23.3.tar.gz
#安装依赖
yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel
#初始化
./configure 
--prefix=/usr/local/nginx 
--pid-path=/var/run/nginx/nginx.pid 
--lock-path=/var/lock/nginx.lock 
--error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log 
--with-http_gzip_static_module 
--http-client-body-temp-path=/var/temp/nginx/client 
--http-proxy-temp-path=/var/temp/nginx/proxy 
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi 
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi 
--http-scgi-temp-path=/var/temp/nginx/scgi
make
make install

3.启动nginx

[root@localhost /]# whereis nginx
nginx: /usr/local/nginx
[root@localhost /]# ./usr/local/nginx/sbin/nginx 
[root@localhost /]# ps -ef | grep nginx
root       7184      1  0 10:11 ?        00:00:00 nginx: master process ./usr/local/nginx/sbin/nginx
nobody     7185   7184  0 10:11 ?        00:00:00 nginx: worker process
root       7187   1773  0 10:11 pts/0    00:00:00 grep --color=auto nginx

4.关闭防火墙

[root@localhost /]# systemctl stop firewalld.service 
[root@localhost /]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost /]# vim /etc/selinux/config 
[root@localhost /]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled

5.测试是否访问成功

6.准备两台配置好的web服务器

192.168.40配置网站

192.168.0.50配置网站

 7.配置反向代理

修改配置文件

#重启服务
[root@localhost /]# /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
[root@localhost /]# /usr/local/nginx/sbin/nginx -s reload

 8.测试结果

访问反向代理服务器可以到达两个web服务器

 

 

原文地址:https://blog.csdn.net/hsxhaocai/article/details/130462493

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_27472.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注