如果是阿云的ECS服务器,默认是已经安装了Apache服务器的,但一般都用不到,可以选择将它卸载

sudo service apache2 stop

update-rc.d -f apache2 remove
sudo apt-get remove apache2

Ubuntu安装Nginx

sudo apt-get update
sudo apt-get install nginx

#查看nginx版本
nginx -v
#进入nginx的默认目录
cd /etc/nginx/
ls #进入conf.d文件夹
cd conf.d
ls
pwd #新建配置文件
sudo vi nodejs-com-.conf
upstream nodejs {
server 127.0.0.1:
} server {
listen ;
server_name 192.168.31.209: location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward_For $proxy_add_x_forwarded_for;
proxy_set_header Host #http_host;
proxy_set_header X-Nginx_Proxy true; proxy_pass http://nodejs;
proxy_redirect off;
}
}

检查nginx配置文件是否存在错误

sudo nginx -t
#重启nginx服务
sudo nginx -s reload #或者可以使用
sudo service nginx restart

以下配置来自于,https://www.youtube.com/watch?v=SpL_hJNUNEI

配置的负载均衡

#默认的配置
sudo vi /etc/nginx/sites-available/default #规换成以下规则
upstream web_backend{
server 192.168.31.210
server 192.168.31.211
} server{
listen ; location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web_backend;
}
}

Ubuntu Nginx的更多相关文章

  1. Ubuntu Nginx下配置网站ssl实现https访问

    最近在看  HTTP权威指南   看到介绍了HTTPS的ssl,自己就动手测试了下,将步骤记录下 HTTPS简介 什么是HTTPS?百科是这样解释的.HTTPS(全称:Hyper Text Trans ...

  2. Ubuntu Nginx安装

    1.先更新ubuntu系统 更新命令 sudo apt-get update sudo apt-get upgrade 2 添加ubuntu nginx更新源镜像 cd /etc/apt/ sudo ...

  3. 利用docker搭建ubuntu+nginx+PHP容器

      环境:操作系统(Ubuntu  16.04 64位); php7.1;  nginx/1.14.0   基础环境准备: 整体思路:docker pull一个ubuntu镜像,然后在容器中安装ngi ...

  4. Ubuntu Nginx uwsgi django 初试

    /************************************************************************************** * Ubuntu Ngi ...

  5. [技术博客]ubuntu+nginx+uwsgi+Django+https的部署

    ubuntu+nginx+uwsgi+Django+https部署文档 配置机器介绍 操作系统:Ubuntu 18.04.2 LTS 64位 python版本:Python 3.6.7 Django版 ...

  6. ubuntu+nginx+uwsgi部署django web项目

    前言 将本地开发的django项目部署至linux上的uwsgi服务器,并配置nginx,完成基于ubuntu+nginx+uwsgi的上线运行.下面整理相关步骤. 服务器配置virtualenv 如 ...

  7. Ubuntu nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

    在Ubuntu 12中启动刚安装好的Nginx,报错: nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 原因如下: ...

  8. 微信小程序免费Https获取以及Ubuntu Nginx配置

    先贴上Nginx的配置文件 user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections ...

  9. ubuntu nginx ssl 证书配置

      前几天自己用 egg.js 写了个 api 接口,然后把它部署到服务器上.服务器是ubuntu 16.04 + nginx:因为要用到https,然后今天实践了一下如何配置https. 关于htt ...

  10. 使用Dockerfile定制ubuntu+nginx镜像

    实验目的:书写Dockerfile,定制ubuntu 14.04 + nginx 1.14.0的镜像. 实验过程: 1. 下载nginx-1.14.0  http://nginx.org/downlo ...

随机推荐

  1. [LeetCode] 21. Merge Two Sorted Lists ☆

    Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...

  2. [LeetCode] 13. Roman to Integer ☆☆

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  3. Ubuntu12.04 安装nginx和mongo过程

    1.安装php和php-cgi apt-get install php5 php5-cgi 2.安装 nginx apt-get install nginx 3.安装 MongoDB apt-get ...

  4. 【Foreign】数据结构C [线段树]

    数据结构C Time Limit: 20 Sec  Memory Limit: 512 MB Description Input Output Sample Input Sample Output H ...

  5. loj515 「LibreOJ β Round #2」贪心只能过样例

    传送门:https://loj.ac/problem/515 [题解] 容易发现S最大到1000000. 于是我们有一个$O(n^2*S)$的dp做法. 容易发现可以被bitset优化. 于是复杂度就 ...

  6. 【51NOD-0】1008 N的阶乘 mod P

    [算法]简单数学 [题解]多项式展开:(a*b)%p=(a%p*b%p)%p #include<cstdio> #include<algorithm> #define rep( ...

  7. Drainage Ditches(POJ1273+网络流+Dinic+EK)

    题目链接:poj.org/problem?id=1273 题目: 题意:求最大流. 思路:测板子题,分别用Dinic和EK实现(我的板子跑得时间均为0ms). Dinic代码实现如下: #includ ...

  8. Super A^B mod C (快速幂+欧拉函数+欧拉定理)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1759 题目:Problem Description Given A,B,C, You should quick ...

  9. java 深度拷贝 复制 深度复制

    1.深度拷贝.复制代码实现 最近需要用到比较两个对象属性的变化,其中一个是oldObj,另外一个是newObj,oldObj是newObj的前一个状态,所以需要在newObj的某个状态时,复制一个一样 ...

  10. Java案例之随机验证码功能实现

    实现的功能比较简单,就是随机产生了四个字符然后输出.效果图如下,下面我会详细说一下实现这个功能用到了那些知识点,并且会把 这些知识点详细的介绍出来.哈哈 ,大神勿喷,对于初学Java的人帮助应该蛮大的 ...