Skip to content

hamishau/vagrant.craftcms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a guide to setup a new installation of Craft CMS and Postgres, running in an Ubuntu 24.04 Vagrant Box. Install Vagrant and Virtualbox before proceeding.

Clone Repository

Clone Github repository to your local development machine:

git clone git@github.com:hamishau/vagrant.craftcms.git

Project Name

Search for all instances of yourapp and replace with your preferred project name.

Deploy Vagrant Box

vagrant up

Edit Hosts

Windows Powershell: notepad c:\Windows\System32\Drivers\etc\hosts
Ubuntu Terminal: sudo nano /etc/hosts
MacOS Terminal: sudo nano /etc/hosts

192.168.56.10 yourapp.local

What provisioning does

Installs Craft, writes /var/www/html/craft/.env, and runs the installer so the site is ready to view.

Defaults:

  • Driver pgsql, host 127.0.0.1, port 5432
  • DB user postgres, password admin, database yourapp
  • SECURITY_KEY generated per provision
  • Admin user admin / admin123, email admin@yourapp.local
  • Site name Your App, URL http://yourapp.local:8080, language en-US

Preview in browser:

http://yourapp.local:8080

Post Installation

These are not required as a part of the Vagrant deployment process - just a collection of helpful commands that might be required at some point in your Vagrant box.

Set all directories to 755 and files to 644, and ownership to www-data:

vagrant ssh -c 'find /var/www/html -type d -exec chmod 0755 {} \; && find /var/www/html -type f -exec chmod 0644 {} \; && sudo chown -R www-data:www-data /var/www/html/craft'

Craft Folder Permissions:

vagrant ssh -c 'sudo chmod 777 /var/www/html/craft/.env && sudo chmod 777 /var/www/html/craft/composer.json && sudo chmod 777 /var/www/html/craft/composer.lock && sudo chmod 777 /var/www/html/craft/config/license.key && sudo chmod -R 777 /var/www/html/craft/config && sudo chmod -R 777 /var/www/html/craft/storage && sudo chmod -R 777 /var/www/html/craft/vendor && sudo chmod -R 777 /var/www/html/craft/web/cpresources'

Import PostgreSQL Database

vagrant ssh -c 'cd /var/www/html && sudo -u postgres psql yourapp < yourapp.psql'

Export PostgreSQL Database

vagrant ssh -c 'cd /var/www/html && sudo -u postgres pg_dump yourapp > yourapp.psql'

Drop PostgreSQL Database and Create New Database

vagrant ssh -c 'cd /var/www/html && sudo -u postgres dropdb yourapp && sudo -u postgres createdb yourapp'

Restart Vagrant Box

vagrant reload

Destroy Vagrant Box

vagrant destroy

About

This is a 5 minute deployment of a new Craft CMS + Postgres installation, running in an Ubuntu 24.04 Vagrant Box.

Topics

Resources

Stars

Watchers

Forks

Contributors