1.安装工具和库

# PCRE是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式

# zlib库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip

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

2.目录结构

源码目录:/home/werben/pkgsrc/nginx
安装目录:/home/werben/application/nginx

3.下载解压源码

# 官网地址: https://nginx.org/en/download.html
wget -c https://nginx.org/download/nginx-1.17.5.tar.gz

4.创建用户组和用户

groupadd www
useradd -g www www

5.编译源码

./configure --user=www --group=www --prefix=/home/werben/application/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-pcre

make && make install

6.映射全局命令

ln -s /home/werben/application/nginx/sbin/nginx /usr/local/bin/nginx

7.启动,停止,重启

nginx -s stop
nginx -s quit
ngins -s reload

8.检测配置文件nginx.conf正确性

nginx  -t

9.开机自启动

vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart=nginx
ExecReload=nginx reload
ExecStop=nginx quit
PrivateTmp=true [Install]
WantedBy=multi-user.target
#重新加载守护进程
systemctl daemon-reload #启动nginx服务
systemctl start nginx.service
#停止nginx服务
systemctl stop nginx.service
#设置开机自启动
systemctl enable nginx.service
#停止开机自启动
systemctl disable nginx.service
#查看服务当前状态
systemctl status nginx.service
#重新启动服务
systemctl restart nginx.service
#查看所有已启动的服务
systemctl list-units --type=service

10.出现问题和解决方法

#如果`systemctl start nginx.service`提示如下报错

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details. #执行
systemctl status nginx.service
#如果出现如下错误
Process: 35783 ExecStart=...nginx/sbin/nginx(code=exitedstatus=203/EXEC)
nginx.service: Control process exited, code=exited status=203
systemd[1]: nginx.service: Failed with result 'exit-code'.
localhost.localdomain systemd[1]: Failed to start nginx. journalctl -xe #如果看到如下信息
If you believe that systemd should be allowed execute access on the>
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do allow this access for now by executing:
# ausearch -c '(nginx)' --raw | audit2allow -M my-nginx
# semodule -X 300 -i my-nginx.pp #解决方法
setenforce 0
vim /etc/selinux/config
SELINUX=disabled

centos8自定义目录安装nginx的更多相关文章

  1. centos8自定义目录安装php7.3

    1.目录结构 源码目录:/home/werben/pkgsrc/php-7.3.11 安装目录:/home/werben/application/php7.3.11 2.下载php源码 # 官网地址: ...

  2. CentOS7下自定义目录安装mono+jexus教程

    一.阅读前须知: 1.本文属于安装完Centos7之后的步骤 2.如果还不了解mono,请点击mono 3.本篇主要内容是使用自定义目录安装mono+jexus教程,使用默认目录请查看使用默认目录安装 ...

  3. CentOS7下默认目录安装mono+jexus教程

    一.阅读前须知: 1.本文属于安装完Centos7之后的步骤 2.如果还不了解mono,请点击mono 3.本篇主要内容是使用默认目录安装mono+jexus教程,使用自定义目录请查看使用自定义目录安 ...

  4. 记录使用yum安装nginx之后的目录问题

    一般来说我们安装nginx的目录都是/usr/local/nginx的,但是用yum安装的目录跟手动安装的不一样,下面是整理的使用yum安装的一些对应目录. nginx执行文件目录:/usr/sbin ...

  5. ubuntu安装nginx及其默认目录结构

    一. 安装包安装 1.1 安装Nginx $sudo apt-get install nginx Ubuntu安装之后的文件结构大致为: 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经 ...

  6. linux系统下nginx安装目录和nginx.conf配置文件目录

    linux系统下nginx安装目录和nginx.conf配置文件目录 1.查看nginx安装目录 输入命令 # ps  -ef | grep nginx 返回结果包含安装目录 root      26 ...

  7. centos8 安装 nginx

    http://nginx.org/ NGINX官网 创建文件夹mkdir nginx进入创建的文件夹 根据自己需要下载合适版本 通过 wget http://nginx.org/download/ng ...

  8. Centos7安装nginx后提示“Welcome to nginx on Fedora!”,conf.d目录下无default.conf文件

    问题描述 在腾讯云centos7上安装nginx sudo yum install nginx 打开默认网页显示 Welcome to nginx on Fedora! 且 /etc/nginx/co ...

  9. Centos7 设置自定义安装nginx的systemctl启动方式

    一.systemctl方式启动设置过程 1.首先创建服务配置文件(名字和路径就是这个) vim /usr/lib/systemd/system/nginx.service 2.添加配置内容 [Unit ...

随机推荐

  1. CF1197B

    CF1197B 题意: 出n个柱子,每个柱子一个圆盘,其半径各不相同,每次只能将柱子上只有一个圆盘的移到相邻位置,问能否全部移到一个柱子上. 解法: 思路题. 如果所有盘子都能移动到同一个柱子上,那么 ...

  2. 能不能支持在线查看word,excel这样的文件?还有拖拽上传功能?

    https://forum.enhancer.io/topic/5adea0cdce69735af635fcd8 方法1. 用一个自定义窗口, 自定义窗口里放一个iframe 假设你的 word 的地 ...

  3. 图解如何利用Intellij IDEA进行代码重构

    源:https://jingyan.baidu.com/article/c45ad29c64f7e7051653e27d.html 重命名类,打开 Refactor -> Rename 或 Sh ...

  4. Cesium入门-3-官方完整实例

    实例核心代码 //资源访问令牌 Cesium token Cesium.Ion.defaultAccessToken='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ ...

  5. Ubuntu无法找到add-apt-repository问题的解决方法

      网上查了一下资料,原来是需要 python-software-properties 于是 apt-get install python-software-properties 除此之外还要安装 s ...

  6. go一个简单的爬虫(豆瓣)

    最近在学习go语言爬虫,写了个小demo package main import ( "fmt" "io/ioutil" "net/http" ...

  7. python包中__init__.py文件的作用

    python包中__init__.py文件的作用 __init__.py文件最常用的作用是标识一个文件夹是一个 python包. __init__.py文件的另一个作用是定义模糊导入时要导入的内容. ...

  8. windows/Linux 下安装coreseek/sphinx

    2013年12月8日 17:26:26 注意的地方: 1.配置文件的 数据源, 索引, 服务 这3处配置的路径要写成windows识别的路径,最好是绝对路径 2.安装windows服务的时候,可以不带 ...

  9. 阶段5 3.微服务项目【学成在线】_day05 消息中间件RabbitMQ_4.RabbitMQ研究-安装RabbitMQ

    RabbitMQ由Erlang语言开发,Erlang语言用于并发及分布式系统的开发,在电信领域应用广泛,OTP(Open Telecom Platform)作为Erlang语言的一部分,包含了很多基于 ...

  10. 消息队列之ActiveMQ学习笔记(二、C#实例实现)

    ActiveMQ提供多种语言支持,如Java, C, C++, C#, Ruby, Perl, Python, PHP等.此处列举C#实例 下述C#实例代是基于QUEUE的P2P方式,如需要实现TOP ...