Nginx、keepalived安装详细步骤

一、Nginx安装

1.选择文件夹/opt(个人喜好),安装依赖pcre,下载太慢请用yum安装,下面有命令

wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz

2.解压pcre压缩包

tar -xvf pcre-8.37.tar.gz

3.在pcre目录下输入命令

./configure如果失败了,需要提前安装一下c++编译器,输入命令yum -y install gcc-c++,回车,即可。

./configure
make && make install

4.检查是否安装成功

pcre-config --version

 如果下载很慢或下载完tar解压错误可以使用yum安装prce

[root@zabbix-c /]# yum list | grep pcre
pcre.x86_64                                 8.32-17.el7                @anaconda
pcre-devel.x86_64                           8.32-17.el7                @base    
pcre-static.x86_64                          8.32-17.el7                @base    
pcre-tools.x86_64                           8.32-17.el7                @base    
pcre.i686                                   8.32-17.el7                base     
pcre-devel.i686                             8.32-17.el7                base     
pcre-static.i686                            8.32-17.el7                base     
......
yum install pcre pcre-devel pcre-static pcre-tools

5.安装其他依赖

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

6.下载nginx安装包

下载地址:https://nginx.org/en/download.html

下载对应版本的tar.gz压缩包,用Xftp上传到Centos中。

7.解压nginx压缩包

tar -xvf nginx-1.12.2.tar.gz

8.进入nginx目录

./configure

如果是作为zabbix被控端,编译时需要带上./configure --with-http_stub_status_module 模块,如果不是,请忽略这句话。

make && make install

9.启动nginx服务

在、usr/local目录下自动生成nginx目录,启动路径是/usr/local/nginx/sbin,在该目录下,输入./nginx,成功开启nginx。

注意,真正的配置文件在/usr/local/nginx/目录,并不是在下载的安装包中,安装包中只是事例而已。

cd /usr/local/nginx/sbin
./nginx

10.打开防火墙端口

此处默认使用的端口是80端口。

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload

查看已经开启的端口

firewall-cmd --list-all

 成功访问nginx主页

[root@zabbix-c sbin]# curl http://localhost:80



Welcome to nginx!



Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

关闭nginx服务

./nginx -s stop

二、keepalive安装

1.yum安装

如果发生软件安装包报错,缺少Percona-XtraDB-Cluster-shared-55-5.5.37-25.10.756.el6.x86_64.rpm这个包

#声明,如果没有报错,请不要输入此段代码,按照下面yum正常安装即可。
wget http://www.percona.com/redir/downloads/Percona-XtraDB-Cluster/5.5.37-25.10/RPM/rhel6/x86_64/Percona-XtraDB-Cluster-shared-55-5.5.37-25.10.756.el6.x86_64.rpm
rpm -ivh Percona-XtraDB-Cluster-shared-55-5.5.37-25.10.756.el6.x86_64.rpm
yum install keepalived -y

2.检查是否安装成功

rpm -q -a keepalived

你可能感兴趣的:(运维,nginx,nginx,运维)