一,nginx的官网:

http://nginx.org/

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

二,下载与解压nginx

1,下载

[root@centos8 source]# wget http://nginx.org/download/nginx-1.18.0.tar.gz

2,   解压缩

[root@centos8 source]# tar -zxvf nginx-1.18.0.tar.gz 

三,编译与安装nginx

1,configure

#--prefix 指定安装路径

#--with-http_stub_status_module    允许查看nginx状态的模块

# --with-http_ssl_module     支持https的模块

[root@centos8 nginx-1.18.0]# ./configure --prefix=/usr/local/soft/nginx-1.18.0 --with-http_stub_status_module --with-http_ssl_module

2,编译并安装

[root@centos8 nginx-1.18.0]# make && make install

四, configure报错的解决

说明:如果相应的软件包已安装不会报错,写在这里供参考

1,问题1,configure提示:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决:

[root@os3 nginx-1.18.0]# yum install pcre-devel

2,问题2,configure提示:

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

解决:

[root@os3 nginx-1.18.0]# yum install openssl openssl-devel 

五,测试编译安装的效果:查看nginx的版本

[root@centos8 nginx-1.18.0]# /usr/local/soft/nginx-1.18.0/sbin/nginx -v
nginx version: nginx/1.18.0

六,如何查看nginx的配置编译参数?

[root@centos8 nginx-1.18.0]# /usr/local/soft/nginx-1.18.0/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)
built with OpenSSL 1.1.1c FIPS 28 May 2019
TLS SNI support enabled
configure arguments: --prefix=/usr/local/soft/nginx-1.18.0 --with-http_stub_status_module --with-http_ssl_module

注意区分和上一条查看版本命令的区别: -v参数分别是小写和大写

七,使systemctl能管理运行nginx服务

1,运行的准备工作:配置日志目录

[root@centos8 conf]# mkdir /data/nginx
[root@centos8 conf]# mkdir /data/nginx/logs

2,运行的准备工作:创建nginx用户

[root@centos8 conf]# groupadd nginx

#-g:指定所属的group

#-s:指定shell,因为它不需要登录,所以用/sbin/nologin

#-M:不创建home目录,因为它不需要登录

[root@centos8 conf]# useradd -g nginx -s /sbin/nologin -M nginx 

3,简单配置nginx

[root@centos8 conf]# vi nginx.conf

内容:

指定运行nginx的用户和组是:nginx

user nginx nginx;

发生错误时要写入到错误日志(目录用上面创建好的)

error_log   /data/nginx/logs/error.log;

指定pid的路径

pid        logs/nginx.pid;

日志格式(取消注释即可)

   log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

指定访问日志的路径和格式(目录用上面创建好的)

  access_log  /data/nginx/logs/access.log  main;

4,生成service文件:

[root@centos8 ~]# vi /usr/lib/systemd/system/nginx.service

内容:

[Unit]
Description=nginx-The High-performance HTTP Server
After=network.target [Service]
Type=forking
PIDFile=/usr/local/soft/nginx-1.18.0/logs/nginx.pid
ExecStartPre=/usr/local/soft/nginx-1.18.0/sbin/nginx -t -c /usr/local/soft/nginx-1.18.0/conf/nginx.conf
ExecStart=/usr/local/soft/nginx-1.18.0/sbin/nginx -c /usr/local/soft/nginx-1.18.0/conf/nginx.conf
ExecReload=/usr/local/soft/nginx-1.18.0/sbin/nginx -s reload
ExecStop=/usr/local/soft/nginx-1.18.0/sbin/nginx -s stop
PrivateTmp=true [Install]
WantedBy=multi-user.target

5,启动服务

重新加载服务文件

[root@centos8 ~]# systemctl daemon-reload 

启动:

[root@centos8 ~]# systemctl start nginx

6,查看效果:

从浏览器访问安装机器的ip的80端口即可:

看例子截图:

7,查看日志目录

[root@centos8 conf]# ll /data/nginx/logs/
总用量 8
-rw-r--r-- 1 root root 1477 4月 22 18:49 access.log
-rw-r--r-- 1 root root 1195 4月 22 18:32 error.log

日志已成功写入

八,查看centos版本

[root@centos8 ~]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)

