关于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 应用. 我们可 ...
随机推荐
- [Git] Git操作命令
基础操作 git配置 git config --global user.name "Your Name" git config --global user.email " ...
- 转://Oracle 事务探索与实例(一)
一数据库版本 SYS@LEO1>select* from v$version; BANNER -------------------------------------------------- ...
- 16.xml
一.xml 1.什么是XML:是一种可扩展的标记语言,所有标记都可以自定义,常用来做配置文件和数据传输的载体2.语法:标签(元素):<元素名> 值 </元素名>属性:在元素中 ...
- nginx之十三:搭建 nginx 反向代理用做内网域名转发
user www www;worker_processes 1;error_log logs/error.log;pid logs/nginx.pid;worker_rlimit_nofile 6 ...
- P3368 【模板】树状数组 2--洛谷luogu
题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数数加上x 2.求出某一个数的值 输入输出格式 输入格式: 第一行包含两个整数N.M,分别表示该数列数字的个数和操作的总个数. ...
- 在DreamView中支持一辆新车
Support a new Vehicle in DreamView In order to support a new vehicle in DreamView, please follow the ...
- <网络编程>基本TCP套接字编程
tcp提供了可靠传输,当tcp向另一端发送数据的时候,要求对端返回一个确认.如果没有接收到确认,tcp就重传数据并且等待更长时间,数次重传失败后,tcp才放弃. 建立一个tcp连接会发生如下事情: 服 ...
- Python中print和return的区别
有趣的事,Python永远不会缺席! 如需转发,请注明出处:小婷儿的python https://www.cnblogs.com/xxtalhr/p/10742671.html 一.解释 1.ret ...
- (转)MySQL慢查询分析优化 + MySQL调优
.long_query_time的默认值为10,意思是运行10S以上的语句. .临时设置开启慢查询日志 mysql> show variables like '%slow_query_log%' ...
- Java网络编程中异步编程的理解
目录 前言 一.异步,同步,阻塞和非阻塞的理解 二.异步编程从用户层面和框架层面不同角度的理解 用户角度的理解 框架角度的理解 三.为什么使用异步 四.理解这些能在实际中的应用 六.困惑 参考文章 前 ...