Description of the problem, no problem to start projects in the framework of vagrant cii virtual machine time, but when you start laravel project costs 17S, which is obviously not consistent with common sense it?
The cause of this problem is the virtual machine shared file system IO slow caused. And when a new application is installed Laravel response to a request, you need to read 600 + file, especially the bottleneck.
Added: The following pro-test possible ways
1. Local Mac systems do not require installation, I was installed in unclear circumstances of each error, so uninstall just fine
sudo rm /etc/exports
sudo touch /etc/exports
sudo chmod -R 777 exports #有权限问题的话加这一步
sudo vagrant halt
sudo vagrant up --provision #在启动过程中,会询问是否允许更改exports文件,直接允许就好
vagrant plugin uninstall vagrant-winnfsd #卸载插件
After 2 modification: Vagrantfile file
# -*- 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"
config.vm.boot_timeout = 360
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
# 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
# config.vm.network "forwarded_port", guest: 82, host: 8082, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 83, host: 8083, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 84, host: 8084, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 85, host: 8085, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 86, host: 8086, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 87, host: 8087, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 3306, host: 33306, host_ip: "127.0.0.1"
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "localhost"
# config.vm.network "forwarded_port", guest: 81, host: 8081, host_ip: "localhost"
config.vm.synced_folder "../../../Users/liutao/Desktop/vagrant", "/home/wwwroot/default",nfs: true, nfs_udp: true
# 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.11"
#端口转发
#config.vm.network "forwarded_port", guest: 8080, host: 8080, auto_correct: true
# 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",ip: "192.168.33.10"
# 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 "../data", "/vagrant_data"
# 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 = true
#
# # Customize the amount of memory on the VM:
vb.memory = "512"
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
/ Etc / exports file modified, this is automatically generated in the vagrant up the boot process
# VAGRANT-BEGIN: 0 528272d2-254a-4d20-a6cb-19671440688c
"/Users/liutao/Desktop/vagrant" 192.168.33.11 -alldirs -mapall=501:20
# VAGRANT-END: 0 528272d2-254a-4d20-a6cb-19671440688c
After the successful start:
If an error
sudo rm /etc/exports
sudo touch /etc/exports
sudo chmod -R 777 exports #有权限问题的话加这一步
================ The following is for reference only ==============
Vagrant virtual machine system: CentOS6.5
First put into a virtual machine's network settings: private_network mode.
1, the virtual machine to install nfs service:
CentOS 5:
yum -y install nfs-utils portmap
centos 6:
yum -y install nfs-utils rpcbind
2, the MAC the OS has been integrated NFS, only need to modify / etc / eprots document, if not the new
sudo vi /etc/exports 保持空文件即可
3, Vagrantfile file modification
config.vm.synced_folder ".", "/vagrant", type: "nfs"
After saving, use the command vagrant reload after the restart the virtual machine to take effect, will modify the MAC OX / etc / exports file period. Mac will be prompted to enter the account password. Input can be!
2015-02-02 Latest update: vagrant official explanation was found in the same period
NFS synced folders have a set of options that can be specified that are unique to NFS. These are listed below. These options can be specified in the final part of theconfig.vm.synced_folder
definition, along with the type
option.
nfs_export
(boolean) – If this is false, then Vagrant won’t modify your/etc/exports
automatically and assumes you’ve done so already.nfs_udp
(boolean) – Whether or not to use UDP as the transport. UDP is faster but has some limitations (see the NFS documentation for more details). This defaults to true.nfs_version
(string | integer) – The NFS protocol version to use when mounting the folder on the guest. This defaults to 3.
You can set properties to modify nfs_export true to ignore the file, the file will be assumed to have been set up.
The default uses the UDP protocol.
NFS protocol version used: The default is 3
nfs support windows
vagrant plugin install vagrant-winnfsd
vagrant plugin list
Uninstall the plug-: https://stackoverflow.com/questions/54294057/vagrant-up-problem-sh-netsh-command-not-found
vagrant plugin uninstall vagrant-winnfsd
git commit an error:
git pull 报错:error: insufficient permission for adding an object to repository database .git/objects
error: insufficient permission for adding an object to repository database .git/objects error: 无法创建树对象
Solution: Successful submissions
在客户端,我的是mac端
sudo chmod 777 -R .git/objects
即可
Otherwise: Reference: user identity NFS service mapping [NAS] NFS client after the mount directory solutions without written permission
=================== The following for reference, it is said not working =====================
Homestead Laravel use in the development of applications, often experience slow website response speed, sometimes even ten seconds or even tens of seconds before returning the response, which greatly influenced the development experience:
The cause of this problem is the virtual machine shared file system IO slow caused. And when a new application is installed Laravel response to a request, you need to read 600 + file, especially the bottleneck.
Problem-solving
solution is to have a virtual machine to use higher efficiency NFS mount IO mode.
The first step, install the NFS service
we need to install NFS on the host system services for the virtual machines.
Mac users supported by default NFS mount.
Windows users need to install Vagrant WinNFSd, run the following command in your Git Shell (or other Windows Shell) in the installation:
$ vagrant plugin install vagrant-winnfsd
Ubuntu users can use the following command to install the NFS service:
$ apt-get install nfs-kernel-server
The second step, modify the configuration
the next Homestead.yaml modify documents in file folders mount information, the type is specified mount NFS:
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
The third step is to restart the virtual machine and application
because we have modified the Homestead.yaml, --provision parameters need to apply the virtual machine to modify and use reload to restart the virtual machine:
$ vagrant reload --provision
Conclusion
After the above configuration is successful, under normal circumstances, you should be able to get a response speed within 1s.
Transfer link: https: //learnku.com/laravel/wikis/2555
setp 1 :centos安装nfs
yum install nfs-utils rpcbind
setp 2 :MAC OS已经集成nfs,只需要修改/etc/exports文件,如果没有则新建
setp 3 : Vagrantfile文件修改
config.vm.synced_folder "~/www", "/data", type: “nfs"
注:~/www为mac机器的目录。/data为虚拟机的目录。
保存后,使用命令 vagrant reload 重启虚拟机后才会生效,期间会修改MAC OX的 /etc/exports 文件。会提示输入mac账号的密码。输入即可!
然后,你会发现mac上的~/www 目录和虚拟机上的/data目录是互通的。开始配置你的网站吧
window may refer to: https://blog.csdn.net/ghostyusheng/article/details/64923272
Reference: https://gist.github.com/ikennaokpala/79f033880ecd38272a411350c6d573c0