zoukankan      html  css  js  c++  java
  • Ubuntu16.04安装及配置nginx

     Ubuntu版本信息:

    root@yatces-virtual-machine:~# cat /etc/lsb-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=16.04
    DISTRIB_CODENAME=xenial
    DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

    安装nginx版本:

    nginx-1.11.3

    1.安装nginx依赖库

    1.1安装pcre依赖库

    root@yatces-virtual-machine:~# apt-get install libpcre3 libpcre3-dev

    1.2安装zlib依赖库

    root@yatces-virtual-machine:~# apt-get install zlib1g-dev

    1.3安装ssl依赖库

    root@yatces-virtual-machine:~# apt-get install openssl

    2.安装nginx

    2.1下载最新版本

    root@yatces-virtual-machine:/usr/local/soft# wget http://nginx.org/download/nginx-1.11.3.tar.gz

    2.2解压

    root@yatces-virtual-machine:/usr/local/soft# tar -zxvf nginx-1.11.3.tar.gz

    2.3进入nginx目录配置

    root@yatces-virtual-machine:/usr/local/soft# cd nginx-1.11.3/

    2.4配置(先创建文件夹:/usr/local/nginx)

    root@yatces-virtual-machine:/usr/local/soft/nginx-1.11.3# ./configure --prefix=/usr/local/nginx

    可以通过./configure --help查看需要配置的参数

    root@yatces-virtual-machine:/usr/local/soft/nginx-1.11.3# ./configure --help
    --help print this message --prefix=PATH set installation prefix --sbin-path=PATH set nginx binary pathname --modules-path=PATH set modules path
     ...

     2.5编译、安装

    root@yatces-virtual-machine:/usr/local/soft/nginx-1.11.3# make
    
    
    root@yatces-virtual-machine:/usr/local/soft/nginx-1.11.3# make install

    如果make的时候报错,提示“pcre.h No such file or directory”,需要安装 libpcre3-dev依赖。

    2.6启动nginx

    安装完后在/usr/local/nginx/sbin目录下有个nginx命令

    root@yatces-virtual-machine:/usr/local/nginx/sbin# ls
    nginx

    启动

    root@yatces-virtual-machine:/usr/local/nginx/sbin# ./nginx

    后面可以加上-c 指定配置文件的位置,不加nginx会自动加载默认配置文件。

    root@yatces-virtual-machine:/usr/local/nginx/sbin# ./nginx -c /usr/local/nginx/conf/nginx.conf

    查看nginx进程

    root@yatces-virtual-machine:/usr/local/nginx/sbin# ps -ef|grep nginx
    root      11975      1  0 14:57 ?        00:00:00 nginx: master process ./nginx
    nobody    11976  11975  0 14:57 ?        00:00:00 nginx: worker process
    root      11978  11883  0 14:57 pts/2    00:00:00 grep --color=auto nginx

    访问nginx 

  • 相关阅读:
    [LeetCode] 456. 132 Pattern
    [LeetCode] 606. Construct String from Binary Tree
    [LeetCode] 536. Construct Binary Tree from String
    [LeetCode] 925. Long Pressed Name
    [LeetCode] 652. Find Duplicate Subtrees
    [LeetCode] 743. Network Delay Time
    [LeetCode] 1209. Remove All Adjacent Duplicates in String II
    [LeetCode] 1047. Remove All Adjacent Duplicates In String
    [LeetCode] 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
    [LeetCode] 859. Buddy Strings
  • 原文地址:https://www.cnblogs.com/Yatces/p/11388811.html
Copyright © 2011-2022 走看看