• 安装篇四:安装NGINX(1.4.0版本)


    #1、NGINX安装

    1、安装文件上传软件
        [root@TEST ~]# yum install lrzsz –y     <———拖拽文件
    2、检查软件安装的系统环境
        [root@TEST ~]# cat /etc/redhat-release
        [root@TEST ~]# uname -r
    3、安装nginx的依赖包(pcre-devel openssl-devel)---假设不进行安装
        [root@TEST ~]# yum install -y pcre-devel openssl-devel
    4、下载nginx软件---1.10.2 复制链接地址(统一位置进行下载)
        [root@TEST ~]# cd /server/tools/
        [root@TEST tools]# wget -q http://nginx.org/download/nginx-1.4.0.tar.gz
        说明:软件很小,用心查看一下
    5、解压、配置、编译、安装NGINX
        解压要编译安装的软件(解压软件---配置(./configure)---做菜(编译 make)---上菜(安装 make install))
        [root@TEST ~]#  cd /server/tools/
        [root@TEST tools]#  tar xf nginx-1.4.0.tar.gz
        [root@TEST tools]#  cd nginx-1.4.0
        [root@TEST tools]#  ls (里面的内容就是源代码(config readme安装说明)---默认编译会安装到/usr/local目录)
        [root@TEST nginx-1.4.0]#  useradd -s /sbin/nologin -M www        <--- 创建NGINX服务程序www用户
        进行配置,编译,安装
        (说明:每执行下面一个命令,都使用 "echo $?" 进行测试,看返回值是否为0,若为0,则只需下面命令;若返回值不是0,则删除安装包重新执行。
        [root@TEST nginx-1.4.0]#  ./configure --prefix=/application/nginx-1.4.0 --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module
    
    ####---------------------------------####
    执行命令时,报如下错误信息:
    checking for OS
     + Linux 2.6.32-431.el6.x86_64 x86_64
    checking for C compiler ... not found
    ./configure: error: C compiler cc is not found
    出现这个错误。那么就是gcc 包没有安装。
    [root@TEST nginx-1.4.0]# yum -y install gcc
    ####---------------------------------####
    
        [root@TEST nginx-1.4.0]#  echo $?    <————返回值为0,执行下一个命令
        [root@TEST nginx-1.4.0]#  make 
        [root@TEST nginx-1.4.0]#  echo $?    <————返回值为0,执行下一个命令
        [root@TEST nginx-1.4.0]#  make install
        [root@TEST nginx-1.4.0]#  echo $?    <————返回值为0,执行下一个命令
    6、创建软连接
        软件安装完成要做一个软链接
        [root@TEST nginx-1.4.0]#  ln -s /application/nginx-1.4.0 /application/nginx
    7、重启nginx服务;进行首页测试
        [root@TEST nginx-1.4.0]#  /applicaton/nginx/sbin/nginx   
        [root@TEST nginx-1.4.0]#  lsof -i:80        <————查看监听情况
    8、浏览器访问 http://10.0.0.200            <————能访问到NGINX欢迎页面,说明NGINX安装成功
        至此软件安装完毕:
    9、NGINX状态检查
        [root@TEST nginx-1.4.0]#  ps –ef | grep nginx
          root      30716      1  0 15:55 ?        00:00:00 nginx: master process nginx
          www       31453  30716  0 17:40 ?        00:00:00 nginx: worker process
          root      31696  31670  0 18:15 pts/0    00:00:00 grep --color=auto nginx
        [root@TEST nginx-1.4.0]#  netstat –lntup | grep nginx
          tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      4170/nginx

    #2、NGINX程序目录结构

    [root@www nginx-1.4.0]# ll 
    drwx------ 2 www  root 4096 Apr 13 22:32 client_body_temp
    drwx------ 2 www  root 4096 Apr 13 22:32 fastcgi_temp
    drwx------ 2 www  root 4096 Apr 13 22:32 proxy_temp
    drwx------ 2 www  root 4096 Apr 13 22:32 scgi_temp
    drwx------ 2 www  root 4096 Apr 13 22:32 uwsgi_temp
    drwxr-xr-x 2 root root 4096 Apr 13 22:27 conf        <——--- 配置文件保存路径(nginx.conf)
    drwxr-xr-x 2 root root 4096 Apr 13 22:27 html        <——--- 站点目录,整合网站资源
    drwxr-xr-x 2 root root 4096 Apr 13 22:32 logs        <——--- 日志文件(错误日志文件 访问日志文件  进程pid文件)
    drwxr-xr-x 2 root root 4096 Apr 13 22:27 sbin        <——--- 程序命令保存路径

    #3、NGINX配置文件说明(nginx.conf)

    #说明:原配置文件没有什么作用,必须初始化配置文件
    [root@TEST ~]# cd /application/nginx/conf/
    [root@TEST conf]# grep -Ev "^$|#" nginx.conf.default >nginx.conf
    [root@TEST conf]# cat nginx.conf

    #编写nginx配置文件规范总结:

      1) 配置文件中指令或者参数,一定要编写正确(拼写 位置)

      2) 每一个区块都是有成对大括号组成

      3) 所有区块中的指令信息结尾都要有分好

    #4、NGINX常见命令汇总

    #启动nginx
    [root@TEST ~]# /application/nginx/sbin/nginx
    #查看nginx版本
    [root@TEST ~]# /application/nginx/sbin/nginx -v
      nginx version: nginx/1.4.0
    #配置文件语法检查
    [root@TEST ~]# /application/nginx/sbin/nginx -t
    #nginx命令帮助
    [root@TEST ~]# /application/nginx/sbin/nginx –h
    #关闭nginx
    [root@TEST ~]# /application/nginx/sbin/nginx -s stop
    #平滑重启(当配置文件发送变化时可以使用:(如果配置文件里面涉及ip地址的修改的话,必须使用先关闭服务,再重启的方式))
    [root@TEST ~]# /application/nginx/sbin/nginx -s reload
    #打开日志文件(一般用于日志切割)
    [root@TEST ~]# /application/nginx/sbin/nginx -s reopen 
  • 相关阅读:
    css水平垂直居中
    JavaScript提供了哪几种“异步模式”?
    sort()
    后端开发中,可以在Cache-Control设置的常用指令
    纯函数
    react和vue
    npm(classnames) 更灵活使用类名
    shell知多少?
    常见的HTTP状态码
    axios
  • 原文地址:https://www.cnblogs.com/l75790/p/12804228.html
Copyright © 2020-2023  润新知