Last year, I got myself a Macbook Air for two reasons: a powerful terminal and popular graphics software. I thought the transition would be smooth; but only when I started the process did I realize the complexity of the task.
SitePoint recently published articles on setting up a development machine on Ubuntu and setting up a development machine on a Mac. In this post, I'll look at the subtle differences you might face when shifting your development environment from Ubuntu to OS X, or vice versa.
General Procedure for Installing Software
Let's first talk about what you can expect on OS X if you're used to Ubuntu.
OS X, owing to its high market share, has a large developer base. Therefore, almost all pieces of software have an OS X installer. How you install them is interesting. An installer usually walks you through the installation (much like an installation wizard on Windows). Some packages might be available in the form of
.dmg files, which are none other than compressed files. You need to move the extracted application to the
Applications directory. Removing such packages just requires removal from the
Applications directory. Here's a guide on installing downloaded software on a Mac.
Alternatively, the installation of applications might also be done through the App Store. However, not all applications are available there. Those that aren't — such as browsers like Chrome and Firefox, and text editors like Sublime Text — are easily downloaded from their respective websites and installed as described above.
Terminal on a Mac
In the terminal, most commands are similar (except those that are specifically package related). For instance, running the
grep command to search for a phrase is exactly the same.
However, if you're interested in developing scripts that run across platforms (including old Mac versions), you may find this guide by Apple developers interesting.
Further, for the list of subtle differences in commands, visit A Sysadmin's Unixersal Translator, by Rosetta Stone, and select OS X and Linux from the list of operating systems on the top left corner. From the list, you can see that the usage of most commonly used commands is the same.
Homebrew: the Package Manager for Mac
apt-get as a package manager, whereas Fedora has
Unfortunately, there's no default package manager for Mac that magically installs every new piece of software you might wish to have. Although there are many alternatives like MacPorts and Fink, the best package manager for Mac is probably Homebrew. In case you're interested, here's a comparison between the three options.
Installing Homebrew is easy: you just need to run a single command, as mentioned on their website:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The installation script is in Ruby. Ruby comes pre-installed on a Mac. During installation on a fresh machine, you're prompted to install components of XCode Command Line Tools, which you need to approve. To verify that Homebrew has been installed, you can run
Installing packages through Homebrew is similar to other package managers. Homebrew installs packages for the local user, and therefore doesn't require any root privileges. We'll look at the process of installing packages on Homebrew later in this post. Meanwhile, make sure Homebrew is updated by running the following commands:
brew update brew doctor brew upgrade
Using SourceTree on a Mac
Almost all developers today — especially those working in teams — need to use version control to collaborate. The most popular version control tool is Git, although many prefer Mercurial or Subversion.
Matthew explained his choices for version control in his post, such as GUI tools like SourceTree or GitX. These GUI tools come with their own version of Git. SourceTree supports both Git and Mercurial.
If you prefer using version control through the command line, you need to install your version control system separately. Git has a package for Mac, but if you need the latest development version, you'll have to build from the source.
Note: if there's a separate version of Git/Mercurial present in your system when you install SourceTree, you'll be asked whether you want to use the version in your system or the version bundled with SourceTree.
Let's Get Coding
If you're one of those who can't wait to get started, this is the section that starts the coding. Thankfully, most of the important stuff comes pre-installed on the latest version of Mac OS X — El Capitan. In addition to Python, Ruby and PHP, El Capitan also has Apache 2.4 pre-installed! In OS X, the
apachectl command runs Apache, as compared to
apache on ubuntu.
For those running OS X, Python, Node.js and Ruby have installers, or you can compile them by getting your desired version. PHP doesn't have an installer for OS X, though, but can be compiled from its source. All of them can also be installed through Homebrew. For instance, you can run the following command to install PHP 5.6:
brew install php56
Similarly, run the following to install Python 3:
brew install python3
You can use MAMP stack (Mac, Apache, MySQL, PHP) to get the bundle (similar to LAMP for Linux and WAMP for Windows). This lets you start development quickly, without worrying about individual installations. MAMP has a specific installer, which you can run every time you want to start the development environment. Working with MAMP is similar to using WAMP or LAMP.
List of tables in a database in MySQL
Although using MAMP would eliminate the need to install a database, the database can't be used by an external application. Let's now see how to install MySQL on Mac OS X. The easiest way is to use Homebrew (yet again!):
brew install mysql
MySQL comes with an installer for Mac. Installing it is a simple process, as explained on the MySQL website.
Similarly, PostgreSQL can be installed on Mac OS X through an installer or through Homebrew.
If you prefer a NoSQL database like MongoDB, Homebrew has a recipe for that, too:
brew install mongodb
MongoDB doesn't have an installer for Mac. In the absence of a package manager, you would need to compile MongoDB from the source if you don't use a package manager.
Over the last year, I've realized that a Mac boosts your productivity — if used the right way. There's a number of productivity apps for Mac that one must use.
Caffeine is a useful app, which, when activated, prevents the screen saver, screen dimming, or the system going to sleep. It's just perfect for running scripts that might take a long time to execute.
Google Drive and Dropbox are essential too, for keeping your local files synced with the cloud. Drive and Dropbox sync files in their special folders, but MacDropAny lets you
drop any normal folder and covert into a Drive or Dropbox folder.
In this post, I looked at the process of shifting your development environment from Ubuntu to Mac OS X. Although I've described the manual process, there are services like Vagrant and Docker that help you make portable development environments that make setting it up on a new system fast.
Do you agree with my development environment? Is there anything important that I missed out? Please speak up in the comments below.
10 Top WordPress Ecommerce Themes for 2021
By Monique Danao,
With WordPress themes, you can build a great ecommerce site without being a designer or coder. Here are ten top WordPress ecommerce themes.
A Beginner’s Guide to Keras: Digit Recognition in 30 Minutes
By Shaumik Daityari,
Want to create an artificial neural network? Learn step by step how to create a model for recognizing handwritten digits.
A Comparison of Ruby Version Managers for macOS
By Daniel Kehoe,
If you're a serious Ruby developer, you'll need an up-to-date version, possibly several. We cover the best Ruby version managers for macOS.