• Linux安装Nginx


    安装依赖:

    yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
    yum install
    pcre #centos7系统自带无需安装

    下面开始Nginx安装步骤

    1.下载压缩包

      wget http://124.205.69.167/files/5114000006EA9D21/nginx.org/download/nginx-1.15.2.tar.gz
      

    2.解压  

      tar -zxvf nginx-1.15.2.tar.gz -C /usr/local

      

    3.编译安装

      cd /usr/local/nginx-1.15.2/
      ./configure

      

      

      make && make install

      

      安装完成后在/usr/local/目录下会多出一个文件夹nginx
      cd /usr/local/

      ll

      

    4.查看安装版本

      cd /usr/local/nginx/sbin/
      /usr/local/nginx/sbin/nginx -v
      

    5.检查配置

      /usr/local/nginx/sbin/nginx -t

      

    6.启动

      /usr/local/nginx/sbin/nginx

      

    7.浏览器访问

      linux服务器ip:80 

     

    8.其他

      /usr/local/nginx/sbin/nginx -s reload # 重新载入配置文件

      /usr/local/nginx/sbin/nginx -s reopen # 重启 Nginx

      /usr/local/nginx/sbin/nginx -s stop # 停止 Nginx

    9.开机启动

      (1)编辑service文件

        cd /usr/lib/systemd/system/     #进入service文件目录

        vim ./nginx.service  #编辑nginx.service文件

        在nigix.service文件中添加以下信息

        [Unit]
        Description=nginx - high performance web server
        After=network.target remote-fs.target nss-lookup.target
        [Service]
        Type=forking
        ExecStart=/usr/local/nginx/sbin/nginx
        ExecReload=/usr/local/nginx/sbin/nginx -s reload
        ExecStop=/usr/local/nginx/sbin/nginx -s stop
        [Install]
        WantedBy=multi-user.target
        

      (2)生效

        systemctl daemon-reload

      (3)改变文件权限

        chmod 777 ./nginx.service 

      (4)建立软连接

        ln -s /usr/lib/systemd/system/nginx.service /etc/systemd/system/multi-user.target.wants/nginx.service

      (5)systemctl开机启动nginx

        systemctl enable nginx.service 

      (6)systemctl取消开机启动nginx

        systemctl disable nginx.service

      (7)systemctl启动nginx

        systemctl start nginx.service

      (8)systemctl重启nginx

        systemctl restart nginx.service

      (9)systemctl停止nginx

        systemctl restart nginx.service

      (10)systemctl查看nginx状态

        systemctl status nginx.service

  • 相关阅读:
    如何克服晕车?
    简单C程序,迷宫
    非名校毕业年薪20W程序员 心得分享
    北京:一个大学生每年要花多少钱
    PowerPoint超链接字体颜色修改、怎么去掉超链接下划线
    河南旅游景点介绍
    程序员必看的十大电影
    AMD的cpu如何安装Mac OS
    C/C++面试之算法系列--去除数组中的重复数字
    Warshall算法
  • 原文地址:https://www.cnblogs.com/zwcry/p/9454647.html
Copyright © 2020-2023  润新知