(转)CentOS7安装Nginx1.14.2
原文:https://blog.csdn.net/zhyfyz/article/details/84957381
https://blog.csdn.net/q85795362/article/details/82891997-----centos7编译安装nginx1.14.0
https://blog.csdn.net/qq_32828933/article/details/82715798---CentOS 7.5 编译安装 Nginx 1.15.3
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++
安装pcre和pcre-devel
yum install -y pcre pcre-devel
安装zlib zlib提供了很多压缩和解方式,nginx需要zlib对http进行gzip
yum install -y zlib zlib-devel
安装openssl openssl是一个安全套接字层密码库,nginx要支持https,需要使用openssl
yum install -y openssl openssl-devel
下载nginx
wget http://nginx.org/download/nginx-1.14.2.tar.gz
解压
tar -zxvf nginx-1.14.2.tar.gz
1
cd到文件路径
cd nginx-1.14.2
编译
./configure --prefix=/application \
--sbin-path=/application/nginx/sbin/nginx \
--conf-path=/application/nginx/conf/nginx.conf \
--error-log-path=/application/nginx/logs/error.log \
--pid-path=/application/nginx/nginx.pid \
--lock-path=/application/nginx/nginx.lock \
--user=nginx \
--group=nginx \
--with-openssl=/usr/local/bin/openssl \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/application/nginx/logs/access.log \
--http-client-body-temp-path=/application/nginx/client \
--http-proxy-temp-path=/application/nginx/proxy \
--http-fastcgi-temp-path=/application/nginx/fcgi \
--with-http_stub_status_module
安装
make && make install
创建开机启动命令脚本文件
vim /etc/init.d/nginx
插入启动脚本代码
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/application/nginx/sbin/nginx" #对应编译安装时的sbin-path
prog=$(basename $nginx)
NGINX_CONF_FILE="/application/nginx/conf/nginx.conf"
[ -f /application/nginx/sbin/nginx ] && /application/nginx/sbin/nginx -t
lockfile=/application/nginx/nginx.lock
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
保存
:wq
设置所有人都有对这个启动脚本nginx文件的执行权限
chmod a+x /etc/init.d/nginx
把nginx加入系统服务中
chkconfig --add nginx
如果出现 [emerg] mkdir() “/var/temp/nginx/client” failed (2: No such file or directory) 错误 执行
sudo mkdir -p /var/tem/nginx/client
检查nginx配置是否成功
nginx -t
启动
nginx
重启
nginx -s reload
如果您正在运行防火墙,请运行以下命令以允许HTTP和HTTPS通信:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
至此服务器配置完成。
(转)CentOS7安装Nginx1.14.2的更多相关文章
- Centos7 安装nginx1.14
一丶官网 http://nginx.org/en/download.html 至于安装那个版本首先要看清楚版本代表什么意思 Nginx官网提供了三个类型的版本Mainline version:Main ...
- CentOS7 安装nginx-1.14.0
nginx源码包:http://nginx.org/en/download.html 1.安装gcc gcc是用来编译下载下来的nginx源码 yum install gcc-c++ 2.安装pcre ...
- Centos7安装Nginx1.14.0
一.官网下载 http://nginx.org/en/download.html 版本说明: Nginx官网提供了三个类型的版本 Mainline version:Mainline 是 Nginx 目 ...
- 编译安装和apt安装Nginx1.14.0
安装依赖 yum -y install gcc gcc-c++yum -y install zlib zlib-devel openssl openssl-devel pcre-devel 在Ubun ...
- centos7.6 安装nginx-1.14.2
一.安装所需依赖环境 yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 二.下载nginx官方源 ...
- CentOS 安装Nginx1.14.0
原文地址:http://www.cnblogs.com/ascd-eg/p/9275441.html 一.安装所需环境 1.gcc 安装 yum install gcc-c++ ...
- ubuntu16.04源码编译安装nginx1.14.2
1.下载nginx-1.14.2, 官网地址:nginx.org 2.解压nginx-1.14.2.tar.gz tar zxvf nginx-1.14.2.tar.gz 3.切到文件夹nginx-1 ...
- centos7.5下yum安装nginx-1.14.2
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm ...
- CentOS7安装Nginx-1.9.9+PHP5.6
linux系统CentOS7 Nginx 下载地址http://nginx.org/en/download.html wget下载路径http://nginx.org/download/nginx-1 ...
随机推荐
- ActiveMQ实战之 Queue点对点消息
前言:ActiveMQ消息模式点对点编码 运行:先运行消费者在开启消息生产者即可接收到消息 消息生产者 /** * @摘要 测试发送单条数据的类 */ public class ZMQOneSendT ...
- Redis集群的主从切换研究
目录 目录 1 1. 前言 1 2. slave发起选举 2 3. master响应选举 5 4. 选举示例 5 5. 哈希槽传播方式 6 6. 一次主从切换记录1 6 6.1. 相关参数 6 6.2 ...
- share pool 管理机制
Library cache是Shared pool的一部分,它几乎是Oracle内存结构中最复杂的一部分,主要存放shared curosr(SQL)和PLSQL对象(function,procedu ...
- 卷积神经网络(CNN)之一维卷积、二维卷积、三维卷积详解
作者:szx_spark 由于计算机视觉的大红大紫,二维卷积的用处范围最广.因此本文首先介绍二维卷积,之后再介绍一维卷积与三维卷积的具体流程,并描述其各自的具体应用. 1. 二维卷积 图中的输入的数据 ...
- hdu 5083 有坑+字符串模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=5083 机器码和操作互相转化 注意SET还要判断末5位不为0输出Error #pragma comment(lin ...
- Effective C++ 第二版 31)局部对象引用和函数内new的指针 32)推迟变量定义
条款31 千万不要返回局部对象的引用, 不要返回函数内部用new初始化的指针的引用 第一种情况: 返回局部对象的引用; 局部对象--仅仅是局部的, 在定义时创建, 在离开生命空间时被销毁; 所谓生命空 ...
- Ubuntu12.04 root用户登录设置
ubuntu12.04默认是不允许root登录的,在登录窗口只能看到普通用户和访客登录.以普通身份登录Ubuntu后我们需要做一些修改. 1.普通用户登录后,修改系统配置文件需要切换到超级用户模式,在 ...
- AngularJS $watch 性能杀手
双向绑定是AngularJS核心概念之一,它给我们带来了思维的转变,不再是以DOM为驱动,而是以Model为核心,View中写上声明式标签(指令或{{}}),AngularJS会在后台默默同步View ...
- poj 2531 搜索剪枝
Network Saboteur Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u ...
- 在Delphi中处理word文档与数据库的互联
在Delphi中处理word文档与数据库的互联 ---- 目前,Delphi被越来越多的人选中作为MIS系统开发中的前台工具.在以Delphi为前台,一些大型数据库为后台的MIS系统中,图形的处理不可 ...