关于vagrant一个虚拟机搭建多个项目配置(总结)

关于vagrant一个虚拟机搭建多个项目配置(总结)

问题1:执行vagrant status命令,报错,没有找到命令,翻译;“vargrant bash命令没有找到。”

关于vagrant一个虚拟机搭建多个项目配置(总结)

解答:因为在/home目录中,所有无法执行该命令,需要切换到外部进行执行

关于vagrant一个虚拟机搭建多个项目配置(总结)

问题2:在一个虚拟机中,添加多个项目

关于vagrant一个虚拟机搭建多个项目配置(总结)关于vagrant一个虚拟机搭建多个项目配置(总结)

 

lxw.com.conf配置
server
    {
        listen 80;
        #listen [::]:80;
        server_name lxw.com www.lxw.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /vagrant/2019bak;

        include rewrite/none.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

 test.com.conf配置文件

server
    {
        listen 80;
        #listen [::]:80;
        #server_name _;
        server_name 192.168.10.250 test.com www.test.com 
        index index.html index.htm index.php default.html default.htm default.php;
        root  /vagrant/laizheer/public;

        include rewrite/none.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }  

  

 本地host文件配置,“192.168.10.250”需要与Vagrantfile文件中配置的public_network,IP一致,192.168.10.250等同于远程服务器的IP,

关于vagrant一个虚拟机搭建多个项目配置(总结)

关于vagrant一个虚拟机搭建多个项目配置(总结)

Vagrantfile配置

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "Centos-7"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "public_network", ip: "192.168.10.250"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
#config.vm.synced_folder "../www/laizheer", "/home/wwwroot/defalut"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
 vb.gui = false
  #
  #   # Customize the amount of memory on the VM:
vb.memory = "4096"
vb.cpus = "2"
end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end  

 补充:当lxw.com.conf监听端口改变为8080后,访问时对应改变端口  http://lxw.com:8080/

关于vagrant一个虚拟机搭建多个项目配置(总结)

 命令:

sudo vi lxw.com.conf  不用切换到root用户直接使用root的权限

sudo service nginx reload 重启nginx 服务

 

总结:

mac下给vagrant添加多个项目的步骤:

1.修改/usr/local/nginx/conf/nignx.conf,将域名和文件夹目录添加进去

关于vagrant一个虚拟机搭建多个项目配置(总结)

Vagrantfile文件文中项目件夹配置如下

关于vagrant一个虚拟机搭建多个项目配置(总结)

2.修改本地mac中host地址

sudo vi /etc/hosts

参考:https://www.jianshu.com/p/752211238c1b

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/112410.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 141. 环形链表(链表)

    141. 环形链表(链表)给定一个链表,判断链表中是否有环。如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。注意:pos 不作为参数进行传递,仅仅是为了标识链表的实际情况。如果链表中存在环,则返回 true 。 否则,返回 false 。进阶:你能用 O(1)(即,常量)内存解决此问题吗?示例 1:输入:head = [3,2,0,-4],

    2022年8月9日
    7
  • CSS画三角形及其原理

    CSS画三角形及其原理本文转自https://blog.csdn.net/pengjunlee/article/details/53002553搜索网络之后发现三角形可以通过以下CSS代码实现:#triangle_bottom{height:0px;width:0px;border-left:20pxsolidtransparent;border-right:20pxsolidtransparent…

    2022年6月23日
    27
  • pycharm激活码2022.01.13【2022最新】2022.01.23

    (pycharm激活码2022.01.13)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月31日
    96
  • Java实现判断闰年

    Java实现判断闰年Java实现闰年判断需求分析:年份如果满足以下两个条件中的其中一个则可将其年份判断位闰年一、能被4整除,但不能被100整除,就是闰年;二、能被400整除,也是闰年;需求实现方案一:使用if的嵌套实现packagecom.qingsu.basis;importjava.util.Scanner;publicclassProcessControl{ publicstaticvoidmain(String[]args){ //判断闰年 //1.能被4整除

    2022年7月17日
    17
  • 揭开IT基础架构综合管理平台软件的面纱

    揭开IT基础架构综合管理平台软件的面纱

    2021年7月27日
    59
  • 局域网和广域网_简单的局域网怎么搭建

    局域网和广域网_简单的局域网怎么搭建局域网1、什么是局域网:局域网是封闭型的,可以由办公室内的两台计算机组成,也可以由一个公司内的上千台计算机组成。也称为内网。2、局域网怎么实现:以太网是全球使用最广泛的局域网技术,有线局域网通常通过双绞线(一般直接说网线)连接;无线局域网现在一般通过交换机、路由器实现。3、局域网可以干什么:局域网可以实现文件管理、应用软件共享、打印机共享、工作组内的日程安排、电子邮件和传真通信服务等功能。广域网1、什么是广域网:将各局域网或城域网连接起来便是广域网,也称为外网或公网。2、广域网怎么实现:现在的传

    2022年10月19日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号