How to Setup the LAMP Stack on Mac OS X

Install Apache MySQL, & PHP on Mac OS X Yosemite

Setup LAMP on Mac OSX

LAMP is an acronym for Linux, Apache HTTP Server, MySQL relational database management system, and PHP server-side programming language.   This web service solution stack is a model for building dynamic web applications and web services.  Web developers can now implement this model on their Mac OS X Yosemite computers to support the development of web-based applications and web services.

Please use caution when installing new software on computer systems. A Best Practice includes creating system backups before changes.

How to Enable Apache Web Server on Mac OS X

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems.

Apache Web Server is already included with Mac OS X Yosemmite.  This server can be started with the following steps.

Open a terminal window and log in as the root user:
$ sudo su –
(enter root password at the prompt)

Start Apache with the following command:
$ apachectl start

Verify the Apache Web Server is running on your Mac OS X by opening a web browser and navigating to http://localhost

 How to Enable PHP for Apache

PHP is a popular server-side scripting language designed for  web development.

Enabling PHP for the web server on Mac OS X requires an edit of the Apache configuration file.  A copy of the current version of this configuration file can be saved before the edit by running the following command in the terminal.

$ cp /etc/apache2/httpd.conf  /etc/apache2/httpd.conf.bak

The Apache configuration file can be edited by running the following command in the terminal.

$ vi /etc/apache2/httpd.conf

