美文网首页
nginx安装

nginx安装

作者: 有梦想的虫子_2018 | 来源:发表于2020-10-20 17:10 被阅读0次

    1、安装

    在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel
    linux下检查是否安装过某软件包

    官网下载地址:https://nginx.org/download/
    百度云盘链接:https://pan.baidu.com/s/1_pwCYH616Tvq161AOLoFdQ
    提取码:tlpm

    [root@localhost mc]# tar -zxvf nginx-1.9.9.tar.gz
    [root@localhost mc]# cd nginx-1.9.9/
    [root@localhost nginx-1.9.9]# ./configure --prefix=/usr/local/nginx
    [root@localhost nginx-1.9.9]# make && make install
    

    2、启动

    [root@localhost nginx-1.9.9]# cd /usr/local/nginx/sbin/
    [root@localhost sbin]# ./nginx  #默认配置文件/usr/local/nginx/conf/nginx.conf
    [root@localhost sbin]# ps -ef|grep nginx 
    root      5335     1  0 07:02 ?        00:00:00 nginx: master process ./nginx
    nobody    5336  5335  0 07:02 ?        00:00:00 nginx: worker process
    root      5340  2807  0 07:02 pts/0    00:00:00 grep --color=auto nginx
    
    [root@localhost sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
    启动nginx -c表示指定nginx.conf的文件。如果不指定默认为NGINX_HOME/conf/nginx.conf。
    

    3、停止

    [root@localhost sbin]# ./nginx -s stop  停止
    [root@localhost sbin]# ./nginx -s quit   退出
    [root@localhost sbin]# ./nginx -s reload  重新加载nginx.conf
    

    4、访问

    浏览器访问.png
    ###5、开机自启动
    [root@localhost sbin]# vim /etc/rc.d/rc.local
    
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    
    #开机启动nginx
    /usr/local/nginx/sbin/nginx
    
    

    相关文章

      网友评论

          本文标题:nginx安装

          本文链接:https://www.haomeiwen.com/subject/yvddmktx.html