Linux安装nginx和keepalived

时间:2022-12-19 11:08:44

1、nginx 下载:wget http://nginx.org/download/nginx-1.9.9.tar.gz

2、keepalived 下载wget http://www.keepalived.org/software/keepalived-1.3.0.tar.gz

  

3、安装依赖库文件: yum install pcre pcre-devel zlib zlib-devel

  

4、解压 nginx文件: tar -zxvf nginx-1.9.9.tar.gz -C /usr/local

  

5、进行configure配置: cd nginx-1.9.9 && ./configure --prefix=/usr/local/nginx

Linux安装nginx和keepalived

检查通过,表示正常。

Linux安装nginx和keepalived

  

出现以上错误,执行命令 yum -y install gcc gcc-c++ autoconf automake make

  

  

6、在 nginx-1.9.9 目录里编译安装: make && make install

  

7、启动nginx: /usr/local/nginx/sbin/nginx

关闭nginx: /usr/local/nginx/sbin/nginx -s stop

重启nginx: /usr/local/nginx/sbin/nginx -s reload

Linux安装nginx和keepalived

  

8、查看是否启动:

ps -ef|grep nginx

netstat -anp|grep 80http://192.168.74.155:80 看是否能打开欢迎页面

  

  

9、解压keepalived包:tar -zxvf /usr/local/software/keepalived-1.3.0.tar.gz -C /usr/local

155 166 机器都需要装

  

10、编译keepalived 需要依赖库 yum -install -y openssl openssl-devel

  

11、进行configure配置:cd keepalived-1.3.0/ && ./configure --prefix=/usr/local/keepalived

  

12、在 keepalived-1.3.0 目录中执行编译安装的命令: make && make install

Linux安装nginx和keepalived

出现以上错误: 执行 autoreconf -ivf 然后重新执行 make && make install

  

Linux安装nginx和keepalived

  

出现以上错误: 升级下glib解决 执行 yum update glib* 然后重新执行 make && make install 还是不行,就降低 keepalived版本

  

13、将keepalived安装成系统服务:

a、创建文件夹,将keepalived配置文件进行复制:

mkdir /etc/keepalived

cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

b、复制keepalived脚本文件 建立两个软链接:

cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

cp /usr/local/keepalived-1.3.0/keepalived/etc/init.d/keepalived /etc/init.d/

  

ln -s /usr/local/sbin/keepalived /usr/sbin/

ln -s /usr/local/keepalived/sbin/keepalived /sbin/

可以设置开机启动 执行命令:chkconfig keepalived on ,安装完毕

执行命令 service keepalived start

Linux安装nginx和keepalived