关于vagrant一个虚拟机搭建多个项目配置(总结)
问题1:执行vagrant status命令,报错,没有找到命令,翻译;“vargrant bash命令没有找到。”
解答:因为在/home目录中,所有无法执行该命令,需要切换到外部进行执行
问题2:在一个虚拟机中,添加多个项目
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,
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/
命令:
sudo vi lxw.com.conf 不用切换到root用户直接使用root的权限
sudo service nginx reload 重启nginx 服务
关于vagrant一个虚拟机搭建多个项目配置(总结)的更多相关文章
- webpack入门级 - 从0开始搭建单页项目配置
前言 webpack 作为前端最知名的打包工具,能够把散落的模块打包成一个完整的应用,大多数的知名框架 cli 都是基于 webpack 来编写.这些 cli 为使用者预设好各种处理配置,使用多了就会 ...
- [转]Java Web笔记:搭建环境和项目配置(MyEclipse 2014 + Maven + Tomcat)
来源:http://www.jianshu.com/p/56caa738506a 0. 绪言 Java Web开发中,除了基础知识外,开发环境搭建,也是一项基本功.开发环境包括了IDE.项目管理.项目 ...
- 一个jetty部署多个项目配置之方法一
https://my.oschina.net/wangyongqing/blog/115647 Jetty用户经常想配置他们的web应用到不同的虚拟主机. 通常情况下,一个单一的IP地址的机器有不同的 ...
- VMware如何克隆一个虚拟机
如何在Vmware克隆一个虚拟机,并修改哪些配置. 克隆虚拟机步骤 其中模板虚拟机的安装部署可参见:「VMware安装Linux CentOS 7.7系统」 找到克隆的模板机,并选择克隆. 进入克隆虚 ...
- 第一章 搭建一个通用的.net core项目框架
项目目标部署环境:CentOS 7+ 项目技术点:.netcore2.0 + Autofac +webAPI + NHibernate5.1 + mysql5.6 + nginx 开源地址:https ...
- 一起来学Spring Cloud | 第一章 :如何搭建一个多模块的springcloud项目
在spring cloud系列章节中,本来已经写了几个章节了,但是自己看起来有些东西写得比较杂,所以重构了一下springcloud的章节内容,新写了本章节,先教大家在工作中如何搭建一个多模块的spr ...
- 用Vagrant和Ansible搭建持续交付平台
这是一个关于Vagrant的学习系列,包含如下文章: Vagrant入门 创建自己的Vagrant box 用Vagrant搭建Jenkins构建环境 用Vagrant和Ansible搭建持续交付平台 ...
- Kafka1 利用虚拟机搭建自己的Kafka集群
前言: 上周末自己学习了一下Kafka,参考网上的文章,学习过程中还是比较顺利的,遇到的一些问题最终也都解决了,现在将学习的过程记录与此,供以后自己查阅,如果能帮助到其他人,自然是更好的. ...
- Linux vagrant+virtualbox环境搭建步骤
Linux vagrant+virtualbox环境搭建步骤 Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用. 我们可 ...
随机推荐
- 整理volatile相关知识点
前言:volatile关键字在面试中经常被问到,从volatile关键字可以引申出许多知识点,因此有必要对此进行总结.本文根据<深入理解Java虚拟机——JVM高级特性与最佳实践>中的相关 ...
- docker学习笔记(二)-dockerfile docker仓库
dckerfile2这样写才对,不然打印的是hello $name 例子 登陆https://hub.docker.com 上面是提交到公共仓库 创建本地私有仓库 开启另外一个虚机,将重新构建上传镜像 ...
- 清除tomcat日志文件的shell脚本
#! /bin/bash d=`date +%F` exec >> /mydata/script/logs/$d>& echo "开始执行清除tomcat日志文件& ...
- [TJOI2018]碱基序列
嘟嘟嘟 现在看到字符串就想到SAM,所以很担心kmp啥的会不会忘了-- 这题感觉挺暴力的:首先当然要把\(s\)建成SAM,然后令\(dp[i][j]\)表示到第\(i\)组时,SAM上节点\(j\) ...
- 转://Oracle中User和Schema的区别和联系
今天在阅读Oracle官方文档的时候,读到schema的基本概念,这就让我产生了一个疑问:user和schema两者之间到底有什么区别?为了更深层次的理解二者之间的区别和联系,以下是官方文档中关于us ...
- 四、Oracle 序列、常用函数、多表连接
一.序列定义:是oracle数据库专门用来产生连续且自动增长的数字的对象创建语法:create sequence 序列名(sq_表名) nocache(无缓存) create sequence sq_ ...
- 机器学习三剑客之Pandas中DataFrame基本操作
Pandas 是基于Numpy 的一种工具,是为了解决数据分析任务而创建的.Pandas 纳入了大量库和一些标准的数据模型,提供了高效地操作大型数据集所需的工具.Pandas提供了大量能使我们快速便捷 ...
- 1、FreeRTOS移植
1.FreeRTOS目录结构 FreeRTOS FreeRTOS简略目录如下: ├─FreeRTOS │ ├─Demo // 各种开发工具的完整Demo,开发者可以方便的以此搭建出自己的项目,甚至直接 ...
- Python实现分发数据块到多台服务器上
代码如下: # coding: utf-8 import paramiko import re import os from time import sleep # 定义一个类,表示一台远端linux ...
- navicat 和 pymysql
---------------------------------------------------相信时间的力量,单每月经过努力的时间,一切的安排都是懊脑的安排. # # ------------ ...