centos7 编译安装nginx1.16.0( 完整版 )

一、安装依赖包

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

  依赖包说明:

1、编译依赖 gcc 环境,所以需要:gcc gcc-c++;

2、PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库,所以需要:pcre pcre-devel ;

3、zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库,所以需要:zlib zlib-devel ;

4、OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库,所以需要:openssl openssl-devel ;

二、从官网下载安装包

wget https://nginx.org/download/nginx-1.16.0.tar.gz

三、解压并安装

tar zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
./configure --prefix=/usr/local/nginx
make && make install

四、测试安装是否成功

[[email protected] ~]# nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx

五、启动nginx服务

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

六、验证服务是否启动成功

[[email protected] sbin]# netstat -ntlp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      349/nginx: master 

七、添加nginx服务

vi /lib/systemd/system/nginx.service

  将以下内容插入:

[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

八、以服务的方式启动nginx

pkill nginx
systemctl start nginx

九、查看服务是否启动

[[email protected] sbin]# systemctl status nginx
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-04-29 23:19:39 EDT; 18min ago
  Process: 348 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 349 (nginx)
    Tasks: 2
   Memory: 976.0K
   CGroup: /system.slice/nginx.service
           ├─349 nginx: master process /usr/local/nginx/sbin/nginx
           └─350 nginx: worker process

Apr 29 23:19:39 localhost.localdomain systemd[1]: Starting nginx...
Apr 29 23:19:39 localhost.localdomain systemd[1]: Started nginx.
[[email protected] sbin]# netstat -ntlp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      349/nginx: master p 

十、配置nginx服务自动启动

[[email protected] sbin]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

原文地址:https://www.cnblogs.com/yyxianren/p/10795120.html

时间: 2024-08-29 12:56:58

centos7 编译安装nginx1.16.0( 完整版 )的相关文章

centos6.5安装nginx1.16.0

参考:   centos7 编译安装nginx1.16.0( 完整版 ) https://blog.csdn.net/weixin_37773766/article/details/80290939   nginx安装好后,无法通过ip进行访问 1.安装依赖环境 yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 提示需要root权限,使用root权限安装完成: 2.下载nginx  :

二、Ubuntu下编译安装Nginx1.8.0

    在Ubuntu下搭建LNMP环境.编译安装mysql,nginx,php.最后在LNMP前提下安装composer,并且安装laravel框架.首先,第二步开始编译安装Nginx1.8.0 1.先进入"/usr/local/src"文件夹中,接着键入 "sudo wget http://nginx.org/download/nginx-1.8.0.tar.gz"回车,等待下载完毕.下载完毕后,执行"sudo tar zxvf nginx-1.8.0

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14

转载自http://www.osyunwei.com/archives/7891.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止firewall systemc

CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13

CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 二.配置防火墙,开启80端口.3306端口1    vi/etc/sysconfig/iptables #编辑防火墙配置文件1    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80

基于CentOS6.5环境之下的LNMP之编译安装Nginx1.8.0 stable(稳定版)

LNMP之编译安装Nginx1.8.0 stable(稳定版) 1.yum安装nginx所欲要的生存环境,也就是库文件 yum -y install make gcc gcc-c++ glibc glibc-devel automake autoconf libtool make 2.给nginx添加系统用户 useradd -s /sbin/nologin -M -r nginx 3.解压安装nginx1.8.0 tar xf nginx-1.8.0.tar.gz  cd nginx-1.8.

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享

一.配置防火墙,开启80端口.3306端口CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙.1.关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/ipta

Centos7编译安装nginx1.15+MariaDB10.3+php-7.2

环境准备: yum源:wget -c http://mirrors.163.com/.help/CentOS7-Base-163.repo -O /etc/yum.repo.d/CentOS7-Base-163.repo 下载软件包: wget -c https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.3.9/source/mariadb-10.3.9.tar.gz wget -c http://nginx.org/download/

centos7 编译安装gcc5.4.0

安装依赖 yum groupinstall "Development Tools" yum install -y glibc-static libstdc++-static wget 下载源码 下载源码可以用不同的gcc镜像,我这里用这个美国的下载比较稳定,如果镜像不好用的话可以去 http://www.gnu.org/software/gcc/mirrors.html 找下合适的镜像进行下载 wget http://www.netgull.com/gcc/releases/gcc-5

CentOS7编译安装nginx-1.8.1和编译参数

Web服务器Nginx LNMP是一组众所周知的Web网站服务器架构环境,即由Linux+Nginx+MySQL+PHP(MySQL有时也指 Mariadb)组合成一个高性能.轻量.稳定.扩展性强的Web网站服务器架构环境. Nginx ("engine x") 作为Web服务器软件,是一个轻量级.高性能的HTTP和反向代理服务器,负 载均衡服务器,及电子邮件IMAP/POP3/SMTP 服务器.Nginx性能稳定.功能丰富.运维简单.效率高 .并发能力强.处理静态文件速度快且消耗系统