Centos7 安装nginx1.14
一丶官网 http://nginx.org/en/download.html 至于安装那个版本首先要看清楚版本代表什么意思

Nginx官网提供了三个类型的版本
Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以说是开发版
Stable version:最新稳定版,生产环境上建议使用的版本(毫无疑问,生产环境用于次版本)
Legacy versions:遗留的老版本的稳定版
编译安装前所需要的准备:
1.GCC编译器
首先检查GCC是否安装,命令:gcc -v ,如果显示有相关版本信息,则说明已经安装好,没有就安装:
yum install -y gcc # -y参数表示一直确认安装
2.PCRE库
Nginx的HTTP模块要用它来解析正则表达式。
yum install -y pcre pcre-devel
pcre-devel是使用PCRE做二次开发时所需要的开发库。类似的你可以想到安装LAMP时安装的php-devel。
3.zlib库
gzip格式的压缩会用到它。
yum install -y zlib zlib-devel
4.OpenSSL库
yum install -y openssl openssl-devel wget http://nginx.org/download/nginx-1.14.0.tar.gz #这里安装的是1.14.0生产稳定版本
解压安装
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0/
./configure --prefix=/usr/local/nginx --pid-path=/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre #生成 Makefile,为下一步的编译做准备
make #编译
make install #安装
附(Nginx部分控制命令):
默认Nginx安装在/usr/local/nginx/中,因此
/usr/local/nginx/sbin/nginx #默认启动方式 start
/usr/local/nginx/sbin/nginx -t #测试配置信息
/usr/local/nginx/sbin/nginx -v #显示版本信息,-V(大V)显示编译时的参数
/usr/local/nginx/sbin/nginx -s stop #快速停止服务
/usr/local/nginx/sbin/nginx -s quit #正常停止服务
- /usr/local/nginx/sbin/nginx -s reload #重启
Q: nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
A: [root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

如果不行记得要打开端口
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
可选 创建方便启动命令
创建nginx启动命令脚本
vi /etc/init.d/nginx
插入以下内容:
#! /bin/bash
# chkconfig: - 85 15
PATH=/usr/local/nginx
DESC="nginx daemon"
NAME=nginx
DAEMON=$PATH/sbin/$NAME
CONFIGFILE=$PATH/conf/$NAME.conf
PIDFILE=$PATH/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
设置执行权限 chmod a+x /etc/init.d/nginx
注册成服务 chkconfig --add nginx
设置开机启动 chkconfig nginx on
Centos7 安装nginx1.14的更多相关文章
- (转)CentOS7安装Nginx1.14.2
原文:https://blog.csdn.net/zhyfyz/article/details/84957381 https://blog.csdn.net/q85795362/article/det ...
- 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 ...
随机推荐
- 王之泰201771010131《面向对象程序设计(java)》第四周学习总结
王之泰201771010131<面向对象程序设计(java)>第四周学习总结 第一部分:理论知识学习部分 第四章 1.类与对象的基础概念. a.类(class)是构造对象的模板或蓝图.由类 ...
- luogu2046[NOI2010]海拔 对偶图优化
luogu2046[NOI2010]海拔 对偶图优化 链接 https://www.luogu.org/problemnew/show/P2046 思路 海拔一定是0或者1,而且会有一条01交错的分界 ...
- 阿里技术专家详解Dubbo实践,演进及未来规划
https://mp.weixin.qq.com/s/9rVGHYfeE8yM2qkSVd2yEQ
- 一些有趣的 js 包
https://github.com/octalmage/robotjs Node.js桌面自动化.控制鼠标,键盘和屏幕. http://robotjs.io
- requests SSLError: hostname 'ccc.xxx.com' doesn't match '*.b0.upaiyun.com'
证书不匹配问题 1.对于python自带的 urllib库 解决办法 import ssl ssl.match_hostname = lambda cert, hostname: True 2. 对 ...
- 【文献07】基于MPC的WMR点镇定-极坐标系下和轨迹跟踪
参考: Kuhne F , Lages W , Silva J D . Point stabilization of mobile robots with nonlinear model predic ...
- js之获取元素最终css属性
很多时候 我们是不用jquery库的,虽然他很好,获取元素最终的css属性我们可以用:getComputedStyle window.getComputedStyle(element, null).g ...
- 数组和List以指定的方式拼接成字符串类型
/// <summary> /// list转换成格式的字符串 /// </summary> /// <param name="param">拼 ...
- ubuntu文档保存出现的一些错误
ubuntu使用vim编辑器保存时,出现了错误,虽然知道基本的保存方法,但是还不够,出现各种错误.基本的保存命令: 写入文件后退出保存:wq后,保存时出现错误E45:已设定选项“readonly”(请 ...
- 最近使用Navicat for MySQl访问远程mysql数据库,出现报错,显示“2003- Can't connect MySQL Server on 'localhost'(10038)“。
优先考虑mysql数据库是否开启 1.先看报错窗口. 通过百度,最终找到的原因是:远程3306端口未对外开放. 于是下面进行远程3306端口开放操作. 首先远程连接服务器,点击“开始”-“管理 ...