{"id":15715967,"url":"https://github.com/wordpress-phoenix/local-wordpress-development","last_synced_at":"2025-05-12T22:13:34.305Z","repository":{"id":147264761,"uuid":"85349521","full_name":"WordPress-Phoenix/local-wordpress-development","owner":"WordPress-Phoenix","description":"WordPress Local Web Development Guide for Mac OS X","archived":false,"fork":false,"pushed_at":"2019-01-17T14:33:49.000Z","size":104,"stargazers_count":15,"open_issues_count":3,"forks_count":5,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-02T13:51:53.607Z","etag":null,"topics":["brew","cask","local-development","osx-setup","phpstorm","vvv","vvv2","wordpress-development"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WordPress-Phoenix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-17T19:52:39.000Z","updated_at":"2024-08-17T22:22:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"a4b6090b-35e0-4839-876c-cb9fc2fe2417","html_url":"https://github.com/WordPress-Phoenix/local-wordpress-development","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Flocal-wordpress-development","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Flocal-wordpress-development/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Flocal-wordpress-development/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WordPress-Phoenix%2Flocal-wordpress-development/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WordPress-Phoenix","download_url":"https://codeload.github.com/WordPress-Phoenix/local-wordpress-development/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223835370,"owners_count":17211158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brew","cask","local-development","osx-setup","phpstorm","vvv","vvv2","wordpress-development"],"created_at":"2024-10-03T21:43:34.028Z","updated_at":"2024-11-09T14:04:04.426Z","avatar_url":"https://github.com/WordPress-Phoenix.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Getting Started\n\nThe right tools make the difference with most craft, and as a web developer your local environment is a critical foundation to set yourself up for success.\n\nThis guide is for OS X, and while some tools are cross-platform or concepts may translate, your mileage will vary.\n\n### How-To Setup...\n\n| How-To Setup... | - | - |\n| -------------   | - | - |\n| :package: [**Dependencies and Apps**](#setup-dependencies-and-apps) | :computer: [**Terminal**](#setup-terminal) | :satellite: [**SSH**](#setup-ssh) |\n| :ledger: [**Local DNS**](#setup-local-dns) | :rocket: [**Virtual Environments**](#setup-virtual-environments) | :grey_question: [**Other / Misc.**](#setup-other-misc) |\n\n\n\n\n# Setup Dependencies and Apps\n\n### Quickstart\n\n###### Download and Install Homebrew Package Manager\n\n```bash\nruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\n#### Why Brew?\n\nBrew helps developers manages software and tools be time-consuming and challenging to install and configure. Brew, in conjunction with Cask, can be a near-one-stop shop for installing _any_ software.\n\nIt's rad.\n\n### Recommended Developer Packages\n```bash\nbrew tap caskroom/cask \u0026\u0026 \\\nbrew install grc git svn node imagemagick pkg-config hub dnsmasq \u0026\u0026 \\\ngit config --global credential.helper osxkeychain\nbrew cask install virtualbox vagrant vagrant-manager\nbrew cask install iterm2 sequel-pro postman visual-studio-code\n```\n### Recommended for Productivity\n```bash\nbrew cask install phpstorm slack\nbrew cask install alfred spectacle flux dash imageoptim clipy\nbrew cask install google-chrome spotify snagit\n```\n### Recommended for OS X Finder Quick Look Previews\n```\nbrew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv webpquicklook suspicious-package quicklookase qlvideo\n```\nOriginally from https://github.com/sindresorhus/quick-look-plugins\n\n# Setup Terminal\nSetting up your terminal profile is very important for productivity. We recommend the following enhancements. Being by opening your bash profile configuration file.\n\n### Setup `.bash_profile`\n```bash\nsudo nano ~/.bash_profile\n```\nThen copy the following and past it into the terminal text editor we just used to open the file.\n```bash\nalias ls=\"ls -GHf\"\nalias ll='ls -lartG'\nalias xdebug_on='vagrant ssh -c \"xdebug_on\" | grep php'\nalias xdebug_off='vagrant ssh -c \"xdebug_off\" | grep php'\nalias hosts='sudo nano /private/etc/hosts'\nalias flushdns='sudo dscacheutil -flushcache'\nalias vup=\"vagrant up --provision\"\nexport PATH=\"/usr/local/sbin:$PATH\"\nalias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder/System/Library/CoreServices/Finder.app'\nalias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'\nalias pruneknownhosts=\"sed -i -e s/*.*//g ~/.ssh/known_hosts\"\nalias prunedevhosts=\"sed -i -e s/.*\\.dev.*//g ~/.ssh/known_hosts\"\n\n# LOCAL GIT HELPERS\nalias updaterepos='ls | xargs -P10 -I{} git -C {} pull'\nalias prunerepos='ls | xargs -P10 -I{} git -C {} remote prune origin'\nalias checkoutdevelopall='ls | xargs -P10 -I{} git -C {} checkout develop'\n\n# REST HELPER\nhttpHeaders () { /usr/bin/curl -I -L $@ ; }\n\n# docker functions\nalias dke=\"docker exec -i -t\"\nalias dkps=\"docker ps -a\"\nalias dkls=\"docker images\"\ndkRun () { docker run -dit $@ ; }\ndkBuild () { docker build . -t $@ ; }\ndkClean () { [[ $(docker ps -a -q -f status=exited) ]] \u0026\u0026 docker rm -v $(docker ps -a -q -f status=exited) ; }\ndkCleanImages () { docker rmi $(docker images | grep \"^\u003cnone\u003e\" | awk '{print $3}') ; }\n```\n\nLastly save and close the file with `Ctrl+X` then `Enter` and one more `Enter`.\n\n### Setup `.inputrc`\nInput RC controls what happens as you type in terminal. We are going to setup a feature that allows terminal to use \"per command history\". When in terminal you can hit the up and down arrows to cycle through previously used commands. With this extra configuration file, it will allow you to track \"per command\" history. So if you typed \"git push\" then \"cd www\", you may want to only search your history for \"git\" commands. To do so, simply type \"git\" and then press up, it will only search your history for git commands and find \"git push\" as desired.\n\nOpen the .inputrc file from terminals nano editor:\n```\nnano ~/.inputrc\n```\n\nThen copy and paste the following into the editor.\n```\n\"\\e[B\": history-search-forward\n\"\\e[A\": history-search-backward\nset completion-ignore-case On\n```\n\nLastly save and close the file with `Ctrl+X` then `Enter` and one more `Enter`.\n\n### Applying New Settings To Terminal\n\nUpdates to the `.bash_profile` don't immediately reflect in your current editor. Open a new tab, restart terminal or source your profile for the current session.\n```\nsource ~/.bash_profile\n```\n\n# Setup SSH\n\nSecure Shell is an encrypted protocol used to connect between two networked computers (on a local network or via the internet). Many web hosts and services like GitHub allow you to authenticate using SSH keys from a trusted machine.\n\nSSH keys only need to be generated once. Instructions are below to copy existing keys or import keys from another computer.\n\n### Check for Current Key(s)\n```bash\nls -al ~/.ssh\n```\n\n### Copy Current Public Key\n```bash\npbcopy \u003c ~/.ssh/id_rsa.pub\n```\n\n### Generate New Keys\nhttps://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/\n\n### Moving Keys to Another Computer\n\nIf you are moving existing keys from a previous computer, you may want to import the keys instead of generating new ones.\n\n1. Copy the existing keys into the new computer's `~/.ssh` folder.\n2. After copying the keys over, the file permissions will be too open and in some cases won't be accepted when trying to connect to servers. To set the correct permissions, run `chmod 600 ~/.ssh/id_rsa` and `chmod 600 ~/.ssh/id_rsa.pub`. It should also be noted that the .ssh folder itself should only be writeable by you (`chmod 700 ~/.ssh`).\n3. Run `ssh-add -k ~/.ssh/id_rsa`.\n\n### Adding Keys to New Computer\n\nFirst we should check if there is already some SSH keys generated. To do so open terminal and run \n```bash\nls -al ~/.ssh\n```\n\n### If you see \"ls: .ssh: No such file or directory\"\n\nPlease run this command to generate the SSH directory and empty key files.\n```bash\ncd ~ \u0026\u0026 mkdir .ssh \u0026\u0026 chmod 700 .ssh \u0026\u0026 cd .ssh \u0026\u0026 touch id_rsa \u0026\u0026 touch id_rsa.pub \u0026\u0026 chmod 600 id_rsa \u0026\u0026 chmod 644 id_rsa.pub\n```\n\n### Now that we have the required files, let's edit them\n\nWe will need to bring in both the public key (.pub) and the private.\\\n**Private:** `vim ~/.ssh/id_rsa`\\\n**Public:** `vim ~/.ssh/id_rsa.pub`\n\n**Basic Vim Editor Commands**\\\n**a** = Edit Mode\\\n**ESC** = Exit Edit Mode\\\n**:** = Command\n\nFor both key files, one at a time - vim the file.  \n1. **IF** File Contents are **NOT** empty, before going into edit mode press lowercase **d** and then uppercase **G**. This will truncate the file.\n2. Press \"**a**\" to enter edit mode\n3. Paste in your key normally ( **(Command/Control) + v** )\n4. Press the \"**ESC**\" key\n5. Press \"**:**\" (_colon_)\n6. Type lowercase \"**wq**\" (_write \u0026 quit_)\n\n### Understanding SSH Key Pairs\n\nSSH keys are generated at user prompt -- they don't come installed on computers.\n\nKey pairs are like deadbolts \u0026 keys. Your **private key** is akin to _your_ house key, it only works with _your_ house's deadbolt lock. While the **public key** is more like the deadbolt lock on your house. The pair, the key and the deadbolt, together allows you secure access into your home.\n\nIn the case of SSH key pairs, you keep the private key to yourself, never share this with anyone else. You share your public key with, well anyone who needs to grant you access to there servers. When they add your public key (deadbolt) to their servers, it’s like giving you your own backdoor into the servers that only your private key works with. (Seen the key-maker in the Matrix movie? Kind of like that).\n\n### Configure SSH Forwarding Agent\n\nhttps://developer.github.com/guides/using-ssh-agent-forwarding/#setting-up-ssh-agent-forwarding\n\n### Example for connecting to Pagely Hosting\nOpen terminal editor nano for .ssh config file:\n```bash\nnano ~/.ssh/config\n```\n\nThen copy and paste the following into the editor.\n```bash\nHost *.pagelydev.com\n     ForwardAgent yes\nHost *.pagelyhosting.com\n     ForwardAgent yes\n```\nLastly save and close the file with `Ctrl+X` then `Enter` and one more `Enter`.\n\n### Understanding forwarding with the ssh agent\n\nBasically, when you are using SSH or SSH tunnels, you need to \"grant access\" to your private key. This allows us to pass our SSH key to the remote server we are connecting to, and it can now use your key to \"forward\" your requests to additional servers that it may talk to. You don't want to allow this for \"just every server you connect to\". That would be dangerous since you need to trust the connecting server not to abuse the use or sharing of your private key. Remember your private key, the one without .pub at the end, is like a password. Do not share your private key with anyone, and we highly recommend you do not \"sync it to a cloud drive service\". Certainly never store it in a Github repository, regardless of the repo is private or public.\n\n# Setup Local DNS\n\n### Configure `dnsmasq`\nThis assumes you use the standard VVV with VirtualBox and the default IP.\nInstall: dnsmasq was installed above, if you skipped it `brew install dnsmasq`\nSetup (https://alanthing.com/blog/2012/04/24/never-touch-your-local-etchosts-file-os-x-again/):\n\n```bash\nmkdir -pv $(brew --prefix)/etc/\necho 'address=/.test/192.168.50.4' \u003e $(brew --prefix)/etc/dnsmasq.conf\nsudo echo \"admin enabled - quickly do sudo tasks\"\n```\n\nNext type your password in the prompt before continuing.\n\nNow hurry a little, you only have 10 minutes to copy and paste the following commands\n```bash\nsudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons\nsudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist\nsudo mkdir -v /etc/resolver\nsudo bash -c 'echo \"nameserver 127.0.0.1\" \u003e /etc/resolver/test'\n```\n\n##### Test `dnsmasq` is working\n\nSend a ping to `google.test` and you should see a local IP address in place of a std. Google IP\n```\nping -c 1 -t 1 google.test\n```\n\nExpect results like:\n```text\nPING google.test (192.168.50.4): 56 data bytes\n--- google.test ping statistics ---\n1 packets transmitted, 0 packets received, 100.0% packet loss\n```\n\n#### Understanding `dnsmasq`\n\nMore info on dnsmasq setup and troubleshooting here:\nhttp://passingcuriosity.com/2013/dnsmasq-dev-osx/\n\nMore info on OSX resolver\nhttp://apple.stackexchange.com/questions/74639/do-etc-resolver-files-work-in-mountain-lion-for-dns-resolution\n\nNOTE: nslookup ignores osx dns proxy, do not test with that\n\n#### Optional: Resolve domains using alternative DNS if your ISP's lags\n\nDNS resolves domain names and using your ISP's DNS is kind of like using your ISP's email.\n\nEven business or fiber internet can lean on mediocre DNS, so if you frequently have problems, try a change.\n\n1. Open __System Preferences__ and select __Network__ _[third row]_.\n2. Click __Advanced...__ in the bottom-right.\n3. Click DNS _[third tab]_\n4. Add IPs in left column.\n\n```\nGoogle DNS:\n8.8.8.8\n8.8.4.4\n\nOpenDNS:\n208.67.222.222\n208.67.222.220\n```\n\n## Setting Up WordPress Development\n\nFully setting up local WordPress development of a custom site isn't that complicated, but its complex enough that we don't want to try do a comprehensive explanation in readme file.\n\n### VVV Pre Reqs:\n```\nvagrant plugin install vagrant-hostsupdater\nvagrant plugin install vagrant-triggers\n```\n\n### Quick setup of VVV:\n```\nmkdir -p ~/Sites; cd ~/Sites \u0026\u0026 git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git ; cd VVV \u0026\u0026 vagrant up ;\n```\n\n### Possible issue\nIf you run into issue with `default: There are problems and -y was used without --force-yes`, \n\nYou may be able to resolve it by:\n1. `cd ~/Sites/VVV/provision/provision.sh`\n2. Search for `if ! apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew install`\n3. Replace `apt-get -y` with `apt-get --force-yes -y` on that line\n\nFor other issue around VVV, please check the issue board: https://github.com/Varying-Vagrant-Vagrants/VVV/issues\n\n### But I want a custom local WordPress instance\nEnter VVV2 YML configs. Allowing you to tell VVV that you want more local instances, and how you want those instances configured. Read more in the [official VVV2 config docs](https://varyingvagrantvagrants.org/docs/en-US/vvv-config/). Would you like to see a video to follow along? We got you covered there too!\n\n[![IMAGE ALT TEXT](http://img.youtube.com/vi/6XC1er-2pmM/0.jpg)](https://www.youtube.com/watch?v=6XC1er-2pmM \"Video Title\")\n\nFirst we need to create a custom config file that VVV2 is expecting:\n\n```bash\ncp ~/Sites/VVV/vvv-config.yml ~/Sites/VVV/vvv-custom.yml\n```\n\nNext we need to add a custom domain to the configuration file. \n\n*Please note: YML files are space sensetive, if its not working, its likely an issue with indentiation/spacing/nesting.*\n\nPaste in the following just above the utilities section of vvv-custom.yml:\n```yaml\n  mylocalsite.dev:\n    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git\n    hosts:\n      - mylocalsite.dev\n```\n\nLast we need to ask VVV to build our new configuration. We can completely rebuild the entire Vagrant, or, whats faster is to ask VVV2 to just build our new site within the Vagrant. We are going to show here the more efficient way of building just our 1 new site from the config.\n\n```\nvagrant up ; vagrant provision --provision-with site-mylocalsite.dev'\n```\n\n### But I want VVV2 to mirror my production site\nYou mean you don't want to manually configure every site locally every time you set them up? Well, you are in luck. VVV2 allows us to do that by defining the entire environment using a Github repo. Please note that this is advanced, and requires some previous knowledge of DevOps, bash shell scripts, and VVV provisioning itself. \n\nWe have prepared a boilerplate repo for you to download / fork / clone as you would like. You can check out the readme file, and the provision/vvv-init.sh file for notes about how to go about configuring your own private staging server, right inside VVV.\n\nhttps://github.com/WordPress-Phoenix/vvv2-provision-boilerplate\n\n## Connecting Sequel Pro to VVV\n\n1. Open Sequel Pro\n2. Click +Add New Connection\n3. Click SSH tab option and fill out the fields below:\n```\nMySQL Host: 127.0.0.1\nUser: \t\twp\nPass: \t\twp\nDatabase: \t(empty)\nPort: \t\t3306\nSSH Host: \tvvv.test\nSSH User: \tvagrant\nSSH Pass: \tvagrant\nSSH Port: \t(none)\nUnchecked SSL box\n```\n\n# Setup Other/Misc Config\n- Plugins for PHPStorm: dash, gfm, .ignore\n- PHPStorm-\u003eprefs-\u003eeditor-\u003ecode style-\u003ephp-\u003e”Set From…”-\u003eWordpress\n- `git config --global user.name \"John Doe\"`\n- `git config --global user.email johndoe@example.com`\n- Finder-\u003e prefs-\u003e new finder at “choose user dir” and then setup favorites sidebar\n- RSA Token + PIN Automator app https://github.com/dustingraves/RSA-Copy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwordpress-phoenix%2Flocal-wordpress-development","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwordpress-phoenix%2Flocal-wordpress-development","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwordpress-phoenix%2Flocal-wordpress-development/lists"}