下載vagrant軟件包 地址, 安裝(windows傻瓜式安裝, 很少說).php
建立vagrant工程目錄, 初始化Vagrantfile.html
F:\> mkdir vagrant F:\> cd vagrant F:\vagrant>vagrant.exe init A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.
添加box(相似docker的容器), 到官方源下載須要的box, 本案例下載(puppetlabs/centos-6.6-64-nocm)(https://atlas.hashicorp.com/puppetlabs/boxes/centos-6.6-64-nocm),公司服務器是centos6.x.mysql
F:\vagrant>vagrant box add puppetlabs/centos-6.6-64-nocm ==> box: Loading metadata for box 'puppetlabs/centos-6.6-64-nocm' box: URL: https://atlas.hashicorp.com/puppetlabs/centos-6.6-64-nocm This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) virtualbox 2) vmware_desktop Enter your choice: 1 ==> box: Adding box 'puppetlabs/centos-6.6-64-nocm' (v1.0.3) for provider: virtualbox box: Downloading: https://atlas.hashicorp.com/puppetlabs/boxes/centos-6.6-64-nocm/versions/1.0.3/providers/virtualbox.box box: Progress: 0% (Rate: 27052/s, Estimated time remaining: 3:23:32)==> box: Waiting for cleanup before exiting... box: Progress: 0% (Rate: 23813/s, Estimated time remaining: 3:26:33) ==> box: Box download was interrupted. Exiting.
ps: 慢的有的一B啊, 果斷複製連接, 迅雷下載, 安裝*.box文件. 速度還能接受.
linux
box命令略解: vagrant box add [可選參數] <官方源名稱, url連接地址, 下載後的*.box文件>
web
安裝box文件(秒幹):sql
F:\vagrant>vagrant box add --name puppetlabs/centos-6.6-64-nocm F:\boxes\virtualbox.box ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'puppetlabs/centos-6.6-64-nocm' (v0) for provider: box: Unpacking necessary files from: file://F:/boxes/virtualbox.box box: Progress: 100% (Rate: 658M/s, Estimated time remaining: --:--:--) ==> box: Successfully added box 'puppetlabs/centos-6.6-64-nocm' (v0) for 'virtualbox'!
使用剛下在的boxdocker
編輯vagrant工程目錄下的Vagrantfile文件apache
15行: config.vm.box = "puppetlabs/centos-6.6-64-nocm"
啓動vagrant(此處會啓動virtualbox, 預先安裝virtualbox, win7安裝有點小問題, 請自行google或百度解決)windows
vagrant up
ssh上去(默認F:/vagrant 自動掛載到/vagrant)上centos
F:\vagrant>vagrant ssh Last login: Fri May 6 02:33:11 2016 from 10.0.2.2 [vagrant@localhost ~]$ ls / bin boot dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr vagrant var [vagrant@localhost ~]$
在/vagrant建立的文件, 會同步到 F:>vagrant下.
本案列使用 apache2.4, php5.6.12 mysql5.7 編譯安裝, 源文件都一打包好, 有須要能夠找我要loovien@163.com.
默認全部服務安裝到/usr/local/webserver目錄下.
安裝必要的依賴.
$ sudo yum groupinstall "Development tools"
apache2.4 編譯.
./configure && make && make install
../configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-headers --enable-usertrack --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --with-include-apr --prefix=/usr/local/webserver
, make && make install
編譯php
安裝依賴, 沒辦法, 編譯就是這樣, 少了什麼依賴就安裝什麼依賴, 編譯安裝.
$ sudo yum install libxml2 libxml-devel
$ ./configure --prefix=/usr/local/webserver/php --with-mysql
$ make && make install
編譯mysql
運行項目可能須要編譯php擴展, 自行安裝便可, 使用 phpize
.
在/etc/rc.local, 添加apache2, mysql 啓動命令, 是開機啓動.