mac安裝vagrant訪問laraval歡迎頁面,執行時間15秒,安裝nfs掛載點(親測可行)

      網友投稿 694 2022-05-30

      問題說明,在vagrant虛擬機中啟動cii 框架項目的時候沒問題,但在啟動laravel項目的時候花費17S,這明顯不符合常理嗎?

      造成此問題的原因,是虛擬機共享文件系統 IO 速度慢所導致的。而一個全新安裝的 Laravel 應用響應一個請求時,需要讀取 600+ 的文件,瓶頸尤為明顯。

      補充:以下親測可行方法

      1.本地Mac系統不需要安裝,我的是在不清楚的情況下安裝了,每次報錯,所以卸載就好

      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 #卸載插件

      2修改后:?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"

      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 文件,這個是在vagrant up 啟動過程中自動生成的

      # 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

      成功啟動后:

      如果報錯

      sudo rm /etc/exports

      sudo touch /etc/exports

      sudo chmod -R 777 exports #有權限問題的話加這一步

      ================以下僅供參考==============

      Vagrant虛擬機系統:CentOS6.5

      首先要把虛擬機的網絡設置成?:private_network?模式。

      1、虛擬機安裝nfs服務:

      centos 5 :

      yum -y install nfs-utils portmap

      centos 6 :

      yum -y install nfs-utils rpcbind

      2、MAC?OS已經集成nfs,只需要修改/etc/eprots文件,如果沒有則新建

      sudo vi /etc/exports ? 保持空文件即可

      3、Vagrantfile文件修改

      config.vm.synced_folder ".", "/vagrant", type: "nfs"

      保存后,使用命令?vagrant reload?重啟虛擬機后才會生效,期間會修改MAC OX的?/etc/exports?文件。會提示輸入mac賬號的密碼。輸入即可!

      2015-02-02最新更新:vagrant官方說明中發現了一段內同

      mac安裝的vagrant訪問laraval歡迎頁面,執行時間15秒,安裝nfs掛載點(親測可行)

      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/exportsautomatically 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.

      可以設置?nfs_export的屬性為true即可忽略文件的修改,會假設已經把文件設置好。

      默認采用的是UDP協議。

      NFS協議使用的版本:默認為3

      nfs ? 支持windows

      vagrant plugin install vagrant-winnfsd

      vagrant plugin list

      卸載插件:Vagrant up problem: sh: netsh: command not found - Stack Overflow

      vagrant plugin uninstall vagrant-winnfsd

      git commit 報錯:

      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: 無法創建樹對象

      解決方案:成功提交文件

      在客戶端,我的是mac端

      sudo chmod 777 -R .git/objects

      即可

      其他方式:可參考:NFS服務的用戶身份映射??【NAS】NFS客戶端掛載目錄后無寫入權限的解決方案

      ===================以下供參考,據說不太好使=====================

      使用 Homestead 在開發 Laravel 應用程序,經常會遇到網頁響應速度緩慢,有時甚至十幾秒甚至幾十秒才返回響應,極大影響了開發體驗:

      造成此問題的原因,是虛擬機共享文件系統 IO 速度慢所導致的。而一個全新安裝的 Laravel 應用響應一個請求時,需要讀取 600+ 的文件,瓶頸尤為明顯。

      解決問題

      解決方案是讓虛擬機使用 IO 效率更高的 NFS 掛載方式。

      第一步、安裝 NFS 服務

      我們需要在主機的系統里安裝 NFS 服務供虛擬機使用。

      Mac 用戶默認支持 NFS 掛載。

      Windows 用戶 需要安裝 Vagrant WinNFSd ,在你的 Git Shell (或者其他 Windows Shell)里運行以下命令進行安裝:

      $ vagrant plugin install vagrant-winnfsd

      Ubuntu 用戶 可以使用以下命令安裝 NFS 服務:

      $ apt-get install nfs-kernel-server

      第二步、修改配置

      接下來修改 Homestead.yaml 文件里的 folders 文件掛載信息,指定掛載的 type 為 NFS:

      folders:

      - map: ~/code

      to: /home/vagrant/code

      type: "nfs"

      第三步、重啟并應用虛擬機

      因為我們修改了 Homestead.yaml ,需要 --provision 參數來應用虛擬機修改,并使用 reload 來重啟虛擬機:

      $ vagrant reload --provision

      結語

      以上配置成功后,一般情況下,你應該可以得到 1s 內的響應速度。

      轉自鏈接: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可參考:??vagrant 基本命令、標準配置文件,支持nfs_ghostyusheng 's blog-CSDN博客

      參考:https://gist.github.com/ikennaokpala/79f033880ecd38272a411350c6d573c0

      mac vagrant 虛擬機nfs掛載點 - 懶牛拉車 - 博客園

      Mac OS 虛擬化

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:一些常用的知識點
      下一篇:第2章TCPIP協議 網絡層arp 網絡接口層
      相關文章
      亚洲人成无码网站在线观看| 亚洲国产精品日韩在线观看| 亚洲人成网站色在线观看| 久久久亚洲裙底偷窥综合| 亚洲av中文无码乱人伦在线播放 | 亚洲AV成人精品一区二区三区| 色噜噜亚洲男人的天堂| 亚洲乱码日产精品BD在线观看| 亚洲精品成人无码中文毛片不卡| 亚洲综合色婷婷七月丁香| 国产成人 亚洲欧洲| 亚洲AV永久无码精品一福利| 亚洲fuli在线观看| 亚洲jjzzjjzz在线播放| 国产成人精品日本亚洲11| 亚洲自国产拍揄拍| 亚洲欧洲日韩国产一区二区三区| 亚洲va成无码人在线观看| 亚洲 暴爽 AV人人爽日日碰| 99999久久久久久亚洲| 午夜在线a亚洲v天堂网2019| 精品国产成人亚洲午夜福利| 中文字幕在线观看亚洲视频| 四虎必出精品亚洲高清| 亚洲一卡2卡三卡4卡无卡下载| 亚洲一区二区三区成人网站| 亚洲AV无码专区亚洲AV桃| vvvv99日韩精品亚洲| 亚洲美日韩Av中文字幕无码久久久妻妇 | 亚洲欧美国产国产综合一区| 亚洲高清毛片一区二区| 精品亚洲视频在线| 中文字幕亚洲一区二区va在线| 国产亚洲精品a在线无码| 亚洲精选在线观看| 亚洲国产精品综合久久久| 中文无码亚洲精品字幕| 亚洲精品无码久久| 国产成人精品日本亚洲专区 | 亚洲卡一卡二卡乱码新区| 亚洲国产AV一区二区三区四区|