Vagrant Macos Box

broken image


  1. Vagrant Osx Box
  2. Vagrant Macos Box Mojave

Vagrant is a command-line utility used to manage the lifecycle of virtual machines.

Sudo rm /opt/vagrant/embedded/bin/curl. Note: you also need to remove the embedded curl when you add a vagrant box (remotely or locally) so if you get the same error when running vagrant box add. Just remove the curl from vagrant and it will work. Vagrant package -base VirtualBoxVMName -output /path/to/output/windows.box -vagrantfile /path/to/initial/Vagrantfile Replace VirtualBoxVMName with the name of your base box as it appears in the VirtualBox UI. Replace /path/to/output/windows.box with the path where you would like the Vagrant base box file to be saved. Add the Vagrant box you want to use. We'll use Ubuntu 12.04 for the following example. $ vagrant box add precise64 You can find more boxes at Vagrant Cloud Now create a test directory and cd into the test directory.

PhpStorm provides a full integration with Vagrant allowing you to configure the Vagrant virtual environment, control the behavior of virtual machines, and execute Vagrant commands from within your project.

In the context of working with Vagrant, you will meet the following definitions:

  • Vagrantfile: the main configuration file that defines the Vagrant environment, stores all the configuration for the virtual boxes and tells Vagrant how to work with virtual machines.

  • Virtual box: a virtual sandbox that contains a preconfigured virtual machine. Vagrant works with different providers of virtual boxes, such as Oracle's VirtualBox, VMWare or AWS.

  • Instance: a virtual machine.

In this article, we will explain how to initialize the Vagrantfile, specify the virtual box, run and interact with the virtual machine from PhpStorm.

Prerequisites

Mojave
  1. Install and enable Vagrant plugin as described in Installing plugins from JetBrains repository.

  2. Install Vagrant and Oracle's VirtualBox applications.

  3. Make sure virtualization is enabled on your computer.

Initialize the Vagrantfile

Vagrant Osx Box

To start working with Vagrant, you need to initialize the Vagrantfile.

Do one of the following:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant init

    This will initialize the Vagrantfile and put it into your project root folder by default.

  • From the main menu, choose Tools | Vagrant | Init in Project Root and select the target root folder from the opened window.

In the Project tool window Alt+1, switch to the Project files view and double-click the Vagrantfile to open it in the embedded editor.

You will see that Vagrantfile already has a predefined configuration. The config.vm.box = '...' line specifies the virtual box that will be used in a project.

Specify the virtual box

As an example, we will specify the ubuntu/trusty64 box. It contains a basic Ubuntu virtual machine. You can specify any other virtual box based on your needs. To find a list of available virtual boxes, refer to Discovering Vagrant Boxes.

Do one of the following:

  • Open the Vagrantfile and change config.vm.box = 'base' line to the following: config.vm.box = 'ubuntu/trusty64'.

  • In the Settings/Preferences dialog (Ctrl+Alt+S ), select Tools | Vagrant. In the Boxes window click the button and specify the following:

    • Box name: ubuntu/trusty64

    • Box URL: https://app.vagrantup.com/ubuntu/boxes/trusty64

All the downloaded boxes are stored in the location of the Vagrantfile. To change the default root folder for the virtual boxes, open the Settings/Preferences dialog (Ctrl+Alt+S ), select Tools | Vagrant and change the Instance folder location.

Once the Vagrantfile initialization is completed and virtual box is specified, you are ready to deploy and run the virtual machine.

Launch an instance

Do one of the following:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant up.

    You will see the following output:

  • From the main menu, choose Tools | Vagrant | Up.

SSH into a running machine

When the virtual machine is launched, it runs on a backend. To SSH into a running machine:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant ssh

Vagrant commands to control an instance

To control an instance, use Vagrant commands. They can be run either from Terminal (Alt+F12) or from the main menu.

