【运维技术】Nginx安装教程(yum安装,源码编译)
安装方式
- yum直接更新源安装
- 源码直接编译之后安装
使用yum进行直接安装
Installing a Prebuilt CentOS/RHEL Package from an OS Repository
- Install the EPEL repository:
$ sudo yum install epel-release
- Update the repository and install NGINX Open Source:
$ sudo yum update
- Install Nginx
$ sudo yum install nginx
- Verify the installation:
$ sudo nginx -v
nginx version: nginx/1.6.3
源码直接编译之后安装
注意点,centos默认需要先安装c以及c++的的编译环境执行命令,在继续后续的操作
$ yum -y install gcc
$ yum -y install gcc-c++
一、安装nginx依赖
- PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
$ tar -zxf pcre-8.41.tar.gz
$ cd pcre-8.41
$ ./configure
$ make
$ sudo make install
- zlib – Supports header compression. Required by the NGINX Gzip module.
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./configure
$ make
$ sudo make install
- OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.
$ wget http://www.openssl.org/source/openssl-1.0.2k.tar.gz
$ tar -zxf openssl-1.0.2k.tar.gz
$ cd openssl-1.0.2k
$ ./Configure darwin64-x86_64-cc --prefix=/usr
$ make
$ sudo make install
遇到问题死都安装不上去,所以使用yum的包进行安装了
yum -y install openssl openssl-devel
二、获取源码,编译源码
- 可以通过官方网站获取版本,我们这边获取的是stable版本,使用脚本处理
$ wget http://nginx.org/download/nginx-1.13.4.tar.gz
$ tar zxf nginx-1.13.4.tar.gz
$ cd nginx-1.13.4
- Configuring the Build Options
这些都是nginx的相关配置,但是还是有具体配置参考项目Configuring the Build Options
$ ./configure
--sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-pcre=../pcre-8.41
--with-zlib=../zlib-1.2.11
--with-http_ssl_module
--with-stream
--with-mail=dynamic
--add-module=/usr/build/nginx-rtmp-module
--add-dynamic-module=/usr/build/3party_module
- Completing the Installation from Source
编译安装
$ make
$ sudo make install
- 启动
# 启动nginx
$ sudo nginx
# 启动nginx(守护模式进程常驻)
$ sudo nginx
# 停止nginx
$ nginx pid file: "/usr/local/nginx/logs/nginx.pid"
$ sudo kill `cat /usr/local/nginx/logs/nginx.pid`
- 卸载nginx
# 方式一:https://unix.stackexchange.com/questions/22708/how-to-uninstall-nginx-installed-from-source
$ sudo rm -f -R /usr/local/nginx && rm -f /usr/local/sbin/nginx
# 方式二:https://serverfault.com/questions/645110/how-to-uninstall-nginx-on-centos7
$ make uninstall
- 安装两个nginx
一般一台服务器不会安装两个nginx的,但是特殊情况会,所以一个使用源码编译安装,一个使用yum源安装
编译的时候使用命令切换路径
./configure --prefix=/usr/local/nginx2 --sbin-path=/usr/local/nginx2/nginx2 --conf-path=/usr/local/nginx2/nginx.conf --pid-path=/usr/local/nginx2/nginx.pid
- 安装路径
- 启动bin路径
- 配置路径
- pid路径
遇到问题
- 源码安装的时候,yum update docker的镜像的使用十分慢,所以我进行了一段时间的等待,但是依旧没有处理完
解决方案,yum update的时候排除某些。http://blog.51cto.com/pizibaidu/1342925
yum update --exclude=docker-ce*
- 发现启动后,有两个进程
按照进程号的关系判断,master和worker的进程是一定有关联关系的,删除master即可
参考网址
root 30870 1 0 16:10 ? 00:00:00 nginx: master process nginx
nginx 30871 30870 0 16:10 ? 00:00:00 nginx: worker process
root 31028 8302 0 16:13 pts/0 00:00:00 grep --color=auto nginx
直接使用命令启动
$ nginx
使用命令停止启动
$ systemctl stop nginx
$ systemctl start nginx
参考
【运维技术】Nginx安装教程(yum安装,源码编译)的更多相关文章
- WordPress安装篇(5):源码编译安装LNMP并部署WordPress
与YUM方式安装相比,源码编译安装方式更灵活,安装过程中能自定义功能和参数,特别是在批量部署服务器又要求软件版本及配置一致时,源码编译安装的优势很明显.本文介绍如何通过源码编译方式安装Nginx1.1 ...
- 【运维技术】CentOS7上从零开始安装阿里RocketMQ版本:release-4.0.1【亲测哈哈】
CentOS7上从零开始安装阿里RocketMQ版本:release-4.0.1[亲测哈哈] 安装git # 更新包 $ yum update # 安装git $ yum install git # ...
- Centos7通过yum跟源码编译安装Nginx
源码编译安装 http://nginx.org/en/download.html 到官网下载,然后用XFTP上传到root目录 把文件解压出来 tar -zxvf nginx-1.16.0.tar.g ...
- nginx在centos 7中源码编译安装【添加grpc的支持】
安装依赖软件 1.安装编译工具gcc gcc是一个开源编译器集合,用于处理各种各样的语言:C.C++.Java.Ada等,在linux世界中是最通用的编译器,支持大量处理器:x86.AMD64.Pow ...
- 【运维技术】CentOS7上从零开始安装LAMP安装织梦DedeCMS教程
前期准备数据 centos7 系统 安装 appache httpd # 更新httpd yum update httpd # 安装httpd yum install -y httpd # 启动服务 ...
- 运维监控之zabbix(yum安装)
简介 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位 ...
- hadoop2.2伪分布安装加2.2源码编译
配置linux基本环境: --> java.ip.hostname.hosts.iptables.chkconfig.ssh环境配置 hadoop2.2安装在linux64位机器上,需要对源码进 ...
- CentOS6.5一键安装MySQL5.5.32(源码编译)
###################################################mysql_install.sh ...
- centos-rpm安装的mariadb,php52源码编译安装时注意点
1.不要静态指定with-mysql 以扩展的mysql.so的形式安装 2.找不到header file之类的 要yum install mysql-devel find / -name mysql ...
- Linux运维-zabbix_agent最新版的yum安装
agentd端可以直接使用yum来进行安装 rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1. ...
随机推荐
- 在联网时,两台linux服务器传输文件方法
登陆服务器root用户命令:su - root 传输文件命令:scp +需要传输linux系统文件+空格+目标linux服务器的用户名@服务器ip地址:+传输的文件路径:例:scp /mnt/work ...
- OpenGL开发环境简介
基于OpenGL标准开发的应用程序运行时需有动态链接库OpenGL32.DLL.Glu32.DLL,这两个文件在安装Windows NT时已自动装载到C:\WINDOWS\SYSTEM32目录下(这里 ...
- 微信小程序 this.setData 修改json里面的值
page({ data:{ s1:{a:"",b:"b"} }, changeData:function(e){ var cData=this.data.s1; ...
- [直观学习排序算法] 视觉直观感受若干常用排序算法 以及 iOS 资料
http://www.zhfish.net/?s=点击范围 1 快速排序 介绍: 快速排序是由东尼·霍尔所发展的一种排序算法.在平均状况下,排序 n 个项目要Ο(n log n)次比较.在最坏状况下则 ...
- 网络子系统46_ip协议数据帧的转发
//调用路径ip_rcv->ip_rcv_finish->dst_input->(skb->dst->input) //ip_forward以回调函数的形式,保存在skb ...
- java中的Iterator和Iterable 区别
java.lang.Iterable java.util.Iterator 来自百度知道: Iterator是迭代器类,而Iterable是接口. 好多类都实现了Iterable接口,这样对象就可以调 ...
- LeetCode——Power of Two
Description: Given an integer, write a function to determine if it is a power of two. public class S ...
- 解决Chrome关联Html文件图标显示为空白
用记事本保存为ChromeHTML.reg Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\CLSID\{42042206-2D85-1 ...
- C# 计算当前时间距离今晚00:00:00还有多少分多少秒
.net 计算当前时间距离今晚00:00:00还有多少分多少秒 string dateDiff = null;//获取当前时间 DateTime DateTime1 = DateTime.Now; / ...
- nexus使用方法
转自:https://www.cnblogs.com/grey-wolf/p/6481166.html centos7搭建nexus maven私服 前置条件: 1.安装jdk,可参考 http: ...