Come With Me Mac OS

macOS Update: While these instructions still work, there are new posts for recent versions of macOS, the latest being Install Apache, PHP, and MySQL on macOS Mojave.

HoRNDIS (pronounce: “horrendous”) is a driver for Mac OS X that allows you to use your Android phone's native USB tethering mode to get Internet access. It is known to work with Mac OS X versions 10.6.8 (Snow Leopard) through 10.14 (Mojave – see notes below), and has been tested on a wide variety of phones. Although you should be careful. Get Office apps for Mac. Start quickly with the most recent versions of Word, Excel, PowerPoint, Outlook, OneNote and OneDrive —combining the familiarity of Office and the unique Mac.

I have installed Apache, PHP, and MySQL on Mac OS X since Leopard. Each time doing so by hand. Each version of Mac OS X having some minor difference. This post serves as much for my own record as to outline how to install Apache, MySQL, and PHP for a local development environment on Mac OS X Mountain Lion Mavericks.

I am aware of the several packages available, notably MAMP. These packages help get you started quickly. But they forego the learning experience and, as most developers report, eventually break. Personally, the choice to do it myself has proven invaluable.

Mac OS 8 is an operating system that was released by Apple Computer, Inc. On July 26, 1997. It includes the largest overhaul of the classic Mac OS experience since the release of System 7, approximately six years before.It emphasizes color more than prior versions. Released over a series of updates, Mac OS 8 represents an incremental integration of many of the technologies which had been. We are the premier worldwide provider of OS X Server Hosting. With over 5 years in Mac specific hosting services, we offer a effective and unique approach to mac cloud servers. Our customers enjoy working with us because we’re fast, uncomplicated and offer real support. We would like to show you a description here but the site won’t allow us.

It is important to remember Mac OS X runs atop UNIX. So all of these technologies install easily on Mac OS X. Furthermore, Apache and PHP are included by default. In the end, you only install MySQL then simply turn everything on.

First, open Terminal and switch to root to avoid permission issues while running these commands.

Enable Apache on Mac OS X

Note: Prior to Mountain Lion this was an option for Web Sharing in System Prefrences → Sharing.

Verify It works! by accessing http://localhost

Enable PHP for Apache

OS X Mavericks Update: You will need to rerun the steps in this section after upgrading an existing install to Mac OS X Mavericks.

First, make a backup of the default Apache configuration. This is good practice and serves as a comparison against future versions of Mac OS X.

Now edit the Apache configuration. Feel free to use TextEdit if you are not familiar with vi.

