DEV Community

Axel Espinosa
Axel Espinosa

Posted on

Set up your PHP environment on UBUNTU

Recently I had the idea to move my environment for coding in PHP to Ubuntu. I don't have a bad history using windows but I've read that in Linux you have an easy installation of tools for coding, so I created a dual boot on my computer and started.

Disclaimer: I'm not an expert using Ubuntu but I'm learning and I thought that it could be a great idea to share what I've learned and another thing is that I'm learning English, so I really appreciate if you tell me of any grammar mistake.

To set up my PHP environment using Laravel/Homestead I followed these steps listed below.

First we need to download Virtual Box version 6.* with the command

sudo apt install virtualbox-6.1
Enter fullscreen mode Exit fullscreen mode

After that we need to turn off the secure boot on your machine, this if you're using a modern laptop. You will find this option in the BIOS of your system.

Once you turned off Secure Boot on your machine, download the latest version of vagrant to avoid any error from the official site of releases: https://releases.hashicorp.com/vagrant

Then if you downloaded the .deb package you can click it and install it.

We're going to use laravel/homestead which is bounded with all the software needed to have an isolated environment in your machine for PHP.

You need to add the vagrant box to your machine with the command

vagrant box add laravel/homestead
Enter fullscreen mode Exit fullscreen mode

This will add to your vagrant boxes the laravel box that contains all the software needed for development on PHP with laravel.

Once you've added the box and configured everything you need in the Homestead.yaml file, provision the vagrant machine with your current user, not the sudo user.

The last thing to do is create a new group in your machine called vagrant with the command:

sudo groupadd vagrant
Enter fullscreen mode Exit fullscreen mode

Next, add your current user to that group using the command

sudo usermod -aG vagrant $USER
Enter fullscreen mode Exit fullscreen mode

Now the last thing to do is change the owner:group of your files.

sudo chown -R axele:vagrant ./project
Enter fullscreen mode Exit fullscreen mode

And now you can create files and everything you need inside the vagrant machine.

Thanks for reading.

Top comments (0)