一、源码安装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管理的更多相关文章

  1. 源码安装nginx以及平滑升级

                                                           源码安装nginx以及平滑升级                               ...

  2. 源码安装nginx 方法二

    yum 仓库不能用大写字母 [root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件 gzip ./* gzip . gzip./ # 关闭防火墙和selinux [root ...

  3. 源码安装nginx env

    源码安装nginx 1. For ubuntu:18.04 apt -y install build-essential libtool libpcre3 libpcre3-dev zlib1g-de ...

  4. Linux之源码安装nginx,并按照作业一描述的那样去测试使用

    作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...

  5. linux源码安装nginx

    任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...

  6. 工作笔记-- 源码安装nginx

    源码安装nginx 1.安装nginx的依赖包 [root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pc ...

  7. nginx使用-1(源码安装nginx)

    Nginx概述 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Ramb ...

  8. redhat 5下源码安装nginx服务

    首先确保机器中已安装 gcc c++,libtool等工具,保证可执行源码安装 A.为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Co ...

  9. centos7 中源码安装nginx

    使用nginx有一段时间了,还是有很多东西不懂的,在这里做一下自己学习过程中的一些整理,能使自己得到提升. 1.环境:centos7 1511  最小化安装 2.下载nginx,可以在系统中下载,也可 ...

随机推荐

  1. mysql主从复制延迟问题的相关知识与解决方案

    一.如何监控发生了主从延迟? 在从库机器上,执行show slave status,查看Seconds_Behind_Master值,代表主从同步从库落后主库的时间,单位为秒,若同从同步无延迟,这个值 ...

  2. java通过jdbc访问mysql,update数据返回值的思考

    java通过jdbc访问mysql,update数据返回值的思考 先不说那么多,把Java代码贴出来吧. public static void main(String[] args) throws I ...

  3. HDFS基础

    1. HDFS Shell基础 [root@master hadoop]# hadoop fsUsage: hadoop fs [generic options] [-appendToFile < ...

  4. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error com piling: 无效的标记: -parameters

    背景:本项目使用JDK1.8 编译maven工程的时候出现如下错误: Failed to execute goal org.apache.maven.plugins:maven-compiler-pl ...

  5. 大华等其他NVR接入海康IPC H.264方法

    有一次遇到这个问题,因为时间急,没有注意,这次一个朋友也遇到这个问题,各种百度,也没有看到答案 只好自己研究了一下,最终发现以下方式来解决 下面办法可以解决海康IPC不能能过ONVIF连接到大华等其他 ...

  6. 蜕变成蝶~Linux设备驱动中的阻塞和非阻塞I/O

    今天意外收到一个消息,真是惊呆我了,博客轩给我发了信息,说是俺的博客文章有特色可以出本书,,这简直让我受宠若惊,俺只是个大三的技术宅,写的博客也是自己所学的一些见解和在网上看到我一些博文以及帖子里综合 ...

  7. elasticsearch 6.1.1 transport jar

    https://files.cnblogs.com/files/xjyggd/transport6.1.1.rar

  8. 宣布推出针对 Microsoft OneDrive 和 SharePoint 的 Autodesk AutoCAD 新集成

    在 OneDrive 和 SharePoint,我们的愿景是随时随地为你的团队提供简单而安全的文件访问.无论你的职位.专业或行业是什么,我们将始终致力于扩展和连接你最重视的内容.今天,我们发布了与 A ...

  9. Twig---for循环

    如何使用twig做for循环. Twig中文文档: https://www.kancloud.cn/yunye/twig-cn/159620 {% for item in list %} <li ...

  10. python基础类型—列表

    列表 列表是python中的基础数据类型之一,其他语言中也有类似于列表的数据类型,比如js中叫数组,他是以[]括起来,每个元素以逗号隔开,而且他里面可以存放各种数据类型比如: li = [‘alex’ ...