最近正好用着Vagrant搭建開發環境,寫一篇文章記錄一下。php
Vagrant目前是國內互聯網公司應用最多的內部開發環境工具。mysql
Mac、 Windows搭建是同樣的,我是在Mac下搭建的環境。nginx
vagrant 搭建開發環境laravel
virtualbox 5.1.8
下載地址:https://www.virtualbox.org/wiki/Download_Old_Builds_5_1git
vagrant 1.8.6
下載地址:https://releases.hashicorp.com/vagrant/1.8.6github
box下載web
地址1:https://github.com/CommanderK5/packer-centos-template/releases/download/0.6.7/vagrant-centos-6.7.boxsql
地址2: https://github.com/CommanderK5/packer-centos-template/releases/thinkphp
下載以後請確保文件名爲centos6.7.boxapache
替換源
1 deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 2 deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 3 deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 4 deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 5 deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 6 deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 7 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 8 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 9 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 10 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
L(A|N)MP
Ngnix
sudo apt-get install nginx
nginx -v
nginx version: nginx/1.4.6
Apache
sudo apt-get install apache2
apache2 -v
Server version: Apache/2.4.7
更改端口,將端口設置爲8888
Mysql
php
安裝php
PHP擴展
支持apache2的php模塊
支持nginx fastcgi
端口轉發
config.vm.network "forwarded_port", guest: 80, host: 8888 config.vm.network "forwarded_port", guest: 8888, host: 8889
網絡設置
配置
config.vm.network "private_network", ip: "192.168.199.101"
效果
共享目錄
配置
config.vm.synced_folder "/Users/code/", "/home/www"
tp5
<Directory /> Options FollowSymLinks AllowOverride None #修改爲AllowOverride ALL 打開rewrite #Require all denied #把這行屏蔽掉,拒絕一切連接 </Directory>
yii2
laravel5
vagrant 經常使用命令
vagrant init 初始化配置
vagrant up 啓動虛擬機
vagrant ssh ssh登陸虛擬機
vagrant suspend 掛起虛擬機
vagrant reload 重啓虛擬機
vagrant halt 關閉虛擬機vagrant status 查看虛擬機狀態vagrant destroy 刪除虛擬機