工作问题记录————CentOS6离线安装nginx和keepalived
1.下载 nginx 和 keepalived 安装包并传入虚拟机:
nginx 下载地址:http://nginx.org/download/
keepalived 下载地址:http://www.keepalived.org/download.html
使用 secureCRT 远程登录虚拟机,快捷键 Alt+P 打开文件传输,传入 nginx 和 keepalived 安装包:
mkdir /usr/local/nginx
mv /home/root/nginx-1.18.0.tar.gz /usr/local/nginx
mkdir /usr/local/keepalived
mv /home/root/keepalived-2.0.20.tar.gz /usr/local/keepalived
2.安装 nginx:
cd /usr/local/nginx
tar -zxvf nginx-1.18.0.tar.gz
cd ./nginx-1.18.0
##设置nginx配置信息
./configure --with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-mail \
--with-mail_ssl_module \
--with-stream
##安装nginx
make
make install
3.测试启动 nginx:
cd /usr/local/nginx/sbin
##开始nginx服务
./nginx
##查看nginx进程
ps –ef|grep nginx
##关闭nginx服务
./nginx -s stop
nginx 服务默认端口为 80。
4.安装 keepalived:
cd /usr/local/keepalived
tar -zxvf keepalived-2.0.20.tar.gz
cd keepalived-2.0.20/ && ./configure --prefix=/usr/local/keepalived
make && make install
安装 keepalived 需要安装 openssl 和 openssl-devel 依赖包。
5.将 keepalived 配置为系统服务:
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/keepalived-2.0.20/keepalived/etc/init.d/keepalived /etc/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/sbin/keepalived /usr/sbin/
ln -s /usr/local/keepalived/sbin/keepalived /sbin/
chkconfig keepalived on
6.开启 keepalived 服务:
service keepalived start
service keepalived stop