If you get an error at any point, please stop and ask.
  1. Press Command-Space, type "terminal", and press enter.
  2. Paste this into the terminal and press Enter: xcode-select --install
  3. Follow the prompts.
  4. Paste this into the terminal and press Enter: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" (if you have already installed Homebrew, you can skip this step; you'll know if you have)
  5. Follow the prompts and enter your password as required.
  6. Paste this into the terminal and press Enter: brew install openldap libiconv
  7. Paste this into the terminal and press Enter: sudo apachectl stop – you can ignore an error on this step.
  8. Paste this into the terminal and press Enter: brew install httpd php@7.4
  9. Paste this into the terminal and press Enter: vim /usr/local/etc/httpd/httpd.conf
  10. Type this: /Listen 8080 and press Enter.
  11. Use the arrow keys to put the cursor over one of the 8s and press x twice.
  12. Type this: /DocumentRoot " and press Enter.
  13. Use the arrows to put the cursor inside the quotes and press each of these keys in turn: c i " (letter c, letter i, double quote (with shift))
  14. Type /Users/NAME/Sites where NAME is your macOS username, and press Escape.
  15. On the following line starting <Directory change the path to match. Use the arrows to put the cursor on the space and press each of these keys in turn: c t > (letter c, letter t, greater-than sign). Type the path again and press Escape.
  16. Type :%s/AllowOverride None/AllowOverride All/ (from the colon to the final slash, inclusive on both ends). Press Enter.
  17. Type this: /#LoadModule rewrite and press Enter.
  18. Press these characters in order: 0 x (numeral zero, letter x).
  19. Press O (capital letter O)
  20. Paste this and press Escape: LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
  21. Type /^User and press enter.
  22. Use the arrows to put the cursor on the word after "User" and press each of these in order: c a w (letter c, letter a, letter w)
  23. Press space and type your macOS username.
  24. Press Escape.
  25. Do the same on the Group line and change it to staff.
  26. Press Escape.
  27. Type /DirectoryIndex index and press Enter.
  28. Press f x l a (letter f, letter x, letter l, letter a)
  29. Type index.php and a space, and press escape.
  30. Type /> and press enter.
  31. Press o (letter O)
  32. Paste this block in:
    <FilesMatch \.php$>
    SetHandler application/x-httpd-php
    </FilesMatch>
  33. Press Escape.
  34. Press : x (colon, letter x) and press Enter.
  35. Type mkdir ~/Sites and press Enter.
  36. Find the directory path to your Eclipse project (or wherever you're building your website). The remaining instructions will assume it was /Users/YOU/eclipse-workspace/mywebsite - change the following instruction as appropriate to your path. This is the directory that your index.html file is in.
  37. Type ln -s /Users/YOU/eclipse-workspace/mywebsite ~/Sites/first and press enter.
  38. Type in brew services start httpd and press enter.
  39. Go to http://localhost/first/ in your browser and see it working.
If you get an error at any point, please stop and ask.

After rebooting

If step 38 (brew services start httpd) didn't work for you, after a reboot you will need to run this command in the terminal:

sudo apachectl start

Setting up a database server

  1. Run this command in the terminal: brew install mariadb
  2. If brew services start worked for you earlier, run:
    • brew services start mariadb
  3. Otherwise, run:
    • mysql.server start
  4. Run this command in the terminal: mysql -uroot
  5. Type CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass'; and press Enter.
  6. Type CREATE DATABASE mydb; and press Enter.
  7. Type GRANT ALL ON mydb.* TO 'myuser'@'localhost'; and press Enter.
  8. Press Ctrl-D.
  9. Type mysql -u myuser -pmypass mydb and press Enter to enter an SQL client. Press Ctrl-D to close it after checking that it ran. This is what we will use later on to enter database commands.
  10. Type curl https://ecs.victoria.ac.nz/foswiki/pub/Courses/SWEN502_2019T2/WebApps/mydb.sql | mysql -u myuser -pmypass mydb and press Enter to import our sample database.
  11. If you started the server with mysql.server start above, you will need to do that again after rebooting.

MongoDB

Follow the setup instructions on the MongoDB website. You already have Homebrew installed and can start at the "Tap the MongoDB Homebrew Tap" step.

After the server is running, run: You can now run mongo to enter the MongoDB client.