Using MAMP for Web Development

Preview:

DESCRIPTION

Doing PHP, Perl, and Python development made easy with a great tool called MAMP. This session will demonstrate how to install and configure MAMP to speed up web development using the LAMP stack on a Mac and Windows. Additionally, the session will demonstrate how to use several different IDEs with MAMP to perform debugging and testing.

Citation preview

Using MAMP for Web

Development

devLink 2014Eric W. Greene

http://www.ericwgreene.com

Doing PHP, Perl, and Python development made easy with a great tool called MAMP. This session will demonstrate how to install and configure MAMP to speed up web development using the LAMP stack on a Mac and Windows. Additionally, the session will demonstrate how to use several different IDEs with MAMP to perform debugging and testing.

Agenda• What is MAMP?

• Installation

• Configuration & Status Overview

• Web Configuration

• Dynamic DNS Configuration

• Database

Configuration

• Mail Configuration

• IDE Configuration (IntelliJ Idea & SublimeText 2)

• MAMP for Windows - BETA

What is MAMP?• MAMP = My Apache - MySQL - PHP• A very easy to setup local server development

environment.• Web - Apache• Databases - MySQL & SQLite (plus tools)• DNS - Dynamic DNS (several providers supported)• Mail - Postfix• Server-Side Languages - PHP (multiple versions), Perl &

Python• MAMP vs MAMP PRO - PRO offers more

functionality and configuration enhancements. We will be using PRO for the demo.

• Alternative to MAMP: AMPPS -> http://www.ampps.com/

Configuration Overview

• Start/Stop Button

• Help Button

• Save Button

• WebStart Button

Status Overview

Once the web server is

started, click ‘WebStart’ to see a status overview in your web browser.

Status Overview Details

• Display PHP Info

• Display MySQL Credentials

• MAMP Version

• APC Opcode Cache Status

• Link to phpMyAdmin to manage MySQL

• Link to phpLiteAdmin to manage SQLite

• And a helpful FAQ

Web Server Configuration• General Tab - Configure default ports for HTTP, HTTPS and

MySQL. Specify the Apache/MySQL user account. Select startup options and the Apache error log file location.

• Modules Tab - Review the list of Apache modules available and enable/disable them.

• PHP Tab - Specify default version and whether to allow different versions for different sites. Select caching module. Enable the debugger. Setup logging level and where to log it to.

• Hosts Tab - Setup the various host configurations for Apache.

• SSL Tab - Configure SSL for individual hosts.

• Extras

Demo - Managing Hosts• Configure LocalHost• Add a New Host

• Configure Host Name with Hosts file.• Enable SSL on the new Host

• Add a Second New Host• Configure Host Name with Hosts file.

• View Web Site from Modern.IE Virtual Machine (ip address, Windows Hosts file & DNS entry). If the Internet connection is good, view local web site from BrowserStack.

• Delete new Host

Dynamic DNS Server• Only works if your computer/router has an

addressable IP on the public Internet or an IP address within your local network which you can access.

• If using a router, be sure to setup port forwarding to point to the port of the host you want to make accessible. I do not recommend placing your whole PC in the DMZ. Port forwarding allows you to do what you need while being as secure as possible.

• Several options are available: DNS-O-Matic, np-ip.com, dyn.com and easydns.com.

Demo - Setup Dynamic DNS 1/2

• For the demo we will use DNS-O-Matic and NameCheap.com

• Configure NameCheap.com• First, enable the Dynamic DNS service• Second, add an A record to the DNS entries for

the Hostname you would like to updated such as ‘www’. Set the TTL to 60 since this is dynamic we want requestors to not cache the value for long periods of time

• Configure DNS-O-Matic• Create an account or sign in• Register the service by entering the host name,

password and domain name to update

Demo - Setup Dynamic DNS 2/2• Configure MAMP

• Click on Dynamic DNS tab. Click on DNS-O-Matic.• Enter DNS-O-Matic credentials.• Select either Activate Dynamic DNS Service to

either Automatic or Permanent.• Save Settings and Restart the Server.

Database Server• Two options MySQL and SQLite. SQLite is kind of

“hidden” since there is no database server there is nothing to configure.

• You can configure the port number, the root password, whether not to allow remote access to MySQL and log file location.

• For MySQL, it provides phpMyAdmin, Sequel Pro and MySQL Workbench. Another good option not included is Navicat ($).

• For SQLite, it provides phpLiteAdmin through the WebStart status page. Another good option not included is Navicat ($).

Demo - Create Database

• Fire up phpMyAdmin.

• Create a database. Create a table and add a few records.

• Write a PHP script to retrieve rows of data from the database.

Mail Server

• Use it send emails from your application.

• Using a “Smart Host” it can send emails through a third party provider so the domain name and IP address of the email and the sending computer all match up.

IDE Integration• MAMP uses XDebug to debug PHP scripts.

• Any IDE which can debug using XDebug can debug PHP scripts on MAMP.

• Several popular IDEs are Sublime Text 2, PhpStorm, NetBeans & Eclipse.

• We will demo Sublime Text 2 and IntelliJ Idea (PhpStorm on steroids).

• In Windows, Visual Studio with PHP Tools would be a great option as well. (this is actually a really great tool)

• Sadly, Dreamweaver does not support debugging.

Demo - Debugging in an IDE

• Debugging in Sublime Text 2.

• Show the XDebug Package.

• Set a breakpoint, fire up the debugger.

• Look at variables, watches and the call stack.

• Debugging in IntelliJ Idea.

• Configure MAMP PHP web server in the IDE for debugging.

• Set a breakpoint, fire up the debugger.

• Look at variables, watches and the call stack.

Perl and Python• Default cgi-bin folder: /Application/MAMP/cgi-bin

• For Python:

• Add a Python file with no extension.

• Make sure the Python file is executable.

• Launch in browser with: http://localhost:8888/cgi-bin/hellopython (no extension).

• For Perl:

• Add Perl file with no extension.

• Make sure the Perl file is executable.

• Launch in browser with: http://localhost:8888/perl/helloperl (notice the ‘perl’ path and no extension).

Advanced Configuration

• Editing Config File Templates.

• Backing up and restoring.

• Verify, Repair, Update and Save MySQL Databases.

• Other Preferences.

MAMP for Windows (BETA)

• From their website:What is MAMP for Windows?The abbreviation "MAMP" in MAMP for Windows stands for: My Apache, MySQL and PHP. With just a few mouse clicks, you can install Apache, PHP and MySQL on your PC! MAMP for Windows installs a local server environment in a matter of seconds on your PC, be it a Notebook or Desktop PC. MAMP for Windows comes free of charge and is installed very easily: You can install Apache, PHP and MySQL without starting a script or having to change any configuration files!

Recommended