This Gist shows how to run CentOS linux distro native or on a Vagrant virtual machine with Nginx. Access it locally or via host to the 'localhost:80'. Also show how to make Laravel servers to run and access the url both locally and via host at 'localhost:8000'
- Via PowerShell
- Download CentOS 7 x86_64 Vagrant box
- Download and install Vagrant 2.0.2 x86_64
- Create Vagrant directories
- Add CentOS 7 x86_64 box to Vagrant
- Configure Vagrantfile
- Start CentOS 7 box
$centos7box_url = "https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box";
$box_filename = $centos7box_url.SubString($centos7box_url.LastIndexOf('/') + 1);
$box_target = "$Env:UserProfile\Downloads\$box_filename";
$WebClient = (New-Object System.Net.WebClient);
$WebClient.DownloadFile("$centos7box_url", $box_target);
$token = "?_ga=2.261808136.406962179.1520208830-1365469008.1516682057";
$vagrant_url = "https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.msi";
$vagrant_filename= $vagrant_url.SubString($vagrant_url.LastIndexOf('/') + 1);
$vagrant_target = "$Env:UserProfile\Downloads\$vagrant_filename";
$WebClient = (New-Object System.Net.WebClient);
$WebClient.DownloadFile("$vagrant_url$token", $vagrant_target);
Start-Process msiexec.exe -Wait -ArgumentList "/I $vagrant_target /quiet";
Verifying Vagrant:
vagrant --version
Expected output:
Vagrant 2.0.2
$outpath = "$Env:UserProfile\Vagrant";
New-Item -ItemType directory -Path $outpath;
New-Item -ItemType directory -Path $outpath\centos7box;
Move-Item -Path $vagrant_target -Destination $outpath\centos7box\vagrant_filename
Set-Location $outpath\centos7box
vagrant box add centos7box .\vagrant_filename
vagrant init centos7box
$Vagrantfile = "
Vagrant.configure("2") do |config|
config.vm.box = "centos7dcm4chee"
config.vm.network ""forwarded_port"", guest: 80, host: 8080, auto_correct: true
config.vm.network ""forwarded_port"", guest: 8000, host: 8000, auto_correct: true
config.vm.network ""forwarded_port"", guest: 90, host: 9090, auto_correct: true
config.vm.network ""forwarded_port"", guest: 9000, host: 9000, auto_correct: true
config.vm.network ""private_network"", ip: ""192.168.68.8""
config.vm.network ""public_network""
config.vm.provision ""shell"", inline: <<-SHELL
sudo su
export LANG=en_US.UTF-8
SHELL
end
";
Set-Content -Path .\Vagranfile -Value $Vagrantfile;
vagrant up
vagrant ssh
sudo chown -R $(whoami) /usr/local/Homebrew/