Knitting needles and crochet hook on a blue shield

Starting with Laravel #2 – Choosing battles

At first I foolishly thought that setting up nginx and PHP would be easy. But I am a cross between an artist and a developer, not an operations engineer. And therefore I switched back to default Apache server. Also I have different opinions about the front-end side of the things.

Last post I ended just after installing my development environment which is Ubuntu Server in VirtualBox. The next step is setting up webserver. For couple of hours I tried to set up nginx but I was not successful. At first I wanted to use official installation guide but that didn’t work for me. Second attempt was Ubuntu way with same result. After second day I resigned to use Apache server with quite simple administration. Copying and editing one XML file was more than enough to set up a server:

After that linking this file to   sites-enabled  folder did the trick.

The hard part was to convince Ubuntu and VirtualBox to let me access the files and edit them from the host system. First step was to enable it in VirtualBox’s configuration:

VirtualBox Shared folders

Ubuntu’s side is where it gets complicated. Simple mount doesn’t work because you can access it only as root user, so web server won’t be able to access the shared folder also. First you need to add yourself and user www-data  to a group vboxsf :

And if you want to mount this shared folder automatically to a different location adding a line to  /etc/fstab file is necessary. I chose to mount folder into a different folder, a trick which I learned very long time ago when I installed Gentoo from Stage 1.

(Hard) link might do the same thing but I feel better when it’s mounted. That’s my only reason.

Also you might need to install tools from Guest Addition CD image which is distributed with VirtualBox and is hidden under Devices in menu.

Next step is setting up port forwarding in VirtualBox. It is pretty straightforward. You’ll go to Network tab in settings for your virtual machine, click on Advanced arrow and button with “Port forwarding” text will appear. After clicking on the button a table will show up and you just need to add similar line:

VirtualBox Network tab portforwarding 8080 to 80

I am using NAT because I don’t see a reason why anyone needs to know that I am using a virtual machine1.

Now you just need to run composer create-project --prefer-dist laravel/laravel project  in /var/www. Warning it feels overwhelming just to look at the structure so the first thing I looked at JavaScript side and I disagree with a lot of things but that’s for some other post. Next week I’ll start coding in PHP, probably.

  1. At the moment I live with flatmates