In this article, we show only the most important commands to work with the virtual machine. To find a full list of available Vagrant commands, refer to Command-Line-Interface.

  • Suspend: suspending an instance pauses all the processes and saves the current state of a virtual machine.

    Run vagrant suspend in Terminal or select Tools | Vagrant | Suspend from the main menu.

  • Resume: resuming an instance brings up a previously suspended virtual machine.

    Run vagrant resume in Terminal or select Tools | Vagrant | Resume from the main menu.

  • Reload: reloading an instance is required when you've made changes to the Vagrantfile and need Vagrant to reload the current virtual environment and its configuration.

    Run vagrant reload in Terminal or select Tools | Vagrant | Reload from the main menu.

  • Shut down: shutting down an instance stops the running virtual machine.

    Run vagrant halt in Terminal or select Tools | Vagrant | Halt from the main menu.

  • Destroy: destroying a virtual machine is important when you need to remove everything related to the previously created environment. All the resources provisioned during the creation of an instance are removed.

    Run vagrant destroy in Terminal or select Tools | Vagrant | Destroy from the main menu.

In this tutorial you will be able to install GitLab Community Edition locally on your mac using a vagrant box. This tutorial has been tested with macOS 10.15 and at the time of writing this tutorial, the latest version of GitLab CE is 12.9.3 and the latest version of Ubuntu is 18.04 (bionic64).

Required

First you must make sure all the following are installed.

  1. Vagrant - download vagrantup.com
  2. Virtual Box - download virtualbox.org
  3. Github Desktop (Optional for section 8) - download desktop.github.com

NOTE: Ruby versions 2.0 and above are included by default in macOS releases since at least El Capitan (10.11).

Vagrant

You should already have ruby installed so lets check this first.

This should output something like.

1. Create the vagrant file

At first in the terminal make the directory that will be used for the GitLab CE installation and set it as default, so for this example 'gitlab-local'.

Then create a vagrant file.

Now open this file.

And replace the content with the following - you may need to change the forwarded_port and private_network to your own settings.

Now startup the vagrant box, this will initially take a while to install all the required files such as Gitlab CE.

Change the host file to recognise http://gitlab.local in your browser by opening the following which should also ask for your password.

Then add the following line at the bottom and save it.

2. Change the default hosting url (gitlab.example.com) for Gitlab CE

Access the Ubuntu terminal of the virtual box.

Vagrant macos box free

Now in the same terminal window edit the following file.

And find and replace.

With.

Then enter the following for the change to take effect.

3. Login to GitLab CE dashboard and change your user details

Open your browser with url http://gitlab.local. The first time around it will ask you to change your password.

Once done it will redirect you to the login page. By default the username is root so just enter this and your new password.

Now you should have access to the Gitlab CE Dashboard.

4. Edit the user account

First thing you should do is change your user details, so choose Settings and change your 'Email' and 'Full name' then press the 'Update profile settings' button.

You will receive an email just to confirm that it's exists. If the external_url has worked correctly the link in the email will work fine.

And then edit your username by selecting Account.

5. Create new repo

Create a new project so for this example I have used first-project.

You will be asked to first generate a SSH key.

6. Generate a new SSH key

Open a new terminal window and enter the following.

Then enter the filename you want the key to be named, just press return if you want to keep the default generated name but I would suggest using a custom name and remember to include the full directory in the filename like below.

Now just press enter twice to keep the passphrase empty.

Open the public key with your naming above.

You will have a line of random code begining with 'ssh-rsa' so copy this for use with GitLab.

Go back to the GitLab CE dashboard and press the Add SSH Key and paste the public key then press Add key.

You should get an email to confirm this.

7. Access the new repo via the terminal (or with the 'GitHub Desktop app' see section 8)

First open the following file and link your ip/url to your key.

And add the following.

So now you can clone the repo by entering this in the terminal.

It will initially ask you the below, so just enter 'yes'.

This should be working fine.

8. Access the new repo with the GitHub Desktop app

With the Github Desktop application things work a little different regarding accessing your repos. So lets start by selecting Settings then Access Tokens on the left navigation.

