using mamp for web development

19
Using MAMP for Web Development devLink 2014 Eric 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.

Upload: eric-greene

Post on 20-May-2015

547 views

Category:

Internet


2 download

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.

TRANSCRIPT

Page 1: Using MAMP for Web Development

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.

Page 2: Using MAMP for Web Development

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

Page 3: Using MAMP for Web Development

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/

Page 4: Using MAMP for Web Development

Configuration Overview

• Start/Stop Button

• Help Button

• Save Button

• WebStart Button

Page 5: Using MAMP for Web Development

Status Overview

Once the web server is

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

Page 6: Using MAMP for Web Development

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

Page 7: Using MAMP for Web Development

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

Page 8: Using MAMP for Web Development

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

Page 9: Using MAMP for Web Development

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.

Page 10: Using MAMP for Web Development

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

Page 11: Using MAMP for Web Development

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.

Page 12: Using MAMP for Web Development

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 ($).

Page 13: Using MAMP for Web Development

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.

Page 14: Using MAMP for Web Development

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.

Page 15: Using MAMP for Web Development

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.

Page 16: Using MAMP for Web Development

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.

Page 17: Using MAMP for Web Development

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).

Page 18: Using MAMP for Web Development

Advanced Configuration

• Editing Config File Templates.

• Backing up and restoring.

• Verify, Repair, Update and Save MySQL Databases.

• Other Preferences.

Page 19: Using MAMP for Web Development

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!