Skip to content

Instantly share code, notes, and snippets.

@natanaelfneto
Last active March 5, 2018 14:14
Show Gist options
  • Save natanaelfneto/ebdcec4ca41262366d35011c1640325c to your computer and use it in GitHub Desktop.
Save natanaelfneto/ebdcec4ca41262366d35011c1640325c to your computer and use it in GitHub Desktop.
How to run CentOS 7 .... incomplete

CentOS 7 and Nginx with Laravel Servers

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'


Content Table

  1. Via PowerShell
    1. Download CentOS 7 x86_64 Vagrant box
    2. Download and install Vagrant 2.0.2 x86_64
    3. Create Vagrant directories
    4. Add CentOS 7 x86_64 box to Vagrant
    5. Configure Vagrantfile
    6. Start CentOS 7 box

Via PowerShell

Download CentOS 7 x86_64 Vagrant 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);

Download and install Vagrant 2.0.2 x86_64

$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

Create Vagrant directories

$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

Add CentOS 7 x86_64 box to Vagrant

Set-Location $outpath\centos7box
vagrant box add centos7box .\vagrant_filename
vagrant init centos7box

Configure Vagrantfile

$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;

Start CentOS 7 box

vagrant up
vagrant ssh
@pvguerra
Copy link

pvguerra commented Feb 5, 2018

sudo chown -R $(whoami) /usr/local/Homebrew/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment