Centos下Nginx源码安装与配置并附shell编程实现自动化安装
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Centos下Nginx源码安装与配置并附shell编程实现自动化安装,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2620字,纯文字阅读大概需要4分钟。
内容图文
一、首先安装必要的库 nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库。选定/usr/local为安装目录,以下具体版本号根据实际改变。 1.安装PCRE库 $ cd /usr/local/ $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz $ tar -zxvf pcre-8.36.tar.gz $ cd pcre-8.36 $ ./configure $ make $ make install 2.安装zlib库 $ cd /usr/local/ $ wget http://zlib.net/zlib-1.2.8.tar.gz $ tar -zxvf zlib-1.2.8.tar.gz $ cd zlib-1.2.8 $ ./configure $ make $ make install 3.安装ssl $ cd /usr/local/ $ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz $ tar -zxvf openssl-1.0.1j.tar.gz $ ./config $ make $ make install 二、安装nginx $ cd /usr/local/ $ wget http://nginx.org/download/nginx-1.12.2.tar.gz $ tar -zxvf nginx-1.12.2.tar.gz $ cd nginx-1.12.2 $ ./configure --prefix=/usr/local/nginx $ make $ make install 在--prefix后面接以下命令: --with-pcre=/usr/local/pcre-8.36 指的是pcre-8.36 的源码路径。 --with-zlib=/usr/local/zlib-1.2.8 指的是zlib-1.2.8 的源码路径。 三、shell安装脚本 脚本中可以选定版本号,支持库包是以yum方式在线安装的#!/bin/bash #-------------------------------------------------------- # Function: Install nginx for CentOS7 # Date: 2018-1-06 # Author: Anwar Wong #-------------------------------------------------------- #Print debug information ? NGINX_VER="$?" NGINX_SOFT="nginx-${NGINX_VER}.tar.gz" NGINX_URL="http://nginx.org/download" NGINX_DIR="/usr/local/nginx" NGINX_SRC=`echo $NGINX_SOFT| sed 's/.tar.*//g'` NGINX_YUM="yum install -y" NGINX_ARG="--user=www --group=www --with-http_stub_status_module --with-http_ssl_module" ? ? if [$? -eq 0]; then echo -e "\033[32m-----------------\033[0m" echo -e "\033[32mUsage:{/bin/bash $0 1.2.3|1.12.2}\033[0m" exit 0 fi #Installing dependencies $NGINX_YUM wget make tar gcc gcc-c++ glibc zlib zlib-devel $NGINX_YUM perl perl-devel pcre pcre-devel openssl openssl-devel ? #Downloading wget -c $NGINX_URL/$NGINX_SOFT tar -xzf $NGINX_SOFT cd $NGINX_SRC ? #Creating user and group useradd -s /sbin/nologin www ? #Starting install nginx ./configure --prefix=$NGINX_DIR/$NGINX_ARG ? #Compile nginx make -j4 make -j4 install ? #Starting Nginx $NGINX_DIR/sbin/nginx ? #Show nginx status ps -ef |grep nginx netstat -tnlp |grep nginx 四、启动 $ /usr/local/nginx/sbin/nginx 检查是否启动成功: 打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。 部分命令如下: 重启: $ /usr/local/nginx/sbin/nginx –s reload 停止: $ /usr/local/nginx/sbin/nginx –s stop 测试配置文件是否正常: $ /usr/local/nginx/sbin/nginx –t 强制关闭: $ pkill nginx ? -----------未完待续-------------
内容总结
以上是互联网集市为您收集整理的Centos下Nginx源码安装与配置并附shell编程实现自动化安装全部内容,希望文章能够帮你解决Centos下Nginx源码安装与配置并附shell编程实现自动化安装所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。