Linux系列之Nginx搭建教程

2022-05-07 16:15:05 浏览数 (1)

##【keepalived安装】 下载keepalived到/usr/local/src tar -xzvf keepalived-1.2.19.tar.gz cd /usr/local/src/keepalived-1.2.19 ###配置 ./configure --prefix=/usr/local/keepalived

编译

make && make install ###复制建立服务启动脚本,以便使用service命令控制之: cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/ chmod x /etc/init.d/keepalived cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ mkdir /etc/keepalived cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

启动keepalived

service keepalived start|stop

##【nginx安装】 nginx安装之前要先安装pcre、openssl、zlib 注意:./configure --prefix=/usr/local/keepalived configure:error:!!! OpenSSL is not properly installed on your system. !!! !!! Can not include OpenSSL headers files. 解决方法:安装openssl,同时pcre也一起安装一下,gcc、zlib没有安装也可以安装一下 yum -y install pcre pcre-devel openssl openssl-devel zlib* gcc ###解压 下载nginx到/usr/local/src tar -xzvf nginx-1.11.4.tar.gz cd nginx-1.11.4

执行配置文件

./configure

编译

make && make install

启动

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

重启

cd /usr/local/nginx/sbin ./nginx -s reload

检验配置文件是否正确

检验: ps -ef|grep nginx /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf 或者 cd /usr/local/nginx/sbin ./nginx -t

0 人点赞