zoukankan      html  css  js  c++  java
  • nginx学习与配置-安装与启动关闭管理

    1. nginx服务器的安装

    安装准备: nginx依赖于pcre库,要先安装pcre

    yum install pcre pcre-devel

     cd /usr/local/src/

     wget wget http://nginx.org/download/nginx-1.6.3.tar.gz

    tar zxvf nginx-1.6.3.tar.gz

    cd nginx-1.6.3

    ./configure --prefix=/data/local/nginx

    make && make install

    这个时候nginx已经安装完成 

    启动:

    cd /data/local/nginx, 看到如下4个目录

    ./

     ....conf配置文件 

     ... html网页文件

     ...logs  日志文件

     ...sbin  主要二进制程序

    2.nginx服务器启动停止管理

        首先需要查看nginx是否已经启动:
        有两种方法:1.netstat -tunpl|grep nginx (查看是否有nginx端口号在监听)   2.ps aux|grep nginx(查看nginx是否有进程在跑,主要看主进程)

        
        如果你是使用的yum安装的则比较简单:  
        1.    /etc/init.d/nginx start

        [root@lx /]# /etc/init.d/nginx start

        Starting nginx:                                            [  OK  ] 

        

        2:service nginx start   

        [root@lx /]# service nginx start

        Starting nginx:                                            [  OK  ]

        注意这里重启停止可以使用:
        service nginx restart/stop
        /etc/init.d/nginx restart/stop

        3.    进入nginx中sbin目录启动nginx
        /data/local/nginx/sbin/nginx

        详细如下:

        [root@lx /]# /data/local/nginx/sbin/nginx 

        [root@lx /]# ps aux|grep nginx

        nginx     2112  0.0  0.5  32956  9804 ?        S    May05   0:06 php-fpm: pool www           

        nginx     2113  0.0  0.4  33136  9336 ?        S    May05   0:06 php-fpm: pool www           

        nginx     2782  0.0  0.2  31044  5472 ?        S    May05   0:00 php-fpm: pool www                                                

        nginx     2783  0.0  0.3  31812  6444 ?        S    May05   0:00 php-fpm: pool www                                                

        root      9480  0.0  0.0   7268   916 ?        Ss   02:14   0:00 nginx: master process /data/local/nginx/sbin/nginx

        nginx     9481  0.0  0.6  18080 11904 ?        S    02:14   0:00 nginx: worker process       

        nginx     9482  0.0  0.6  18080 11904 ?        S    02:14   0:00 nginx: worker process       

        nginx     9483  0.0  0.6  18080 11864 ?        S    02:14   0:00 nginx: worker process       

        nginx     9484  0.0  0.6  18080 11892 ?        S    02:14   0:00 nginx: worker process       

        root      9486  0.0  0.0   4424   760 pts/1    S+   02:14   0:00 grep nginx

        这里需要注意的是:如果路径后面没有跟上nginx.conf配置文件路径则启动会默认为读取默认的配置文件,我们也可以指定配置文件进行启动

        [root@lx /]# /data/local/nginx/sbin/nginx -c  /data/local/nginx/conf/nginx.conf

        [root@lx /]# netstat -tunpl|grep nginx

        tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      9576/nginx          

        tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9576/nginx    

        

        

  • 相关阅读:
    BZOJ 2738 矩阵乘法(整体二分+二维树状数组)
    BZOJ 1430 小猴打架(prufer编码)
    BZOJ 2818 Gcd(莫比乌斯反演)
    BZOJ 4403 序列统计(Lucas)
    BZOJ 3083 遥远的国度(树链剖分+线段树)
    BZOJ 2049 [Sdoi2008]Cave 洞穴勘测(动态树)
    BZOJ 3282 Tree(动态树)
    BZOJ 3239 Discrete Logging(BSGS)
    BZOJ 2683 简单题(CDQ分治+树状数组)
    BZOJ 4327 JSOI2012 玄武密码(后缀自动机)
  • 原文地址:https://www.cnblogs.com/lisqiong/p/5524667.html
Copyright © 2011-2022 走看看