Uncomment the following line (remove #):

Restart Apache:

Install MySQL

  1. Download the MySQL DMG for Mac OS X
  2. Install MySQL
  3. Install Preference Pane
  4. Open System Preferences → MySQL
  5. Ensure the MySQL Server is running
  6. Optionally, you can enable MySQL to start automatically. I do.

The README also suggests creating aliases for mysql and mysqladmin. However there are other commands that are helpful such as mysqldump. Instead, I updated my path to include /usr/local/mysql/bin.

Note: You will need to open a new Terminal window or run the command above for your path to update.

I also run mysql_secure_installation. While this isn't necessary, it's good practice.

Connect PHP and MySQL

You need to ensure PHP and MySQL can communicate with one another. There are several options to do so. I do the following:

Creating VirtualHosts

You could stop here. PHP, MySQL, and Apache are all running. However, all of your sites would have URLs like http://localhost/somesite/ pointing to /Library/WebServer/Documents/somesite. Not ideal for a local development environment.

OS X Mavericks Update: You will need to rerun the steps below to uncomment the vhostInclude after upgrading an existing install to Mac OS X Mavericks.

To run sites individually you need to enable VirtualHosts. To do so, we'll edit the Apache Configuration again.

Uncomment the following line:

Now Apache will load httpd-vhosts.conf. Let's edit this file.

Here is an example of VirtualHosts I've created.

The first VirtualHost points to /Library/WebServer/Documents. The first VirtualHost is important as it behaves like the default Apache configuration and used when no others match.

The second VirtualHost points to my dev workspace and I can access it directly from http://jason.local. For ease of development, I also configured some custom logs.

Note: I use the extension local. This avoids conflicts with any real extensions and serves as a reminder I'm in my local environment.

Restart Apache:

In order to access http://jason.local, you need to edit your hosts file.

Add the following line to the bottom:

Come With Me Mac OS

I run the following to clear the local DNS cache:

Now you can access http://jason.local.

Note: You will need to create a new VirtualHost and edit your hosts file each time you make a new local site.

A note about permissions

You may receive 403 Forbidden when you visit your local site. This is likely a permissions issue. Simply put, the Apache user (_www) needs to have access to read, and sometimes write, your web directory.

If you are not familiar with permissions, read more. For now though, the easiest thing to do is ensure your web directory has permissions of 755. You can change permissions with the command:

In my case, all my files were under my local ~/Documents directory. Which by default is only readable by me. So I had to change permissions for my web directory all the way up to ~/Documents to resolve the 403 Forbidden issue.

Note: There are many ways to solve permission issues. I have provided this as the easiest solution, not the best.

Install PHPMyAdmin

Unless you want to administer MySQL from the command line, I recommend installing PHPMyAdmin. I won't go into the details. Read the installation guide for more information. I install utility applications in the default directory. That way I can access them under, in this case, http://localhost/phpmyadmin.

Closing

A local development environment is a mandatory part of the Software Development Process. Given the ease at which you can install Apache, PHP, and MySQL on Mac OS X there really is no excuse.

Find this interesting? Let's continue the conversation on Twitter.

Recommend switching to Docker

I finally switched to using Docker for local development on macOS. While the following tutorial works for macOS Catalina, it has limitations. I recommend following my latest tutorial on installing Apache, MySQL, and PHP on macOS using Docker.

Note: This post assumes you followed installing Apache, PHP, and MySQL on Mac OS X Mojave and have since upgraded to macOS Catalina. If you did not follow the original post, you should follow installing Apache, PHP, and MySQL on macOS Catalina.

When Mac OS X upgrades it overwrites previous configuration files. However, before doing so it will make backups. For Catalina the original versions may have a suffix of mojave or be copied to a backup folder on the Desktop. Most of the time, configuring your system after updating Mac OS X is simply a matter of comparing the new and old configurations.

This post will look at the differences in Apache, PHP, and MySQL between Mac OS X Mojave and macOS Catalina.

Updating Apache

Mac OS X Mojave and macOS Catalina both come with Apache pre-installed. As noted above, your Apache configuration file is overwritten me when you upgrade to macOS Catalina.

There were a few differences in the configuration files. However, since both Mojave and Catalina run Apache 2.4, you could simply backup the configuration file from Catalina and overwrite it with your Mojave version.

Come With Me Mac Os 11

However, I encourage you to stay up-to-date. As such, you should take the time to update Catalina's Apache configuration. First, create a backup and compare the two configuration files for differences.

Now edit the Apache configuration. Feel free to use a different editor if you are not familiar with vi.

Uncomment the following line (remove #):

In addition, uncomment or add any lines you noticed from the diff above that may be needed. For example, I uncommented the following lines:

Finally, I cleaned up some of the backups that were created during the macOS Catalina upgrade. This will help avoid confusion in the future.

Note: These files were not changed between versions. However, if you changed them, you should compare the files before running the commands.

Restart Apache:

Updating PHP

Mac OS X Mojave came with PHP version 7.1 pre-installed. This PHP version has reached its end of life. macOS Catalina comes with PHP 7.3 pre-installed. If you added any extensions to PHP you will need to recompile them.

Come With Me Mac Os Download

Also, if you changed the core PHP INI file it will have been overwritten when upgrading to macOS Catalina. You can compare the two files by running the following command:

Come With Me Mac Os Catalina

Note: Your original file may note be named something else. You can see which PHP core files exist by running ls /etc/php.ini*.

I would encourage you not to change the PHP INI file directly. Instead, you should overwrite PHP configurations in a custom PHP INI file. This will prevent Mac OS X upgrades from overwriting your PHP configuration in the future. To determine the right path to add your custom PHP INI, run the following command:

Note: It appears Catalina does not include the PHP Zip extension. This is a popular extension used by many packages. This was one of the reasons I switched to using Docker.

Updating MySQL

Come With Me Mac Os X

MySQL is not pre-installed with Mac OS X. It is something you downloaded when following the original post. As such, the macOS Catalina upgrade should not have changed your MySQL configuration.

Find this interesting? Let's continue the conversation on Twitter.