centos8平台编译安装nginx1.18.0的更多相关文章

  1. 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 一.配置好I ...

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

    准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7. ...

  3. CentOS7 编译安装 nginx-1.10.0

    对于NGINX 支持epoll模型 epoll模型的优点 定义: epoll是Linux内核为处理大批句柄而作改进的poll,是Linux下多路复用IO接口select/poll的增强版本,它能显著的 ...

  4. CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13+博客系统WordPress3.3.2

    说明: 操作系统:CentOS 6.2 32位 系统安装教程:CentOS 6.2安装(超级详细图解教程): http://www.osyunwei.com/archives/1537.html 准备 ...

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

    一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  6. ansible:安装nginx1.18.0(使用role功能)

    一,ansible使用role的用途? roles分别将变量/文件/任务/模板/handler等放置于单独的目录中, 并可以方便的include各目录下的功能 roles使playbook能实现代码被 ...

  7. centos7 安装 nginx-1.18.0 并设置开机自启动

    一.到官网下载nginx Mainline  version:  nginx主力版本,为开发版 Stable version: 稳定版,在生产环境中选择此版本进行安装 Legacy versions: ...

  8. centos7下编译安装nginx-1.16.0

    一.下载nginx源码 http://nginx.org/en/download.html 如:nginx-1.16.0.tar.gz 二.创建用户和组,并解压 groupadd www userad ...

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

    一.安装依赖包 yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 依赖包说明: 1.编译 ...

随机推荐

  1. oracle之同义词

    同义词 从字面上理解就是别名的意思,和视图的功能类似.就是一种映射关系. 14.1 私有同义词; 一般是普通用户自己建立的同义词,创建者需要create synonym 权限. sys:SQL> ...

  2. [程序员代码面试指南]递归和动态规划-机器人达到指定位置方法数(一维DP待做)(DP)

    题目描述 一行N个位置1到N,机器人初始位置M,机器人可以往左/右走(只能在位置范围内),规定机器人必须走K步,最终到位置P.输入这四个参数,输出机器人可以走的方法数. 解题思路 DP 方法一:时间复 ...

  3. Proxy使用详解

    文档:Proxy 基本使用就不赘述,看文档即可 通用 1.Proxy可以包装任何形式的对象:包括原生数组,函数,甚至另一个代理 2.代理实例中没有指定的handler,实际就是操作原对象target: ...

  4. (数据科学学习手札95)elyra——jupyter lab最强插件

    本文示例文件已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 jupyter lab是我最喜欢的编辑器,在过往 ...

  5. 关于弹性布局flex

    什么时候使用flex布局? 当页面排版涉及左右浮动.垂直居中等时,应使用flex布局来避免传统的盒式布局带来的一些Bug. 如何使用flex布局? 在目标元素的父元素设置csss属性.display: ...

  6. PHP基础之面向对象篇

    前言 前面写的都是运算符.流程控制.排序查找等,下面说一说面向对象的一些内容.这是前面写的,有兴趣可以去看一看. PHP入门之类型与运算符 PHP入门之流程控制 PHP入门之函数 PHP入门之数组 P ...

  7. 一文读懂MySQL的索引结构及查询优化

    回顾前文: 一文学会MySQL的explain工具 (同时再次强调,这几篇关于MySQL的探究都是基于5.7版本,相关总结与结论不一定适用于其他版本) MySQL官方文档中(https://dev.m ...

  8. 搜索引擎学习(一)初识Lucene

    一.Lucene相关基础概念 定义:一个简易的工具包,实现文件搜索的功能,支持中文,关键字,多条件查询,凡是文件名或文件内容包含的都查出来. 数据分类:结构化数据(固定格式或有限长度的数据)和非结构化 ...

  9. GEKCTF2020-web

    GEKCTF [GKCTF2020]CheckIN97 <title>Check_In</title> <?php highlight_file(__FILE__); c ...

  10. Java环境变量配置 新手必备

    第一步:安装JDK,无脑下一步 建议修改安装路径 这里以jdk1.7为例子(之前帮机房安装软件,五六十台电脑都要用1.7); 2.安装完了之后右击此电脑,打开属性 打开系统高级设置 打开环境变量 这里 ...