Actually, OS X may came up with Apache and PHP installed by default. This is more likely to be an old build, and in that case that may lack many of the less common extensions. So if you want to set up Apache, PHP and MySQL or PostgreSQL in your machine, this is easiest way to do. MAMP is good, but it's gonna install everything from scratch. The same goes for PHP via homebrew. I have tried all of those. But you have to remember that your Mac comes bundled with Apache and PHP out of the box. You just have to add MySQL to the mix and get rolling.
How to Set Up PHP, HTML & MySQL Development on Mac OS X February 7, 2017 Comparatio 0 The following are instructions for setting up a development environment on a Mac that can be used for HTML, PHP and MySQL. Dec 16, 2016 Apache and PHP come packaged with OS X. To create a local web server, all you need to do is configure Apache and install MySQL. Apache Enable Apache on Mac OS X To check what version of apache you have currently installed on your mac just open you terminal and type httpd -v Verify. It installs Apache, PHP and other XAMPP components directly on your OS X system, in the /Applications/XAMPP folder. XAMPP-VM is a virtual machine for OS X. It includes Apache, PHP and other XAMPP components and runs them in a Linux-based virtual machine on your OS X system. For more information, refer to the blog post at https://www.
Mac OS X serves as an excellent development environment, even if you are not actually developing Mac OS or iOS applications. It is the darling of many a LAMP (Linux, Apache, MySQL and PHP) developer, who enjoys a slick desktop operating system with good UNIX-like underpinnings but who don’t necessarily want to put up with all the various limitations and complications that running a Linux desktop brings, consistent improvements in this regard over recent years notwithstanding.
The only trouble with this is that if you want to develop LAMP applications and work on a Mac then traditionally you’ve needed a two-box setup; a Mac on your desk and Linux on a development server. For many this isn’t an issue, and indeed when you’ve got a team of developers, optimal, but what if you wanted a self-contained development environment that was restricted to just one box? What if you wanted that box to be your laptop so you could take it anywhere?
“Virtual machine!”, I hear you cry. Yes, this is a possible solution, and for many works well. Good virtualisation software is free these days, but using a local VM is cumbersome. Not only does it consume a large slice of your RAM but it also puts a lot of strain on the CPU, meaning that if you are running off your battery your battery life will be decreased. It’s also cumbersome; you have to start up the VM when you need it and there can be complications with the networking, for example, if you have connected to a public wireless network it’s possible that your VM might not be extended the same resource.
There is a software package for Mac OS called MAMP (the M for Mac OS replacing the L for Linux). This is a point-and-click installer which bundles Apache, Linux and PHP for installation on Mac OS. I don’t like this solution, for a number of reasons, including:
There’s an alternative to this. You don’t have to fork out £39 for a package of what it otherwise freely and widely available software. With the help of my friend and colleague Ben Nimmo I present the following assembled and tested instructions for turning your Mac into a native MAMP server without using the packages download.
PHP comes with Mac OS, so it’s not necessary to download and install it, however, there are a couple of necessary steps to configure it:
Apache too comes with Mac OS, so again, no need to download and install it. Its configuration, however, is a little more complex, but nothing scary. The described configuration will provide a special Apache “sandbox” environment for your projects. It uses the existing “Sites” directory in your Mac OS home directory.
Then, for each of your sites, add an entry in /etc/hosts for with the format “name.dev.local” pointing to 127.0.0.1, where name corresponds to a subdirectory in your “Sites” directory. Don’t forget that the public subdirectory of each site is assumed to be “web”, so make a symlink to this if the framework you use has a different convention.
You should then be able to access each of your sites from URLs using the convention http://name.dev.local/ – where “name” again is a subdirectory within your “Sites” directory.
I’ve tested this setup procedure and It Works For Me [tm]. If, however, it doesn’t quite work for you as described, please let me know where you’re going wrong and how, if you were able, to resolve it, and I will update these instructions accordingly.
For a list of macOS versions that the MySQL server supports, see https://www.mysql.com/support/supportedplatforms/database.html.
MySQL for macOS is available in a number of different forms:
Native Package Installer, which uses the native macOS installer (DMG) to walk you through the installation of MySQL. For more information, see Chapter 2, Installing MySQL on macOS Using Native Packages. You can use the package installer with macOS. The user you use to perform the installation must have administrator privileges.
Compressed TAR archive, which uses a file packaged using the Unix tar and gzip commands. To use this method, you will need to open a Terminal window. You do not need administrator privileges using this method, as you can install the MySQL server anywhere using this method. For more information on using this method, you can use the generic instructions for using a tarball, Installing MySQL on Unix/Linux Using Generic Binaries.
In addition to the core installation, the Package Installer also includes Chapter 3, Installing a MySQL Launch Daemon and Chapter 4, Installing and Using the MySQL Preference Pane, both of which simplify the management of your installation.
For additional information on using MySQL on macOS, see Chapter 5, General Notes on Installing MySQL on macOS.