目录
如果提示 ./configure: error: the HTTP rewrite module requires the PCRE library. 需要安装 pcre库
如果提示./configure: error: the HTTP gzip module requires the zlib library.
下载ngin包不用多说了
- 上传nginx安装包到服务器
登入 root 账号
进入: cd /usr/local/ 这是安装路径 你们可以自行找安装路径
-
安装
- 在/usr/local/路径下执行
-
mkdir nginx
- 新建nginx文件架
- 解压上传到nginx的安装包:
-
tar -xzvf nginx-1.20.0.tar.gz -C /usr/local/nginx/
- 解压到 /usr/local/nginx/
- 进入解压目录 cd /usr/local/nginx/nginx-1.20.0/
- 执行
-
./configure --with-http_gzip_static_module --with-http_stub_status_module
- 我这里是安装了 --with-http_gzip_static_module 和 --with-http_stub_status_module资源包
- 如果不需要的话直接执行
-
./configure
- --prefix=/usr/local/nginx就是你指定安装路径 默认安装目录就是当前解压路径
- 然后执行 make
make
等上面执行完了以后执行
make install
忘了截图
然后进入 安装目录 默认安装目录就是当前解压路径
-
修改系统配置
- 执行
vi /etc/profile
添加配置
#nginx
export PATH=/usr/local/nginx/sbin:$PATH
执行刷新配置
source /etc/profile
-
启动nginx
- 进入 sbin目录 cd sbin
- 执行
./nginx
- 查看进程 ps -ef | grep nginx
如果提示 ./configure: error: the HTTP rewrite module requires the PCRE library. 需要安装 pcre库
- 上传pcre库到服务器
- 解压上传到pcre的安装包:
-
tar -xzvf pcre-8.45.tar.gz
- 进入解压文件架 cd pcre-8.45
- 执行 ./configure
-
./configure
安装完成后
- 进行编译先执行make
- 然后执行 make install
如果提示./configure: error: the HTTP gzip module requires the zlib library.
- 则需要安装 zlib库
- 解压上传的zlib库
-
tar -xzvf zlib-1.2.13.tar.gz
- 进入 解压文件 cd zlib-1.2.13
- 执行 ./configure
- 执行make
- 执行 make install
-
从新安装 第一步即可
-
集群搭建
默认有三台服务器10.192.80.20 10.192.80.21 10.192.80.22 ,对外服务器为 20服务器
修改20服务器配置文件
- 修改对外nginx服务器配置文件 vi /usr/local/nginx/conf/nginx.conf
在http{} 添加
upstream text{
server IP:端口;
server IP:端口;;
}
upstream text的text与proxy_pass 后的配置一样
打马部分为10.192.80.21 10.192.80.22 2个ip 修改的配置文件是 20服务器
服务器关闭 SELINUX
vi /etc/selinux/config
集群nginx 关闭 SELINUX=enforcing 改为 disabled;
不用刷新