编译安装和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 ...
随机推荐
- ssm回顾笔记(一)
这两天来到了农银,这边即将进行的一个项目是将ssh框架的电商项目迁移到springboot+ssm框架上,所以我基本上是三门技术在同时进行学习,当然以前学过ssm,现在只是回顾. spring 注解 ...
- dump总结
•http://blog.csdn.net/lkforce/article/details/60878295 •日志文件生成 •方法1 •jmap -dump:format=b,file=201703 ...
- Java 设置PDF文档背景——单色背景、图片背景
一般生成的PDF文档默认的文档底色为白色,我们可以通过一定方法来更改文档的背景色,以达到文档美化的作用. 以下内容提供了Java编程来设置PDF背景色的方法.包括2种设置方法: 设置纯色背景色 设置图 ...
- 力扣(LeetCode) 821. 字符的最短距离
给定一个字符串 S 和一个字符 C.返回一个代表字符串 S 中每个字符到字符串 S 中的字符 C 的最短距离的数组. 示例 1: 输入: S = "loveleetcode", C ...
- MySQL5.5安装教程
登录MySQL:mysql -uroot -p密码 退出MySQL:exit | quit 查看数据库:show datab ...
- nova相关操作的Request_Id的获取
在分析nova的众多log文件时,如nova-api,nova-scheduler,nova-compute等,其中的request id是串联起整个flow的关键词. 而通过nova instanc ...
- android ------ RecyclerView 模仿淘宝购物车
电商项目中常常有购物车这个功能,做个很多项目了,都有不同的界面,选了一个来讲一下. RecyclerView 模仿淘宝购物车功能(删除选择商品,商品计算,选择, 全选反选,商品数量加减等) 看看效果图 ...
- MYSQL 总结——2
1.mysql限制显示条目数:Limit, Offset 图片网址:https://sqlbolt.com/lesson/filtering_sorting_query_results 实例: SE ...
- 『TensorFlow』0.x_&_1.x版本框架改动汇总
基本数值运算 除法和模运算符(/,//,%)现在匹配 Python(flooring)语义.这也适用于 [tf.div] 和 [tf.mod].要获取基于强制整数截断的行为,可以使用 [tf.trun ...
- grpc(一)grpc-java之helloworld
1.参考资料 (1)grpc-java官网QuickStart: https://grpc.io/docs/quickstart/java.html (2)grpc-java的github: http ...