At first enter a name - so for this example 'First Project' and select the api checkbox. Then press the 'Create personal access token' button.

The page should refresh and generate a code under Your New Personal Access Token. Make sure to get a copy of this code because we will need to use this in the Github Desktop application.

Now select the 'Your Gitlab Name / first-project' repo.

On the following page choose the Clone dropdown button and highlight either the http or https that appears so for example.

Now launch the GitHub Desktop app and choose 'Clone a Repository from the Internet...'.

Input the repo url and the destination folder.

Vagrant Macos Box
  1. Install and enable Vagrant plugin as described in Installing plugins from JetBrains repository.

  2. Install Vagrant and Oracle's VirtualBox applications.

  3. Make sure virtualization is enabled on your computer.

Initialize the Vagrantfile

Vagrant Osx Box

To start working with Vagrant, you need to initialize the Vagrantfile.

Do one of the following:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant init

    This will initialize the Vagrantfile and put it into your project root folder by default.

  • From the main menu, choose Tools | Vagrant | Init in Project Root and select the target root folder from the opened window.

In the Project tool window Alt+1, switch to the Project files view and double-click the Vagrantfile to open it in the embedded editor.

You will see that Vagrantfile already has a predefined configuration. The config.vm.box = '...' line specifies the virtual box that will be used in a project.

Specify the virtual box

As an example, we will specify the ubuntu/trusty64 box. It contains a basic Ubuntu virtual machine. You can specify any other virtual box based on your needs. To find a list of available virtual boxes, refer to Discovering Vagrant Boxes.

Do one of the following:

  • Open the Vagrantfile and change config.vm.box = 'base' line to the following: config.vm.box = 'ubuntu/trusty64'.

  • In the Settings/Preferences dialog (Ctrl+Alt+S ), select Tools | Vagrant. In the Boxes window click the button and specify the following:

    • Box name: ubuntu/trusty64

    • Box URL: https://app.vagrantup.com/ubuntu/boxes/trusty64

All the downloaded boxes are stored in the location of the Vagrantfile. To change the default root folder for the virtual boxes, open the Settings/Preferences dialog (Ctrl+Alt+S ), select Tools | Vagrant and change the Instance folder location.

Once the Vagrantfile initialization is completed and virtual box is specified, you are ready to deploy and run the virtual machine.

Launch an instance

Do one of the following:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant up.

    You will see the following output:

  • From the main menu, choose Tools | Vagrant | Up.

SSH into a running machine

When the virtual machine is launched, it runs on a backend. To SSH into a running machine:

  • Open the embedded Terminal (Alt+F12) and run the following command: vagrant ssh

Vagrant commands to control an instance

To control an instance, use Vagrant commands. They can be run either from Terminal (Alt+F12) or from the main menu.

In this article, we show only the most important commands to work with the virtual machine. To find a full list of available Vagrant commands, refer to Command-Line-Interface.

  • Suspend: suspending an instance pauses all the processes and saves the current state of a virtual machine.

    Run vagrant suspend in Terminal or select Tools | Vagrant | Suspend from the main menu.

  • Resume: resuming an instance brings up a previously suspended virtual machine.

    Run vagrant resume in Terminal or select Tools | Vagrant | Resume from the main menu.

  • Reload: reloading an instance is required when you've made changes to the Vagrantfile and need Vagrant to reload the current virtual environment and its configuration.

    Run vagrant reload in Terminal or select Tools | Vagrant | Reload from the main menu.

  • Shut down: shutting down an instance stops the running virtual machine.

    Run vagrant halt in Terminal or select Tools | Vagrant | Halt from the main menu.

  • Destroy: destroying a virtual machine is important when you need to remove everything related to the previously created environment. All the resources provisioned during the creation of an instance are removed.

    Run vagrant destroy in Terminal or select Tools | Vagrant | Destroy from the main menu.