This will open the configuration file in the terminal window.  Edit this file by pressing “i” key.  Enable PHP for Apache by uncommenting (remove #) the following line.

Enable Virtual Hosting by uncommenting the following line.

Enable Mod Rewrite by uncommenting the following line.

Save and close this configuration file by pressing the “escape” key, then entering the following command.

$ :wq

How to Create Virtual Hosts in Apache

The term Virtual Host refers to the practice of running more than one web site on a single machine.  We enabled virtual hosting by allowing Apache to load the httpd-vhosts.conf file in the previous step of editing the httpd.conf file by uncommenting the following line.  Include /private/etc/apache2/extra/httpd-vhosts.conf

How to Define a Virtual Host in Apache

The site we are creating in the example is “mobile” with “local” as the top-level domain (TLD).  This will give us http://mobile.local as the URL.  I use “local” as the TLD to help me remember the site is running on my local system, but you can use any value for the TLD.  You can also use any value for the site.  The next few steps will also include defining a local project directory for your new web project.  You can change these values to match your needs, just make sure your values match the values you define in the Virtual Host entry in Apache.

Create a folder on your local file system for the DocumentRoot of your new site.

/1/projects/mobile/www/DocumentRoot

Create a backup of the httpd-vhosts.conf file by running the following command.

$ cp /etc/apache2/extra/httpd-vhosts.conf /etc/apache2/extra/httpd-vhosts.conf.bak

Edit the httpd-vhosts.conf file with the following command.

$ vi /etc/apache2/extra/httpd-vhosts.conf

Add the following markup to the httpd-vhosts.conf file.

Note how the <Directory> definition is slightly different for Apache 2.4. This Apache 2.4 configuration will prevent the Forbidden error that is accompanied by the Apache error message, “You don’t have permission to access / on this server.”

This next step assumes the owner defined in Apache config is _www. Replace “_www” with the name of Apache Server owner. Open a Terminal Window and navigate to the parent folder of the new site directory, then enter the following commands:
# Move into the new site directory
$ cd /1/projects/mobile/www/
# Change ownership of all files to the Apache Server process owner
$ sudo chown -R :_www DocumentRoot
# Change permissions of all site files
$ sudo chmod -R g+w DocumentRoot

 How to Define Virtual DNS

In order to access your new site by name, you will need to edit your system’s hosts file.
# Open /etc/hosts file
$ vi /etc/hosts
# Add the following line towards the bottom of the /etc/hosts file.
127.0.0.1 mobile.local
# Save and close file, then flush the DNS with the following command:
$ discoveryutil udnsflushcaches
# Restart Apache
$ apachectl restart

How to Create a PHP Test Page

The PHP test page for your new site can be created with the following commands.
# Create file
$ vi /1/projects/mobile/www/DocumentRoot/php.php
# Press the “i” key to edit this new file and enter

# Press the escape key to exit editing mode, then save file
$ :wq
# Open a web browser and go to the following URL

http://mobile.local/php.php

How to Install MySQL on Mac

MySQL is the world’s most popular open source database.

  1. Download the MySQL DMG for Mac OS X here.
  2. Install MySQL
  3. Install Preference Pane
  4. Start MySQL from Mac System Preferences Panel

Add MySQL to System PATH with the following commands.
# Modify/Create the .bash_profile file
$ touch ~/.bash_profile
$ vi ~/.bash_profile
# Add the following line to the bottom of ~/.bash_profile
export PATH=”/usr/local/mysql/bin:$PATH”
# Activate ~/.bash_profile update
$ source ~/.bash_profile
$ echo “/usr/local/mysql/bin” >> /etc/paths.d/mysql.path

Connect PHP and MySQL
$ cd /var
$ mkdir mysql
$ cd mysql
$ ln -s /tmp/mysql.sock mysql.sock

How to Install phpMyAdmin

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web.  Download phpMyAdmin here.

Download phpMyAdmin to the system’s default web directory, “/Library/WebServer/Documents/”; then run the following commands from the Terminal Window.

# Move into default web directory
$ cd /Library/WebServer/Documents/
# Unpack phpMyAdmin download
# NOTE: Use actual phpMyAdmin download file name
$ tar -xvf ~/Downloads/phpMyAdmin-3.5.2.2-english.tar.gz
# Rename unpacked phpMyAdmin folder
# NOTE: Use actual phpMyAdmin download folder name
$ mv phpMyAdmin-3.5.2.2-english/ phpmyadmin
# Move into the new phpmyadmin directory
$ cd phpmyadmin
# Create the phpmyadmin config file
$ mv config.sample.inc.php config.inc.php

Launch the phpmyadmin dashboard by opening a web browser and navigating to the following URL: http://localhost/phpmyadmin

How to Start the Virtual Environment

This Mac OS X Apache MySQL PHP development environment can be started with the following steps.

# Make sure the MySQL database is running
Open MySQL Panel from Mac OS X System Preferences
# Open Terminal and switch to root user
$ sudo su –
# Use Terminal Command to start Apache
$ apachectl restart
# Use a Web Browser and Navigate to Website

How to Create Additional Virtual Environments

Additional virtual environments can be easily be created by just repeating the steps outlined in “How to Define a Virtual Host in Apache” section of this tutorial.

Summary

Following these steps provides the web developer with a development environment for creating web applications and web services using open-source technology.

The Volume, Velocity, Variety, and Visualization of Big Data

What if We had More Big Data Artists in the World?

Today’s Big Data Scientists are being challenged with discovering actionable insights from the Volume, Velocity and Variety of data resources in cost-effective innovate ways. This is the foundation of Big Data Trends and has tremendous value when understanding is Visualized by today’s Big Data Artists.

Big Data Artists and Data Storytelling

Data comes to life in the hands of Data Artists.  Effective Data Storytelling can inspire new ideas and actions. Statistics guru Hans Rosling is a modern day Michelangelo of Big Data.  Watch his TED Talk video about “global trends in health and economics“.  Hans really gets rolling into this data story at about the 4 minute mark of this video.

Big Data Virtualization

Processing unstructured, semi-structured, and structured data can be accomplished with open-source tools such as Hadoop, MongoDB, Node.JS, with multiple programming languages including Java and Python. Many of these Big Data Tools can be installed and configured within a few minutes.  We can also leverage Cloud Computing for processing Big Data. Cost-effective processing of Graph Data for Social Network Analytics can be accomplished with GraphChi.  My friend and colleague, Brad Cox, created an easy to use plugin to accelerate graph data processing.  There are a plethora of tools and resources out there.  Help others and share your favorites here. Continue reading

Humanize the Enterprise for Innovation

HUMANIZE THE ENTERPRISE

Harnessing the Power of Engagement to Drive Innovation

The negative impact of the global economy has created barriers that prevent organizations and individuals from realizing their maximum potential.  Today’s business leaders are required to do more with less, a lot less.  Reducing costs and increasing productivity take top priority during these difficult times.  Innovative thought leaders are optimizing all business assets to remain competitive.

The most important asset to any organization is the people.  These people include employees, partners, and customers.  Organizations that survive the current transition phase and thrive in the future are the ones that harness the power of engagement. Continue reading

The Social Business of Enterprise Gamification

Social Business Gamification

Unlocking New Levels of Innovation through Collaboration


Enterprise Gamification is the use of game dynamics within organizations to support a collaborative culture that aligns with business objectives.  This creates an agile social business model that can increase chances of success in current competitive markets and future markets.  Applying Enterprise Gamification and implementing game mechanics in enterprise 2.0 platforms plays a very important role in it’s event-driven architecture for capturing the REAL value of enterprise 2.o solutions.  This REAL value is realized by lowering barriers of participation and showing the relationships of people, ideas, and things.  Implementing enterprise gamification strategy should be a part of the complete social business strategy.  Learn more at “The Secret Social Science Sauce of Gamification“.

Demystifying Enterprise Gamification for Business

Gamification describes a series of design principles, processes and systems used to influence, engage and motivate individuals, groups and communities to drive behaviors and effect desired outcomes. Continue reading

Collection of Social Business Predictions & Tech Trends for 2012

The Future of Social Business & Enterprise 2.0

Many Things in Motion

The Collective Intelligence of Social Business

We are about to embark on an innovative journey that will transform the workforce.  This new innovation age will blur the lines of work and play.  Integrating internal and external Social Media into Enterprise workflows to support collaborative business intelligence will become more of a priority.  The future of Social Business will empower the workforce, partners, and customers in the process of co-creation that will drive new levels of innovation across multiple markets.  These new business models will begin to harness the power of Collective Intelligence as the Enterprise explores collaboration beyond it’s main silo, the firewall.

“The whole is greater than the sum of its parts.” – Aristotle Continue reading