![]() ![]() Press “Control x” to exit, then type “y,” and press Return to save your changes. You can add more hosts on separate lines. Where v is the name of your virtual host. Navigate to the end of the file, then add the following entry: In this case, we will create relationships between the virtual host/domain with the local web sever IP of 127.0.0.1. The host file acts as a local DNS server, referencing user-friendly domains to IP addresses. The last step is to add the entry to you host file. Sudo apachectl restart Update the Hosts file You’ll want to restart the Apache service whenever you make a change to a configuration file. You’ll need to add a virtual host entry for each local site. dev helpful to identify a local development site versus the public production site. ServerName is the domain you plan to use to refer to your local development site. VirtualDocumentRoot "/Users/ with your username, if you decide to place your local sites in development under the Sites folder. Here’s an example of a barebones virtual host entry: Now, for each virtual host, you need to add an entry. ![]() # ServerAdmin DocumentRoot "/Applications/MAMP/Library/docs/" You can remove or comment out these entries. There will likely be two sample entries in the file. Move the cursor down to where the virtual host entries are. Sudo nano -w /Applications/MAMP/conf/apache/extra/nf Now, in Terminal, open the vhosts configuration file (nf): With the nf entry enabled in the Apache configuration file (nf), Include /Applications/MAMP/conf/apache/extra/nf LoadModule vhost_alias_module modules/mod_vhost_alias.so Search on “vhosts,” and uncomment (remove the leading #) the following two lines: Once the file is open, perform a search (Control w) for two entries that are commented out by default. Sudo nano -w /Applications/MAMP/conf/apache/nf Using Terminal, open the MAMP Apache configuration file. With Apache set up, it’s now time to focus on configuring it to handle virtual hosts. Now, you can run MAMP’s Apache on port 80 with no conflicts. Sudo launchctl unload -w /System/Library/LaunchDaemons/ To eliminate this conflict and to leverage port 80 for MAMP’s Apache, I disabled the default instance of Apache from autostarting using the following Terminal command: Placing MAMP’s Apache at port 80 creates a conflict. ![]() The default Apache web server uses port 80. The preference is to change this to 80 for Apache and 3306 for MySQL. Leaving the ports this way, you would be forced to add the port to the URL locally (ex. Once downloaded and installed, MAMP needs to be configured.īy default, MAMP sets the ports to 8888 (Apache) & 8889 (MySQL). This will play into one of the issues I had to overcome. By installing MAMP, I have decided to use the MAMP version of Apache. Note: macOS by default offers the Apache web server. MAMP is the bundled package for the macOS there are similar bundles for Windows-based PCs (ex. All of these are needed to run and develop for WordPress locally. MAMP is the bundle of Apache, PHP and MySQL. After every attempt failed, I decided to wipe out my Mac, and start from scratch. Several months after the Sierra macOS upgrade became available, I hoped this upgrade would resolve the issue, to no avail. At one point, I lost the ability to have MAMP’s Apache run without issue. No matter what I did, I couldn’t get virtual hosts to function again. After a regular update, I lost this functionality … all virtual host functionality. I had virtual hosts set up while on the El Capitan OS in a way when I created a new folder, the virtual host would dynamically be created. I created a decent local development that worked for me simple, straightforward, not complex. I’m fairly new to the Mac, have transitioned from the PC full time a couple years ago. I decided to write this post for two reasons 1.) as a personal reference and 2.) to share what I learned so that others might get to their goal quicker. ![]()
0 Comments
Leave a Reply. |