Exclusive locks not supported error, when using FreeBSD in Vagrant.

This error drove me crazy for the longest time. I was using Vagrant, FreeBSD and Laravel for a project and laravel would not run because of where it stores the cache. It took awhile for me to find a good fix but it is fairly easy.

In your  /etc/rc.conf file add two lines:

  • rpc_lockd_enable=”YES”
  • rpc_statd_enable=”YES”

Restart your vagrant instance and it’s all working now.

You can also update your vagrant file to put those values in when it’s created. Below is my Vagrantfile for new projects:

# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.define :freebsd11p1
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "freebsd/FreeBSD-11.0-RELEASE-p1"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port",guest:3306, host:3306 # mysql
#config.vm.network "forwarded_port", guest: 443, host: 8443
config.vm.box_download_insecure = true
# Set freebsd shell
config.ssh.shell = "sh"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# Configure mac address
config.vm.base_mac = "080027D14C66"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network", type: "dhcp"
config.vm.network "private_network", type: "dhcp"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Use NFS as a shared folder
config.vm.synced_folder ".", "/vagrant", :nfs => true, id: "vagrant-root",
:mount_options => ['rw', 'vers=3', 'tcp', 'actimeo=2']
# Place in /etc/rc.conf, to resolve error: exclusive locks not supported
# rpc_lockd_enable="YES"
# rpc_statd_enable="YES"
# ######################
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
# vb.gui = true
# Customize the amount of memory on the VM:
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.customize ["modifyvm", :id, "--audio", "none"]
# vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
# vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
# install pkg's
env ASSUME_ALWAYS_YES=YES /usr/sbin/pkg install openssl apache24 mod_php70 php70 php70-zip php70-extensions php70-mbstring php70-openssl php70-mysqli php70-curl php70-soap php70-pdo_mysql node npm git nano mysql57-server virtualbox-ose-additions;
# Copy php ini file
cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini;
# Install phpmyadmin
fetch https://files.phpmyadmin.net/phpMyAdmin/4.6.6/phpMyAdmin-4.6.6-english.tar.bz2;
tar -xzf phpMyAdmin-4.6.6-english.tar.bz2;
mkdir /usr/local/www/phpMyAdmin;
mv phpMyAdmin-4.6.6-english/* /usr/local/www/phpMyAdmin;
randomBlowfishSecret=`openssl rand -base64 32`;
sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/local/www/phpMyAdmin/config.sample.inc.php > /usr/local/www/phpMyAdmin/config.inc.php;
# install composer
php -r "copy('https://getcomposer.org/installer&#39;, 'composer-setup.php');"
php composer-setup.php --version=1.3.1;
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer;
composer self-update;
echo "
<IfModule dir_module>
DirectoryIndex app.php index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>" >> /usr/local/etc/apache24/Includes/php.conf;
echo "
<VirtualHost *:80>
ServerName project.dev
DocumentRoot /usr/local/www/apache24/data/public
<Directory /usr/local/www/apache24/data/public >
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/project.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/project-access.log combined
</VirtualHost>
Alias /phpmyadmin "/usr/local/www/phpMyAdmin"
<Directory "/usr/local/www/phpMyAdmin">
Options None
AllowOverride None
Require all granted
</Directory>" >> /usr/local/etc/apache24/httpd.conf
sysrc apache24_enable=yes;
sysrc mysql_enable=yes;
# For NFS
sysrc rpc_lockd_enable=yes;
sysrc rpc_statd_enable=yes;
# map apache dir to local folder
if ! [ -L /var/www ]; then
rm -rf /usr/local/www/apache24/data;
ln -fs /vagrant /usr/local/www/apache24/data;
fi
# start apache24
service apache24 start;
# start database server
service mysql-server start;
# root password update
# mysql -u root -p
# SET PASSWORD = PASSWORD('vagrant');
SHELL
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s