网站不收录,游艇网站建设方案,网站 被刷流量,北京旅游网站建设安装并启动nginx服务 1、二进制安装nginx包 ~ yum -y install epel-release yum -y install nginx
#配置环境 关闭防火墙
~ iptables -F // 或 systemctl stop filewallf 2、作为web服务修改配置文件 ~ vim /etc/nginx/nginx.conf //暂时不修改配置 3…安装并启动nginx服务 1、二进制安装nginx包 ~ yum -y install epel-release yum -y install nginx
#配置环境 关闭防火墙
~ iptables -F // 或 systemctl stop filewallf 2、作为web服务修改配置文件 ~ vim /etc/nginx/nginx.conf //暂时不修改配置 3、让配置生效验证配置 ~ systemctl start nginx //启动nginx服务
#systemctl disable firewalld 设置开机也不启动防火墙
#systemctl enable firewalld 开机启动防火墙
#systemctl enable nginx 开机启动nginx
#systemctl status nginx.service 查看nginx服务是否在运行
#systemctl reload nginx //重新加载配置文件
#nginx -s reload 安装并设置启用nfs服务 1、二进制安装nfs ~ yum -y install nfs 2、作为共享存储挂载在三台web的网站根目录下 nfs主机操作~ vim /etc/exports
~ cat /etc/exports
/Nfsdir 192.168.16.0/24(rw,sync,fsid0)
~ mkdir /Nfsdir
~ echo this is a shared directory /Nfsdir/index.html ~ chmod -R ow /Nfsdir //设置权限
~ systemctl start rpcbind.service //启动rpc服务
~ systemctl start nfs-server.service //启动nfs服务
~ exportfs //查看是nfs否开启成功
~ showmount -a //查看当前和那几个客户端有链接
~ showmount -e //默认查看自己的服务
~ systemctl status rpcbind.service //查看rpc是否在运行
~ systemctl status nfs-server.service //查看nfs服务是否在运行
~ vim /etc/nginx/nginx.conf //修改目录为Nfsdir
~ systemctl reload nginx //重新加载配置文件 ~ systemctl enable nfs-server.service // 设置开机启动nfs
~ systemctl enable rpc-rquotad.service //开机启动rpc nfs 客户端操作~ mount -t nfs 192.168.16.180:/Nfsdir /var/www/html
~ vim /etc/nginx/nginx.conf //修改目录为/var/www/html
~ systemctl reload nginx //nginx -s reload重新加载配置文件 实现在任意一台web上修改的结果其余两台都可以看到 nginx反向代理三台web 实现基于轮询的方式调度三台web并验证结果~ vim /etc/nginx/nginx.conf
http {upstream pythonweb {server 192.168.16.167;server 192.168.16.99:80;server 192.168.16.199;} 实现基于权重的方式调度三台web并验证结果~ vim /etc/nginx/nginx.conf
http {upstream pythonweb {server 192.168.16.167 weight3;server 192.168.16.99:80;server 192.168.16.199;} 实现基于hash的方式调用三台web并验证结果http {upstream pythonweb {ip_hash;server 192.168.16.167;server 192.168.16.99:80;server 192.168.16.199;} nginx反向代理三台webnfs共享存储实现集群配置 # 客户端修改网站根目录为/web
~ mount -t nfs 192.168.16.180:/Nfsdir /web // vim /etc/fstab 开机就挂载的设备
~ vim /etc/nginx/nginx.conf
~ systemctl reload nginx //重新加载配置文件
~ vim /etc/selinux/config //关闭硬件防火墙 改为disabled 需要重启
#setenforce 0 临时关闭防火墙不需要重启 vim /etc/fstab# /etc/fstab
# Created by anaconda on Wed Mar 8 22:54:46 2017
#
# Accessible filesystems, by reference, are maintained under /dev/disk
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID4b0a06e7-efa0-464e-b668-8d02da33c482 /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
#把共享nfs目录开机挂载公司环境会用到
192.168.16.180:/Nfsdir /web nfs defaults 0 0 源码安装nginx并按照作业一描述的那样去测试使用 下载nginx~ wget http://nginx.org/download/nginx-1.10.3.tar.gz
~ tar xvf nginx-1.10.3.tar.gz cd nginx-1.10.3 安装nginx~ ./configure --prefix/usr/local/nginx
#出现问题
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcrepath option. 安装yum -y install pcre-devel 解决问题~ yum -y install pcre-devel
~ ./configure //成功编译
~ make make install
~ vim /etc/nginx/nginx.conf /修改配置文件
~ systemctl start nginx 转载于:https://www.cnblogs.com/hyhnm/p/6592125.html