• Ubuntu16.04 安装配置nginx,实现多项目管理、负载均衡


     
    1、配置nginx代理
    配置apache的监听端口为8080, /etc/apache2/ports.conf
    Listen 8080
     
    配置  /etc/nginx/sites-available 复制
    sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/80
     
    进入80文件更改如下:
    server {
             listen 80;
             listen [::]:80;
     
             server_name 127.0.0.1;
     
             root /var/www/test/;
             index index.html,index.php;
     
             location / {
                    proxy_pass  http://localhost:8080;
                    try_files $uri $uri/ =404;
             }
    }
    参数说明:
    root:根目录
    proxy_pass: 代理
     
     
    一、实现多项目管理
     
    1.apache监听端口,/etc/apache2/ports.conf
    vi /etc/apache2/ports.conf
    
    #然后添加监听端口
    Listen
    8081
        2.复制 000-default.conf配置虚拟机
    sudo cp 000-default.conf 8081.conf
    进入8081.conf配置如下:
    <VirtualHost *:8081>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/CRM
            #ServerName localhost
            #LogLevel info ssl:warn
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            #Include conf-available/serve-cgi-bin.conf
     
             <Directory /var/www/CRM>
                    #Options FollowSymLinks
                    #Options Indexes FollowSymLinks MultiViews 
                    #AllowOverride None
                    DirectoryIndex index.html index.htm index.php
             </Directory>
     </VirtualHost>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    查看代码
     
        3.配置完成还得讲8081.conf文件链接到 sites-enabled 目录下
    sudo ln -s //etc/nginx/sites-available/80 /etc/nginx/sites-available/81
     
        4.配置nginx代理
     
    进入 /etc/nginx/sites-available文件,复制80
    sudo cp /etc/nginx/sites-available/80 /etc/nginx/sites-available/81 
     
    修改81文件的内容如下:
    server {
            listen 81;
            listen [::]:81;
    
            server_name 127.0.0.1;
     
            root /var/www/CRM/;
            index index.html,index.php;
     
            location / {
                     proxy_pass  http://localhost:8081;
                     try_files $uri $uri/ =404;
            }
     }
    查看代码
    这里需要注意,root应该为项目根目录,也就是说,在该目录下应该有入口文件;proxy_pass 的8081也应该跟apache的端口一致
     
     
    3、负载均衡
     
     
     
    功能完善中。。。
     
     
  • 相关阅读:
    魔兽世界服务器Trinitycore分析二:auth server的main函数
    白话经典算法系列之七 堆与堆排序
    Opencv学习笔记(六)SURF学习笔记
    sprintf,你知道多少?
    色相环上面的颜色和相邻颜色的关系是什么
    视达配色教程10 绿色的意向是什么
    网页设计实战3 ufo类型的科技网页如何实现
    如何使用echo.js实现图片的懒加载(整理)
    网页设计实战1 如何实现纸叠登录效果
    人为什么要好好努力学习工作
  • 原文地址:https://www.cnblogs.com/cap-rq/p/9984386.html
Copyright © 2020-2023  润新知