-
First, to check if Homebrew is already installed, type the following into the Terminal:
brew --version -
If
brewis installed, skip to step 6; otherwise continue following the install instructions. -
If it is not installed, launch Xcode and if prompted, agree to the Terms and Conditions. Then, open the Terminal and install the Command Line tools with this command:
xcode-select --install -
You can go to the Homebrew site for more information, but to install Homebrew, run this command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -
Once it has finished, ensure
brewinstalled correctly by typing:brew --version -
Run the following command to ensure everything is configured properly:
brew doctor -
Run the following command to ensure
brewis up to date:brew update
-
First, check if Anaconda is already install by running the command:
conda --version -
If installed, skip to step X; otherwise continue.
-
Download Anaconda. Choose the Anaconda Graphical Installer for Python 2.7 for Mac OS X.
-
Open the installer and follow the directions.
-
To make sure Anaconda properly installed, open a Terminal window and run:
conda --version -
Make sure Anaconda is up to date by running:
conda update anaconda
-
First, check if git is already install by running the command:
git --version -
If already installed, move onto the next section; otherwise, continue.
-
We will be using Homebrew to install git. Run the following commands in Terminal:
brew update brew install git brew doctor
-
First, check if SQLite is already install by running the command:
sqlite3 -version -
If already installed, move onto the next section; otherwise, continue.
-
We will be using Homebrew to install SQLite. Run the following commands in Terminal:
brew update brew install sqlite brew doctor
-
First, go to Applications, and see if Sequel Pro is already installed.
-
If already installed, move onto the next section; otherwise, continue.
-
Download Sequel Pro and install.
-
When finished installing, be sure to unmount the DMG file from your computer.
Note: PyCharm is merely a suggestion for what to use when working in Python.
-
As a student, you qualify for a free license for PyCharm through JetBrains. Go to JetBrains and click on apply.
-
Once you have applied and created an account through JetBrains, download the professional version of PyCharm.
-
PyCharm requires Java which can be downloaded here. You can also install using Homebrew.
-
When PyCharm asks for a license, provide your account login information for your JetBrains account. Your license must be renewed yearly.
You may want to download/try out other text editors or IDEs that fit your working style.
-
Spyder comes packaged with Anaconda. It is a Python IDE. To run it from the Terminal:
/Users/<username>/anaconda/bin/spyder ; exit; -
Komodo Edit is a fairly simple text-editor.
-
You could also try out PhpStorm and WebStorm also through JetBrains.
This a step by step guide on setting up the local web development environment on your Mac. The steps I include are taken from this tutorial. However, the tutorial also includes extra details that are not needed, so I include the necessary steps below.
Apache is a web server, and we will be using it to do web development locally. Apache 2.4 is pre-installed on OS-X Yosemite.
-
To start up the web server, open Terminal and run:
sudo apachectl start -
To stop the web server, open Terminal and run:
sudo apachectl stop -
To restart the web servera after having made configuration changes, open Terminal and run:
sudo apachectl restart -
To make sure Apache is working, start Apache , and then try to reach your server in a browser by pointing it at your localhost, you should see a simple header that says It works!.
-
Note: If you cannot reach your site via
http://localhostyou might need to add an alias in your/etc/hostsfile:127.0.0.1 localhost. It should exist by default.
We are going to change the document root for Apache, so it points to a folder in our home directory.
-
To do so, we need to edit Apache's configuration file. You can use whatever command line editor you are comfortable with, just realize this is a
root-ownedfolder so you will need to usesudoto be able to edit and save the file. I prefer to usevim:sudo vim /etc/apache2/httpd.conf -
Search for the term
DocumentRoot, and you should see the line:DocumentRoot "/Library/WebServer/Documents" -
Change that line to the directory you want to point to on your account where
<username>is your username:DocumentRoot "/Users/<username>/Sites" -
You also need to change the
<Directory>tag reference right below the DocumentRoot line. This should also be changed to point to your new document root also:<Directory "/Users/<username>/Sites"> -
In that same
<Directory>block you will find anAllowOverridesetting, this should be changed as follows:AllowOverride All -
Now we have the Apache configuration pointing to a
Sitesfolder in our home directory. One problem still exists, however. By default, Apache runs as the user_wwwand group_www. This will cause permission problems when trying to access files in our home directory. About a third of the way down thehttpd.conffile there are two settings to set theUserandGroupApache will run under. Change these to match your user account (replace<username>with your real username), with a group ofstaff:User your_user Group staff -
Now, save and close the file.
-
Restart your Apache with
sudo apachectl restartto pick up the changes you made to the configuration file. -
Now, you need to create a
Sitesfolder in the root of your home directory. You can do this in Terminal, or in Finder. In this newSitesfolder create a simpleindex.htmland put some dummy content in it like:<h1>My User Web Root</h1>.mkdir ~/Sites echo "<h1>My User Web Root</h1>" > ~/Sites/index.html -
Pointing your browser to
http://localhostshould display your new message. If you have that working, Apache has been correctly configured!
- We will be installing PHP 5.4 through Homebrew. PHP is used for web development, and the backend of Wordpress is written in it.
-
First, make sure Homebrew is up to date.
brew update brew doctor -
Next, we have to
tapinto the PHP formulas from Homebrew.brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php -
Once that is complete, install PHP 5.4.
brew install php54 brew doctor -
You have successfully installed PHP 5.4 but we need to tell Apache to use it. You will again need to edit the
/etc/apache2/httpd.conffile and search for#LoadModule php5_module. You will notice that this is line is commented out. We can ignore it because this is pointing to the version of PHP that came with OS X. Below the other LoadModule lines, add this:# Brew PHP LoadModule LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so -
You should also take this time to uncomment the
mod_rewrite.somodule definition so that it will be available:LoadModule rewrite_module libexec/apache2/mod_rewrite.so -
Restart Apache again, now that PHP has been installed.
sudo apchectl restart -
We need to make sure PHP is installed and running as expected. Simply create a file called
info.phpin yourSitesfolder you created earlier. In that file, just enter the line:<?php phpinfo(); ?> -
Point your browser to
http://localhost/info.phpand you should see a PHP information page:
- If you see a similar phpinfo result, Apache and PHP are running successfully.
- While SQLite is useful for quick database creation and sharing, MySQL is scalable, secure and necessary for Wordpress.
-
We will be using MariaDB which is a drop-in replacement for MySQL and is easily installed and updated with Homebrew. Open Terminal, and run the follwing commands:
brew update brew install mariadb brew doctor unset TMPDIR mysql_install_db -
After a successful installation, you can start the server:
mysql.server start -
If you are successful, you will see the following:
Starting MySQL .. SUCCESS! -
Change the MySQL server password and secure your installation. The simplest way to do this is to use the provided script:
/usr/local/bin/mysql_secure_installation -
Just answer the questions and fill them in as is appropriate for your environment.
-
To stop the MySQL server, use the command:
mysql.server stop
