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 Github repository to your local development machine:
git clone git@github.com:hamishau/vagrant.craftcms.git
Search for all instances of yourapp and replace with your preferred project name.
vagrant up
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
Installs Craft, writes /var/www/html/craft/.env, and runs the installer so the site is ready to view.
Defaults:
- Driver
pgsql, host127.0.0.1, port5432 - DB user
postgres, passwordadmin, databaseyourapp SECURITY_KEYgenerated per provision- Admin user
admin/admin123, emailadmin@yourapp.local - Site name
Your App, URLhttp://yourapp.local:8080, languageen-US
http://yourapp.local:8080
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.
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'
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'
vagrant ssh -c 'cd /var/www/html && sudo -u postgres psql yourapp < yourapp.psql'
vagrant ssh -c 'cd /var/www/html && sudo -u postgres pg_dump yourapp > yourapp.psql'
vagrant ssh -c 'cd /var/www/html && sudo -u postgres dropdb yourapp && sudo -u postgres createdb yourapp'
vagrant reload
vagrant destroy