In this tutorial you will be able to install GitLab Community Edition locally on your mac using a vagrant box. This tutorial has been tested with macOS 10.15 and at the time of writing this tutorial, the latest version of GitLab CE is 12.9.3 and the latest version of Ubuntu is 18.04 (bionic64).

Required

First you must make sure all the following are installed.

  1. Vagrant - download vagrantup.com
  2. Virtual Box - download virtualbox.org
  3. Github Desktop (Optional for section 8) - download desktop.github.com

NOTE: Ruby versions 2.0 and above are included by default in macOS releases since at least El Capitan (10.11).

You should already have ruby installed so lets check this first.

This should output something like.

1. Create the vagrant file

At first in the terminal make the directory that will be used for the GitLab CE installation and set it as default, so for this example 'gitlab-local'.

Then create a vagrant file.

Now open this file.

And replace the content with the following - you may need to change the forwarded_port and private_network to your own settings.

Now startup the vagrant box, this will initially take a while to install all the required files such as Gitlab CE.

Change the host file to recognise http://gitlab.local in your browser by opening the following which should also ask for your password.

Then add the following line at the bottom and save it.

2. Change the default hosting url (gitlab.example.com) for Gitlab CE

Access the Ubuntu terminal of the virtual box.

Now in the same terminal window edit the following file.

And find and replace.

With.

Then enter the following for the change to take effect.

3. Login to GitLab CE dashboard and change your user details

Open your browser with url http://gitlab.local. The first time around it will ask you to change your password.

Once done it will redirect you to the login page. By default the username is root so just enter this and your new password.

Now you should have access to the Gitlab CE Dashboard.

4. Edit the user account

First thing you should do is change your user details, so choose Settings and change your 'Email' and 'Full name' then press the 'Update profile settings' button.

You will receive an email just to confirm that it's exists. If the external_url has worked correctly the link in the email will work fine.

And then edit your username by selecting Account.

5. Create new repo

Create a new project so for this example I have used first-project.

You will be asked to first generate a SSH key.

6. Generate a new SSH key

Open a new terminal window and enter the following.

Then enter the filename you want the key to be named, just press return if you want to keep the default generated name but I would suggest using a custom name and remember to include the full directory in the filename like below.

Now just press enter twice to keep the passphrase empty.

Open the public key with your naming above.

You will have a line of random code begining with 'ssh-rsa' so copy this for use with GitLab.

Go back to the GitLab CE dashboard and press the Add SSH Key and paste the public key then press Add key.

You should get an email to confirm this.

7. Access the new repo via the terminal (or with the 'GitHub Desktop app' see section 8)

First open the following file and link your ip/url to your key.

And add the following.

So now you can clone the repo by entering this in the terminal.

It will initially ask you the below, so just enter 'yes'.

This should be working fine.

8. Access the new repo with the GitHub Desktop app

With the Github Desktop application things work a little different regarding accessing your repos. So lets start by selecting Settings then Access Tokens on the left navigation.

At first enter a name - so for this example 'First Project' and select the api checkbox. Then press the 'Create personal access token' button.

The page should refresh and generate a code under Your New Personal Access Token. Make sure to get a copy of this code because we will need to use this in the Github Desktop application.

Now select the 'Your Gitlab Name / first-project' repo.

On the following page choose the Clone dropdown button and highlight either the http or https that appears so for example.

Now launch the GitHub Desktop app and choose 'Clone a Repository from the Internet...'.

Input the repo url and the destination folder.

  • Repository URL: http://gitlab.local/your-gitlab-name/first-project.git

  • Local Path: /Users/[username]/gitlab-local-repos/first-project

Now the first time doing this you will be asked for the Authentication Login so add your username (for this example 'Your Gitlab Name') which you used to access the GitLab dashboard and the password which should be the generated 'Personal Access Token'.

Now you should get the cloning progress bar and it will have synced the repo of your local GitLab CE.

Vagrant Macos Box Mojave

I hope this has been helpful.





broken image