编译安装和apt安装Nginx1.14.0
安装依赖
yum -y install gcc gcc-c++yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
在Ubuntu 下, 对应openssl-devel的包是 libssl-dev
建立用户及用户组
groupadd -r nginx
# -r 表示创建的是系统组
useradd -s /sbin/nologin -g nginx -r nginx
# -r 表示创建的是系统用户
id nginx
# 即使用其他用户启动nginx, 也必须创建nginx用户和用户组, 否则会出现 nginx: [emerg] getpwnam("nginx") failed 错误
编译和安装
./configure --prefix=/opt/nginx/nginx-1.14. --user=nginx --group=nginx --with-http_gzip_static_module --with-pcre --with-http_ssl_module --with-http_flv_module --with-stream --with-stream_ssl_module --with-http_stub_status_module
make
make install
建立latest目录和软链, 方便将来替换为新版本
cd /opt/nginx/
ln -s nginx-1.14. latest
配置
将nginx加入系统服务
cd /lib/systemd/system/
vi 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
PIDFile=/var/run/nginx.pid
ExecStartPre=/opt/nginx/latest/sbin/nginx -t -c /opt/nginx/latest/conf/nginx.conf
ExecStart=/opt/nginx/latest/sbin/nginx
ExecReload=/opt/nginx/latest/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true [Install]
WantedBy=multi-user.target # 内容结束 systemctl enable nginx.service
打开端口启动服务
firewall-cmd --zone=public --list-all
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload # 启动nginx
systemctl start nginx
Ubuntu18.04下apt安装Nginx1.14.0
Ubuntu18.04下默认的nginx版本就是1.14.0, 可以直接通过 sudo apt install nginx 安装. 安装后会自动加入service并启动, 可以通过 sudo systemctl list-unit-files 检查
默认的配置文件位于 /etc/nginx/nginx.conf, 这是给Ubuntu定制的配置文件, 基础配置部分, 会加载 /etc/nginx/modules-enabled/*.conf , 在 http 部分, 会自动加载 include /etc/nginx/conf.d/*.conf 和 include /etc/nginx/sites-enabled/*, 这样方便用户通过 modules-enabled, modules-available 和 sites-enabled, sites-available 来管理可用站点.
从这里开始配置就和编译安装的一样了.
编译安装和apt安装Nginx1.14.0的更多相关文章
- CentOS 安装Nginx1.14.0
原文地址:http://www.cnblogs.com/ascd-eg/p/9275441.html 一.安装所需环境 1.gcc 安装 yum install gcc-c++ ...
- CentOS7 安装nginx-1.14.0
nginx源码包:http://nginx.org/en/download.html 1.安装gcc gcc是用来编译下载下来的nginx源码 yum install gcc-c++ 2.安装pcre ...
- Centos7安装Nginx1.14.0
一.官网下载 http://nginx.org/en/download.html 版本说明: Nginx官网提供了三个类型的版本 Mainline version:Mainline 是 Nginx 目 ...
- nginx1.14.0下载、安装、启动
nginx1.14.0下载及安装 wget http://nginx.org/download/nginx-1.14.0.tar.gztar -zxvf nginx-1.14.0.tar.gzcd n ...
- elementaryos5安装mysql5.7、php7.2、nginx1.14.0
一.mysql5.7 安装mysql5.7: sudo apt-get install mysql-server-5.7 查看安装的mysql版本: mysql -V 5.7版本mysql安装过程中以 ...
- 安装 error: Microsoft Visual C++ 14.0 is required 解决方案
最近写的项目需要用到Python的第三方库,比如:mmh3, pyshark等等,而直接pip install ... 会报错:error: Microsoft Visual C++ 14.0 is ...
- Nginx1.14.0+ModSecurity实现简单的WAF
一.编译安装Nginx 1.安装依赖环境 $ yum -y install gcc-c++ flex bison yajl yajl-devel curl-devel curl GeoIP-devel ...
- nginx1.14.0版本https加密配置
修改host文件,为最后访问域名准备 C:\Windows\System32\drivers\etc host文件目录192.168.10.140 www.joyce.com 在最后添加这个自定义域名 ...
- nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx.conf:36
nginx: [emerg] unknown directive "聽" in D:\software03\GitSpace\cms\nginx-1.14.0/conf/nginx ...
随机推荐
- 【2.0】使用默认日志slf4j配置
一.SpringBoot日志简介 SpringBoot使用Commons Logging进行所有内部日志记录,但底层日志实现保持开放状态.为Java Util Logging,Log4j2和Logba ...
- 论文笔记:Visual Question Answering as a Meta Learning Task
Visual Question Answering as a Meta Learning Task ECCV 2018 2018-09-13 19:58:08 Paper: http://openac ...
- centos7安装bbr
centos7安装bbr 安装 sudo wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.s ...
- vmware中虚拟化的问题
因为用的是Window系统,又不想换系统,所以在学习Linux时,使用的VMware来安装的Centos,想在VMware中安装KVM虚拟机,然后报错,说我没有打开虚拟化,我使用 的是Surface ...
- vscode之快速生成vue模板
文件-首选项-用户代码片段-搜索“vue”点击进入vue.json 复制这个片段 { "Vue component": { "prefix": "vu ...
- Django框架(三)
六.Django的视图层 视图函数 一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML ...
- nginx中try_files
location / { try_files $uri $uri/ /index.php?$query_string; } 当用户请求 http://localhost/example 时,这里的 $ ...
- easyui datebox时间控件如何只显示年月
easyui datebox控件,只显示年月,不显示年月日 需要的效果图如下: 具体的js代码: <script> $(function(){ intiMonthBox('costTime ...
- 不安全的HTTP方法(渗透实验)
1.使用 curl -v -X OPTIONS url(含目录) 获取允许访问的http method 例如:curl -v -X OPTIONS http://192.168.1.123:12123 ...
- leetcode python 030 Substring with Concatenation of All Words
## 您将获得一个字符串s,以及一个长度相同单词的列表.## 找到s中substring(s)的所有起始索引,它们只包含所有单词,## eg:s: "barfoothefoobarman&q ...