Wednesday, 29 October 2014

Still trying to set up Vagrant

Today I was still working on getting a Vagrant box set up for my web development environment. To get the box set up you have to create a shell script that will be run when starting up, and in this script you need to install and configure everything.

I wanted to test the script as I write it, to ensure that it works correctly. The simplest way to do this is to ssh into the box and then execute the script from there. However, when I tried to execute the script I got the error ": No such file or directory". I checked the permissions for the script, and execute was marked, so that wasn't the problem. After a bit of googling I found this thread, which had the answer: No such file or directory error when trying to execute startup script in Debian.

When I ran file ./, I got the output:

./ a bash\015 script, ASCII text executable, with CRLF line terminators

Note that it is not a bash script, but a bash\015 script, and also that it has CRLF line terminators. The script needs to use LF line terminators, which I thought that my editor Scite used. Obviously not. After converting to LF, the file command now gave:

./ a bash script, ASCII text executable

With that done I could execute the script, though it didn't work. I found I needed to sudo the script to run it since it installs software. (Not that surprising). Presumably Vagrant sudo runs the script when running it as a bootstrap, since they don't use sudo in front of the commands in the script in their examples.

I found that I couldn't get apache2 to start as my configuration uses SuPHP_UserGroup, and this is not available in the libapache2-mod-suphp build from the Ubuntu repository. So you have to build it from source: How To Install suPHP On Various Linux Distributions For Use With ISPConfig (2.2.20 And Above). But I then had a load of issues getting that to install (no libtool or make installed by default, needing to libtoolize, etc). I need to try it again from fresh to check if all the steps I used in finally getting it to compile are needed or not.

After getting it compiled I still couldn't get apache2 to start. From the log, it looks like this is because the error log directories specified for the sites enabled didn't exist. So this essentially means getting most of my home directory copied from my current Linux VM over to the shared Vagrant folder in Windows.

The issue with doing this was that I have some filenames that aren't acceptable to Windows, such as filenames with '?' and ':' in them. As much as I dislike arbitrary restrictions like this, the only way I could think of dealing with this is to rename the problematic files to remove the problematic characters.

I have a lot of tabs open with setting up Vagrant related stuff, so I'm just going to list them here in case I want to come back to them:

No comments: