安装nginx的依赖包(pcre-devel openssl-devel)
yum install -y gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel
pcre:兼容perl语言正则表达式,perl compatible regular expressions
rewirte模块 参数信息(perl方式定义正则表达式)
openssl:ssh---openssh/openssl---https
总结:所有安装依赖软件,后面都要加上-devel
下载nginx软件
解压软件
tar -zxvf nginx-1.16.0.tar.gz
创建管理用户 www
useradd -M -s /sbin/nologin nginx
nginx软件编译安装过程
编译安装软件
1、配置软件,在软件的解压目录中
[root@web01 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx-1.16.0 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
编译参数说明:
--prefix 表示指定软件安装到哪个目录中,指定目录不存在会自动创建
--user/--group nginx工作进程由哪个用户运行管理
--with-http_stub_status_module 启动nginx状态模块功能(用户访问nginx的网络信息)
--with-http_ssl_module 启动https功能模块
通过软件编译过程中的返回值是否正确,确认配置是否正确
# echo $? 0
2、编译软件
# make
3、编译安装
# make install
验证是否安装成功
根据自己情况是否创建软连接
# ln -s /usr/local/nginx-1.16.0 /usr/local/nginx
# ll /usr/local/nginx/ ##查看nginx安装目录信息
total 4
drwxr-xr-x. 2 root root 4096 Jun 5 16:53 conf
drwxr-xr-x. 2 root root 40 Jun 5 16:53 html
drwxr-xr-x. 2 root root 6 Jun 5 16:53 logs
drwxr-xr-x. 2 root root 19 Jun 5 16:53 sbin
# /usr/local/nginx/sbin/nginx -V ###查看nginx安装版本等信息
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
精简化nginx.conf 主配置文件内容
# egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf.default >/usr/local/nginx/conf/nginx.conf
启动程序
# /usr/local/nginx/sbin/nginx ###启动nginx
# ps -ef | grep nginx ###查看nginx是否启动成功
root 29602 1 0 16:57 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 29603 29602 0 16:57 ? 00:00:00 nginx: worker process
root 29605 20541 0 16:58 pts/0 00:00:00 grep --color=auto nginx
# netstat -lntup |grep 80 ###检查端口信息
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 29602/nginx: master
服务部署完成
至此软件安装完毕!
修改环境变量
echo 'export PATH=/usr/local/nginx/sbin:$PATH'>>/etc/profile source /etc/profile which nginx
创建一个nginx.service启动
一、创建一个nginx.service
在 /usr/lib/systemd/system/目录下面新建一个nginx.service文件。并赋予可执行的权限。
vim /usr/lib/systemd/system/nginx.service
二、编辑service内容
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
三、启动服务
chmod +x /usr/lib/systemd/system/nginx.service
在启动服务之前,需要先重载systemctl命令
systemctl daemon-reload
systemctl start nginx.service
systemctl enable nginx.service
- centos7 中源码安装nginx
使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511 最小化安装 2.下载nginx,可以在系统中下载,也可 ...
- centos7下源码安装mysql5.7.16
一.下载源码包下载mysql源码包 http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz 二.安装约定: 用户名:mysql 安装目录 ...
- CentOS7 实战源码安装mysql5.7.17数据库服务器
CentOS7 实战源码安装mysql5.7.17数据库服务器 简介:实战演练mysql数据库服务器的搭建 mysql简介: mysql是一个开源的关系型数据库管理系统,现在是oracle公司旗下的 ...
- 源码安装nginx env
源码安装nginx 1. For ubuntu:18.04 apt -y install build-essential libtool libpcre3 libpcre3-dev zlib1g-de ...
- 源码安装nginx以及平滑升级
源码安装nginx以及平滑升级 ...
- Linux之源码安装nginx,并按照作业一描述的那样去测试使用
作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...
- 源码安装Nginx以及用systemctl管理
一.源码安装Nginx: 先安装gcc编译器(安装过的可以忽略) [root@localhost ~]# yum -y install gcc gcc-c++ wget 进入src目录 [root@l ...
- linux源码安装nginx
任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...
- 工作笔记-- 源码安装nginx
源码安装nginx 1.安装nginx的依赖包 [root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pc ...
- 源码安装nginx 方法二
yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...
随机推荐
- ffmpeg保持原视频画面比例 自动添加黑边
ffmpeg保持原视频画面比例 自动添加黑边 例如源是1280*528要转成640*480要保持画面比例实际上应该640*264 所以需要在上下都加黑边 ffmpeg -i d:/Media/e.f4 ...
- 在WCF程序中动态修改app.config配置文件
今天在个WCF程序中加入了修改配置文件的功能.我是直接通过IO操作修改的app.config文件内容,修改后发现发现其并不生效,用Google搜了一下,在园子里的文章动态修改App.Config 和w ...
- 十六、对RF中ROBOT_LIBRARY_SCOPE = 'GLOBAL'进行分析
(1)ROBOT_LIBRARY_SCOPE属于ROBOT库范围,这个范围有三个等级,分别是TEST CASE.TEST SUITE.GLOBAL三个等级,默认是TEST CASE:GLOBAL这个等 ...
- 解决VirtualBox虚拟机装XP无声问题的简便办法
原文地址;http://www.2cto.com/os/201206/134887.html 解决VirtualBox虚拟机装XP无声问题的简便办法 解决VirtualBox虚拟机装XP无声问题的简便 ...
- python中单下划线和双下划线的区别
1.python中双下划线(__str__)代表这个变量是特殊变量,是可以直接访问的 __xxx___ 定义的是特列方法.像__init__之类的 2.python前面双划线(__name)代表这个变 ...
- 阶段3 1.Mybatis_12.Mybatis注解开发_2 mybatis注解开发测试和使用注意事项
新建测试类 这里使用了main方法进行测试 InputStream需要抛出异常 写完进行测试 测试结果 讲解 把第一天的IUserDao.xml文件复制到当前的工程里面 红色的取值要用的.黄色的是执行 ...
- 阶段3 1.Mybatis_10.JNDI扩展知识_3 补充-测试JNDI数据源的使用以及使用细节
在webapp文件夹下新建目录META-INF 把context.xml文件复制过去. 拿资料里面的SqlMapConfig.xml文件 全部复制到项目的SqlMapConfig.xml里面来. ja ...
- golang 千位分隔符
项目需求将统计出的数字以千位分隔符分隔的形式展示(如将 1234567.89 格式化为 1,234,567.89),而 golang 的标准库中并无这样的函数. 万能的 google 找到解决办法,可 ...
- idea 使用过程中的一些设置记录
1.XML sql底色 在mapper文件中,SQL出现黄色的底色. ** settings ** > ** inspections ** 去掉 ** SQL ** 中的 ** No data ...
- 【MM系列】SAP MR21修改标准价
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]在SAP里查看数据的方法 前言部 ...