一、下载nginx源码

http://nginx.org/en/download.html

如:nginx-1.16.0.tar.gz

二、创建用户和组,并解压

groupadd www
useradd -g www www
tar xf nginx-1.16.0.tar.gz

  

三、下载openssl,编译高版本openssl

https://www.openssl.org/source/

如:openssl-1.0.2r.tar.gz

tar xf openssl-1.0.2r.tar.gz

  

四、编译安装nginx

cd nginx-1.16.0

./configure --prefix=/data/nmp/nginx \
--user=www \
--group=www \
--with-pcre \
--with-openssl=/data/openssl-1.0.2r \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module \

--with-openssl 的路径设置为第3步中openssl源码解压路径。

上面的有些模块大家可以按需安装。

make -j8 && make install

  

五、配置systemd服务

创建 nginx.service 文件

vi /usr/lib/systemd/system/nginx.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target [Service]
Type=forking
ExecStartPre=/data/nmp/nginx/sbin/nginx -t
ExecStart=/data/nmp/nginx/sbin/nginx -c /data/nmp/nginx/conf/nginx.conf
ExecReload=/data/nmp/nginx/sbin/nginx -s reload
ExecStop=/data/nmp/nginx/sbin/nginx -s stop
PrivateTmp=true [Install]
WantedBy=multi-user.target

启用 nginx.service

systemctl enable nginx.service

启动 nginx

systemctl start nginx.service

  

六、设置firewalld防火墙,开放80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

  

centos7下编译安装nginx-1.16.0的更多相关文章

  1. CentOS 6.5 下编译安装 Nginx 1.8.0

    转自:https://i.cnblogs.com/EditPosts.aspx?postid=8303227&update=1 安装编译依赖的包 yum -y install gcc gcc- ...

  2. Centos7下编译安装php扩展redis5.0.2

    安装环境:centos7 + php 7.2.191. 下载地址:http://pecl.php.net/get/redis-5.0.2.tgz .tgz http://pecl.php.net/ge ...

  3. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  4. CentOS7下编译安装redis-5.0.9

    CentOS7下编译安装redis-5.0.9 本文地址http://yangjianyong.cn/?p=171转载无需经过作者本人授权 下载redis #code start wget https ...

  5. ubuntu14.04下编译安装ambari-2.4.2.0

    ubuntu14.04下编译安装ambari-2.4.2.0 编译前的准备工作 准备工作有: 系统参数 系统依赖(编译环境) 离线安装包 java环境 maven环境 Nodejs环境 git环境 a ...

  6. Ubuntu 16.04源码编译安装nginx 1.10.0

    一.下载相关的依赖库 pcre 下载地址 http://120.52.73.43/jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.t ...

  7. 在CentOS 7下编译安装Nginx+PHP+MySQL环境

    本文转载自:http://www.softeng.cn/?p=156,本文已获得作者授权,未经作者同意,不可转载. 1.前言 本文适合于已经对Linux操作系统具有基本操作经验,并且能够在Linux或 ...

  8. linux下编译安装nginx

    1.首先下载稳定版nginx1.10.2 使用wget命令下载 wget http://nginx.org/download/nginx-1.10.2.tar.gz 2.然后解压 tar -zxvf  ...

  9. centos7 下 yum 安装Nginx

    centos7 下 yum 安装和配置 Nginx 添加yum源 Nginx不在默认的yum源中,可以使用epel或者官网的yum源,这里使用官网的yum源 rpm -ivh http://nginx ...

随机推荐

  1. CentOS 7修改系统时间及硬件时间

    转载于:https://www.cnblogs.com/LouisZJ/p/8554991.html [root@nginx ~]# timedatectl --help timedatectl [O ...

  2. TopSnackbar,在顶部滑出显示的Snackbar;

    TopSnackbar 既然你能找到这篇文章,说明你一定使用过或了解Snackbar,所以我就不介绍Snackbar了.嗯~有图有真相! 嗯,就是图上这样: 我把Snackbar的源码拉了过来,重写了 ...

  3. Postman 中上传图片的接口怎么做参数化呢?

    如题求教,麻烦回复在评论里,不胜感激~

  4. leetCode83. 删除排序链表中的重复元素

    给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次. 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: 输入: 1->1->2->3-&g ...

  5. Android 开发 启动activity并且将前面activity全部清空

    方法一: Intent intent = new Intent(A.this,B.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | I ...

  6. django之关联field 描述子是如何实现的

    model定义时,每个field都是一个类属性,一个对象.在生成类时,属性有contribute_to_class的方法,会调用该方法. m2m field,它会先调用自己的contribute_to ...

  7. 数据库sql使用小结

    1.更新数据库中表的字段的时候,如果更新的表本身含有最细粒度的字段,那么可以以最细粒度作为判断条件,一次性更新多个字段: 2.如果更新的表中本身不含有最细粒度字段,那么要更新多个字段时有两种思路: a ...

  8. 安装USB驱动时报错“无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动”

    今天在安装一个USB设备的时候报错“Windows已找到设备的驱动程序软件,但在试图安装它时遇到错误”. 这个错误的描述是“无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动”. 事实上,这个 ...

  9. 【C++】C++中int与string的相互转换

    一.int转string 1.c++11标准增加了全局函数std::to_string: string to_string (int val); string to_string (long val) ...

  10. 【C++】C++string类总结

    一.string的初始化 首先,为了在程序中使用string类型,必须包含头文件 <string>.如下: #include <string> 注意这里不是string.h,s ...