• nginx ubantu 安装步骤


    Ubuntu14.04默认安装的是Nginx 1.4.6

    如果已经安装,请先卸载
    sudo apt-get remove nginx
    最新的稳定版Nginx 1.6.0在ubuntuupdates ppa库中提供,网址http://www.ubuntuupdates.org/ppa/nginx?dist=trusty

    安装方法:
    sudo add-apt-repository ppa:nginx/stable 
    sudo apt-get update
    sudo apt-get install nginx

    查看nginx 版本

    nginx -v
    nginx version: nginx/1.6.0

    -----------------------------------另一例-----------------------------------

    一、检测主机信息

    root@slave:~# cat /etc/issue
    Ubuntu 12.04.1 LTS l

    root@slave:~# uname  -a
    Linux slave 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    PS:一下操作小编只针对如上环境进行测试

    二、更新apt源

    登录nginx官网 依次点击右边download 下边的stable version 找到响应系统并复制deb连接添加至源配置文件

    eg:

    复制
    deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
    deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx

    添加至/etc/apt/sources.list文件中

    下载并导入/

    wget http://nginx.org/keys/nginx_signing.key
    sudo apt-key add nginx_signing.key

    更新apt-get源
    apt-get update

    安装nginx

    root@slave:~# apt-get install nginx
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树      
    正在读取状态信息... 完成      
    下列【新】软件包将被安装:
      nginx
    升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 154 个软件包未被升级。
    需要下载 462 kB 的软件包。
    解压缩后会消耗掉 1,030 kB 的额外空间。
    获取:1 http://nginx.org/packages/mainline/ubuntu/ precise/nginx nginx amd64 1.7.4-1~precise [462 kB]
    下载 462 kB,耗时 2秒 (207 kB/s)
    Selecting previously unselected package nginx.
    (正在读取数据库 ... 系统当前共安装有 49098 个文件和目录。)
    正在解压缩 nginx (从 .../nginx_1.7.4-1~precise_amd64.deb) ...
    ----------------------------------------------------------------------

    Thanks for using nginx!

    Please find the official documentation for nginx here:
    * http://nginx.org/en/docs/

    Commercial subscriptions for nginx are available on:
    * http://nginx.com/products/

    ----------------------------------------------------------------------
    正在处理用于 ureadahead 的触发器...
    ureadahead will be reprofiled on next reboot
    正在设置 nginx (1.7.4-1~precise) ...
      检查nginx版本
    root@slave:~# nginx -v
    nginx version: nginx/1.7.4

    /-------------------------设置nginx.conf----------------------

    默认安装路径 /etc/nginx/nginx.conf

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    underscores_in_headers on; #自定义 Head 必须定义

    server {
    # 监听 8089 端口
    listen 8089;
    autoindex on;
    server_name 124.128.235.247;
    access_log /var/log/nginx/access.log combined;
    index index.html index.htm index.jsp index.php;
    if ( $query_string ~* ".*[;'<>].*" ){
    return 404;

    location / {
    # 反向代理到 8089 端口
    proxy_pass http://10.10.0.245:8089;
    # add_header Access-Control-Allow-Origin *;
    proxy_set_header HOST $HOST;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Request-Url $request_uri;

    }

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    }

  • 相关阅读:
    【BZOJ4538】[Hnoi2016]网络 整体二分+树状数组
    【BZOJ4543】[POI2014]Hotel加强版 长链剖分+DP
    【BZOJ1304】[CQOI2009]叶子的染色 树形DP
    【BZOJ4552】[Tjoi2016&Heoi2016]排序 二分+线段树
    【BZOJ4557】[JLoi2016]侦察守卫 树形DP
    【BZOJ4499】线性函数 线段树
    【BZOJ1576】[Usaco2009 Jan]安全路经Travel 最短路+并查集
    【BZOJ4560】[JLoi2016]字符串覆盖 KMP+状压DP
    【BZOJ2124】等差子序列 树状数组维护hash值
    MDX导航结构层次:《Microsoft SQL Server 2008 MDX Step by Step》学习笔记九
  • 原文地址:https://www.cnblogs.com/sunsing123/p/10830086.html
Copyright © 2020-2023  润新知