源码安装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,可以在系统中下载,也可 ...
随机推荐
- Tomcat服务器安装、配置、测试
Tomcat服务器安装.配置.测试(win7_64bit) 目录 1.概述 2.本文用到的工具 3.Tomcat服务器安装配置 4.Tomcat服务器简单测试 5.注意事项 >>看不清的图 ...
- 数据仓库:Mysql大量数据快速导出
背景 写这篇文章主要是介绍一下我做数据仓库ETL同步的过程中遇到的一些有意思的内容和提升程序运行效率的过程. 关系型数据库: 项目初期:游戏的运营数据比较轻量,相关的运营数据是通过Java后台程序聚合 ...
- go语言的排序和去重
go语言的排序: https://blog.csdn.net/u010983881/article/details/52460998 go语言去重: https://blog.csdn.net/qq_ ...
- 此请求已被阻止,因为当用在 GET 请求中时,会将敏感信息透漏给第三方网站。若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet。
1.问题描述 mvc从一个路径获取所有的图片信息,ajax方法如下: function getimages(day) { var year = $("#selYear").val( ...
- MySQL 下载地址获取
http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.26-winx64.msi 首先安装 mysql installer 安装器进行安装,之前会让你选 ...
- flask wigs 服务器
Nginx:Hey,WSGI,我刚收到了一个请求,我需要你作些准备,然后由Flask来处理这个请求. WSGI:OK,Nginx.我会设置好环境变量,然后将这个请求传递给Flask处理. Flask: ...
- Linux iptables原理和使用
1.原理 iptables简介 netfilter/iptables(简称为iptables)组成Linux平台下的包过滤防火墙,与大多数的Linux软件一样,这个包过滤防火墙是免费的,它可以代替昂贵 ...
- 和TransDecoder 学习perl 自定义模块的路径问题
TransDecoder 软件是用perl 原因写的,其中包含了一些自定义的模块,通过一个脚本来进行调用,为了能够正常访问自定义的perl 模块, 在其源代码中利用了FindBin 这个模块 use ...
- 更改Nginx网站根目录以及导致的403 forbidden问题解决
版权声明:本文为博主原创文章,未经博主允许不得转载. 一.更改根目录 Nginx默认网站根目录为/usr/local/nginx/html,要将它改成/home/fuxiao/www 更改方法: ...
- mac xmind 激活
下载地址 https://www.jb51.net/softjc/624167.html 打开压缩包中的[K].zip 按里面的READ ME!.rtf 文件来操作 嗯,就这样