Setting up a Development Server
Contents |
Text Editors for Windows/MacOS
When we start programming -- or even when we start coding web pages using HTML -- it will be important to use a good text editor with syntax coloring. Here are a couple of good ones:
- MacOS Text Editor TextWrangler
- Windows Text Editor NotePad++
XAMP: WAMP, MAMP, LAMP
XAMP is an integrated and full function setup for developing dynamic web applications in PhP. It includes a web server (Apache), database server (MySQL), and server-side programming language (PHP).
- WAMP = Windows, Apache, MySQL, PhP
- MAMP = Mac, Apache, MySQL, PhP
- LAMP = Linux, Apache, MySQL, PhP
Installing EasyPHP on Windows
- Follow the installation instructions on pp. 14-18 of the Nixon text.
- Download EasyPHP from http://easyphp.org.
- Run the installer, following the prompts and the default setup.
- Double click the EasyPHP icon in the System Tray to start, stop, and restart Apache, and MySQL.
- Click restart if something goes wrong.
Some possible problems (See page 14-16 of Nixon
- Port blockaqe: If EasyPHP reports that a port is blocked, this usually means that a firewall is preventing access or an antivirus program or Skype is blocking needed ports. EasyPHP needs access to ports 80 (Apache) and 3306 (MySQL).
- The Fix: Investigate the setup for those programs and make sure they aren't using port 80 (for Apache) or port 3306 (for MySQL).
- File permissions: For Windows Vista there may be a permissions problem.
- The Fix: Right click the EasyPHP folder and select Properties. Select the Securities tab and Edit mode and maker sure all users have write access to this folder
Testing Your Installation
- To test that your installation worked properly, enter either of the following URLs into your browser to bring up the EasyPHP home page:
Setting up a Web Folder
- Create a folder named c:\web.
- Click 'Add' under the Apache section of the EasyPHP home page and fill in the form using 'web' as the Alias and 'c:\web' as the path to your directory.
- Click OK to accept the default settings.
- You can create other aliases. For example if you have a cpsc110 directory with path c:\web\cpsc110, you can create an alias 'cpsc110' that will map directly to that directory.
Running Hello World
- Using Notepad or some other text editor, save the following text in a file named 'c:\web\index.html'.
<html><head><title>A quick test</title></head> <body>A quick test</body></html>
- You can call up this page in your browser with: http://localhost/web.
Installing MAMP on Macintosh
- NOTE: This assumes you have Mac OS 10.4 or greater
- Download MAMP (currently 1.8.2) from http://mamp.info/en/download.html
- You can also download from sourceforge: http://sourceforge.net/project/showfiles.php?group_id=121134.
- Unzip the zip file to create a disk image and double click on the disk image.
- Double click the virtual drive MAMP_1.8.2.dmg, which will start the installer.
- Install MAMP into your Applications folder.
- Open the MAMP folder in your Applications folder. The htdocs folder is where you will store your web documents.
- Double click on the MAMP app to start/stop Apache and MySQL servers.
Testing the installation
- Using TextEdit or some other text editor, save the following text in a file named 'index.html' in your MAMP/htdocs folder.
<html><head><title>A quick test</title></head> <body>A quick test</body></html>
- You can call up this page in your browser with: http://localhost:8888.
Other Points
- By default MAMP uses ports 8888 and 8889 for Apache and MySQL respectively. To avoid having to type the port number each time you access a page, use the 'Preferences' button in the MAMP control panel and click on 'Set to default Apache and MySQL ports'. This will set your default ports to 80 and 3306 respectively.
- Test that you can index your page with either http://localhost or http://127.0.0.1.
Credits
- These useful instructions are based on Chapter 2 of Robin Nixon's <a href="http://lpmj.net">Learning PhP, MySQL, and Javascript</a>, O'Reilly, 2009.
- There are other XAMP setups. See for example XAMPP (http://apachefriends.org/en/xampp.html for Windows and Mac or WAMPServer (http://wampserver.com/en/ for Windows.