源码安装Nginx以及用systemctl管理
一、源码安装Nginx:
先安装gcc编译器(安装过的可以忽略)
[root@localhost ~]# yum -y install gcc gcc-c++ wget
进入src目录
[root@localhost ~]# cd /usr/local/src/
下载 nginx软件包
[root@localhost src]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
解压
[root@localhost src]# tar -zxvf nginx-1.14.0.tar.gz
进入nginx-1.14.0目录
[root@localhost src]# cd nginx-1.14.0/
安装依赖
[root@localhost nginx-1.14.0]# yum -y install openssl openssl-devel
./configure软件配置与检查
[root@localhostnginx-1.14.0]#./configure--prefix=/usr/local/nginx --with-http_ssl_module
安装
[root@localhost nginx-1.14.0]# make
[root@localhost nginx-1.14.0]# make install
启动nginx
[root@localhost nginx-1.14.0]#cd /usr/local/nginx/sbin
[root@localhost nginx-1.14.0]#./nginx
查看是否启动成功
[root@localhost nginx-1.14.0]# ps aux |grep nginx
二、systemctl管理:
创建配置文件
源码安装的nginx在/etc/systemd/system/multi-user.target.wants/目录下是没有nginx.service这个文件的,所以要新建[root@localhost nginx-1.14.0]#vim /usr/lib/systemd/system/nginx.service
写入内容(全部复制进去,然后修改)
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target [Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID [Install]
WantedBy=multi-user.target
修改 [Service]内容
将:
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf,
改为:
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
设置开机启动
[root@localhost nginx-1.14.0]# systemctl enable nginx.service
关闭之前启动的nginx服务
[root@localhost nginx-1.14.0]# pkill -9 nginx
重载修改过的所有配置文件
[root@localhost nginx-1.14.0]#systemctl daemon-reload
重新启动nginx服务
[root@localhost nginx-1.14.0]#systemctl start nginx
最后可以用浏览器访问自己虚拟机的IP:192.168.xxx.xx
源码安装Nginx以及用systemctl管理的更多相关文章
- 源码安装nginx以及平滑升级
源码安装nginx以及平滑升级 ...
- 源码安装nginx 方法二
yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...
- 源码安装nginx env
源码安装nginx 1. For ubuntu:18.04 apt -y install build-essential libtool libpcre3 libpcre3-dev zlib1g-de ...
- Linux之源码安装nginx,并按照作业一描述的那样去测试使用
作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...
- 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使用-1(源码安装nginx)
Nginx概述 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Ramb ...
- redhat 5下源码安装nginx服务
首先确保机器中已安装 gcc c++,libtool等工具,保证可执行源码安装 A.为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Co ...
- centos7 中源码安装nginx
使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511 最小化安装 2.下载nginx,可以在系统中下载,也可 ...
随机推荐
- Variable number of arguments (Varargs)
A parameter of a function (normally the last one) may be marked with vararg modifier: fun <T> ...
- Linux时区详解
全球24个时区的划分 相较于两地时间表,可以显示世界各时区时间和地名的世界时区表(World Time),就显得精密与复杂多了,通常世界时区表的表盘上会标示着全球24个时区的城市名称,但究竟这24个时 ...
- Ubuntu安装cuda
到官网选择对应的cuda版本.cuda跟显卡的驱动是有个依赖关系的.参见这篇博客 然后按照提示,运行按照程序 sudo sh cuda_10..130_410.48_linux.run 然后安装完成后 ...
- 【iCore4 双核心板_ARM】例程二十九:SD_IAP_FPGA实验——更新升级FPGA
实验现象及操作说明: 1.烧写程序成功,绿色ARM·LED灯点亮,三色FPGA·LED灯循环点亮,烧写失败,如果挂载SD卡失败,红灯快闪,如果打开文件失败,蓝灯快闪,读取文件指针移动失败,白灯点亮,升 ...
- awd入门教程
(转自:awk入门教程 - 阮一峰) 以下为正文 ———————————————————— awk是处理文本文件的一个应用程序,几乎所有 Linux 系统都自带这个程序. 它依次处理文件的每一行,并读 ...
- Swagger Annotation 详解
在软件开发行业,管理文档是件头疼的事.不是文档难于撰写,而是文档难于维护,因为需求与代码会经常变动,尤其在采用敏捷软件开发模式的系统中.好的工具能够提高团队沟通效率,保证系统质量以及缩短项目的交付周期 ...
- flex布局应用与踩坑
一.预告 本文不是一篇入门的文章所有请符合以下条件的战斗人员绕道: 1.初学前端,对前端的传统布局还不是很熟悉的人 2.后端人员对前端不打算深入学习的同学 二.开篇 flex布局原本是好几个月前就一直 ...
- Spring Boot Starter 的基本封装
1)spring-boot-starter这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring-boot-starter-amqp通过spring-rabbit来 ...
- ux.form.field.GridDate 支持快速选择日期的日期控件
效果如图,亲测6.2.1版本可用 /** *支持快速选择日期的日期控件 */ Ext.define('ux.form.field.GridDate', { extend: 'Ext.form.fiel ...
- nginx出现 “414 request-uri too large”
nginx出现 “414 request-uri too large” 在请求查询的时候使用了Get方法,由于拼接的url过长,导致nginx出现了“414 request-uri too large ...