Configure local wordpress development on mac OS
I can’t use newest wamp version because of my windows 7 system. So I decided to set up a local wordpress environment on my mac.
I recorded all the process in case I have to do the same in the future.
Apache and PHP are already on my machine by using the command
apachetl -v
php -v
Then make a tiny adjustment in its configuration(I use visual studio which I can use code command to open ):
sub code /etc/apachectl2/httpd.conf
1.Enable vhost
Access wordpress projects with custom domains
2.Enable rewrites
By default mod_rewrite follows the filesystem path. We can have more customized wordpress URL by enable it
3. Enable PHP
Let server know how to deal with .php file. cause wordpress is written in PHP.
4. Change the default location for our projects
It is not a requirement, just a convention. I prefer to store the source files in the home folder
5. Enable .htaccess
The AllowOverride controls section of the configuration file allows us to enable the use of .htaccess files
6. Point customized .localhost domain to 127.0.0.1
sudo code /etc/hosts
7. Manage local domains using vhost
sudo code /etc/apache2/extra/httpd-vhosts.conf
Build a wordpress website via WP-CLI
brew install wp-cli
Command line interface is a way to save our time than traditional way.
Create that folder, and open that folder
wp core download
wp config create --dbname=NAME_OF_YOUR_DATABASE --dbuser=root --dbpass= --dbhost=127.0.0.1
Helpful tip
Most front end developer rarely build wordpress projects so there is no need to keep Apache and Mysql always running in a background. this 2 quick bash aliases can help us quick enable/disable Apache and Mysql. But need to add it to .bash_profile file.
Reference from: https://pawelgrzybek.com/configure-a-local-wordpress-development-on-macos-from-scratch/