zoukankan      html  css  js  c++  java
  • linux下安装nginx

    步骤:

    1. 安装所需环境

    a)安装gcc:安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境

      yum install gcc-c++

    b)安装pcre pcre-devel:PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库

      yum install -y pcre pcre-devel

    c)安装zlib:zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库

      yum install -y zlib zlib-devel

    d)安装OpenSSL:OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库

      yum install -y openssl openssl-devel

    2. 官网下载安装包 https://nginx.org/en/download.html

       也可以wget命令下载:wget https://nginx.org/download/nginx-1.16.1.tar.gz

    3. 将安装包上传到linux服务器,解压

      tar -zxvf nginx-1.10.1.tar.gz

    4. 配置、编译、安装

      cd nginx-1.10.1 (进入解压目录,建议解压到/usr/local/nginx)
      -- ./configure (使用默认配置,没有https)

      ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --with-http_stub_status_module --with-http_ssl_module(添加https)

      -- 若使用./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module则会报错,添加参数--conf-path=/usr/local/nginx/nginx.conf就ok了


      make (编译)
      make install (安装)

    5. 启动nginx

      cd /usr/local/nginx/sbin/
      ./nginx

    6. 浏览器输入服务器ip,看到以下页面,说明nginx安装成功!

     7. 其他常用命令

      ./nginx -s stop    等待nginx处理任务完毕,停止nginx进程

      ./nginx -s quit    先查出进程ID,再使用kill命令强制杀掉进程

      ./nginx -s reload   不用重启nginx,使配置文件生效(若修改了nginx.conf)

      ps -ef | grep nginx    查询 nginx 进程

      whereis nginx    查询nginx的安装路径

      ./nginx -t   检查nginx.cnf的语法是否正确

  • 相关阅读:
    day23-json、pickle、configparser、hashlib、suprocess模块
    day22-时间模块、random模块、os模块、sys模块
    day21-py文件作用,导包、模块搜索路径
    day20-python-二分、面向过程思想、函数式、模块
    day19-python-叠加装饰器分析、yield、三元、生成式、递归
    day18-python-装饰器、迭代器、生成器
    day17-python-装饰器
    day16-python-函数对象、函数嵌套、闭包函数
    搭建yum本地源_阿里云CentOS服务器初始化设置
    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了
  • 原文地址:https://www.cnblogs.com/xiaochongc/p/11527492.html
Copyright © 2011-2022 走看看