- The instructions assume you have git and Docker installed. Have the docker app open while going through the steps.
- You need a UCSC VPN connection to use the Campus Directory block in the UCSC Gutenberg Blocks plugin.
-
Go to your terminal and run this command to clone this repo
git clone https://github.com/ucsc/wp-dev.ucsc.git- cd into the folder
cd wp-dev.ucsc
-
Edit your hosts file by running
sudo nano /etc/hostsin your terminal and add127.0.0.1 wp-dev.ucsc- On Mac OS do ctrl+O to writeout and hit enter on your keyboard
- Then hit ctrl+X to exit
- You have now successfully edited you host file.
-
Change
.env.example.txtto.envby following these steps:- cd into the folder
cd wp-dev.ucscif you are not in it already - Run the command
ls -ato see hidden files and verify there is a file called.env.example.txt - Run this command to change the name to .env
mv .env.example.txt .env - Run ls -a to verify the name of the file has changed to
.env
- cd into the folder
-
In the wp-dev.ucsc directory build and start the WordPress server with HTTPS & PHP LDAP module (Allow time for this command to finish)
docker compose up -d- Once this is finished running you should have a total of 5 docker containers up and running. You can verify this by opening up the docker app and making sure there is a green dot next to each container.
- Troubleshooting: If there is not a green dot next to each container then here is what you should do: select all the containers in your docker app and
delete them all. Once all the containers have been deleted go to your terminal in the wp-dev.ucsc directory and run
docker compose up -dagain. This should solve the issue and have all 5 containers up and running succesfully.
Important
Check that a wp-config.php file exists in the ./public/ folder before proceeding
-
Run the following script to clone the theme and plugins to the correct project directories.
./setup.sh
-
Next we install WordPress, activate the theme & plugin, run composer install on the theme as well as npm install on both the plugin and the theme
docker compose -f docker-compose-install.yml run theme_composer_installdocker compose -f docker-compose-install.yml run theme_npm_installdocker compose -f docker-compose-install.yml run plugin_npm_install(may take up to 2 minutes to complete)docker compose -f docker-compose-install.yml run wordpress_install
Your installation is now complete.
Troubleshooting: If there is not a green dot next to each container then here is what you should do: select all the containers in your docker app and
delete them all. Once all the containers have been deleted go to your terminal in the wp-dev.ucsc directory and run docker compose up -d again.
This should solve the issue and have all 5 containers up and running succesfully.
Now that WordPress is installed and the plugins and theme are built, we can start watching for changes to code and rebuild when necessary
- Starts the WordPress server environment
docker compose up -d
- Starts the Node development environments for the theme and blocks plugin
docker compose -f docker-compose-start.yml up -d
Tip
Swap up with down in the commands above to stop your containers. You must run both commands to start and stop the development environments.
At this point you should be able to visit https://wp-dev.ucsc/wp-admin in a browser. In Google Chrome you will get a error saying "Your connection is not private", this is due to the local certificates. You can click Advanced -> proceed to wp-dev.ucsc. To login:
- username:
admin - password
password
Tip
- You can run WP-CLI commands with
docker exec ${NAME}-cli wp <COMMAND> ${NAME}is what you used in your.envfile
The PHP Debug plugin is required. On the debug tab click Create a launch.json file and select type php.
You can replace the contents of launch.json with the following:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/wp-content/plugins/ucsc-gutenberg-blocks": "${workspaceRoot}"
},
"hostname": "wp-dev.ucsc"
}
]
}