WAMP

From HaFrWiki
Jump to: navigation, search

WAMP server [1] is Windows Apache MySQL PHP Server all bundled into one nice package. This package is great to test your projects, you don't need to upload every time you need to test a change. You can test everything from you own Windows machine.

There are more platform specific implementations:

  • LAMP, Linux Apache MySQL and PHP
  • MAMP, Mac Apache MySQL and PHP

Intranet Access

If you running WAMP and want to connect to a local installed WAMP server, you may need to alter/configure:

  • Apache HTTP Server Configuration
  • OS Hosts settings
  • Router settings

Java & Tomcat

To get Java code to run locally in conjunction with MAMP follow these steps: [2]

  1. Download the latest tomcat binary from here.
  2. Extract and place in your MAMP folder (usually in your application folder).
    You should now have a /Applications/MAMP/apache-tomcat-version folder.
  3. Rename the tomcat folder (apache-tomcat-X.X.XX) to tomcat (this is just to ease upgrades I think).
  4. Add /Applications/MAMP/tomcat/bin/startup.sh to the end of the file /Applications/MAMP/bin/startApache.sh
  5. Add /Applications/MAMP/tomcat/bin/shutdown.sh to the end of the file /Applications/MAMP/bin/stopApache.sh
  6. Finally, change the permissions on the following files:
chmod +x startup.sh 
chmod +x shutdown.sh 
chmod +x catalina.sh 
chmod +x setclasspath.sh 
chmod +x bootstrap.jar 
chmod +x tomcat-juli.jar

The lines in step 4 and 5 could be added to the overall ‘start.sh’ and ‘stop.sh’ but as it requires(?) Apache it doesn’t make sense to have tomcat as a self-contained entity.
Fire up a browser and head to localhost:8080 to see if all that worked.

Shell Scripts

To enable the execution of scripts like ksh you need to activate CGI in MAMP. This section shows how. The default setup only allows CGI scripts to execute out of the default: ‘Applications/MAMP/cgi-bin’ directory.

  • Open ‘Applications/MAMP/conf/apache/httpd.conf’ in a text editor of your choice.
  • Search the Document for – ‘AddHandler cgi-script .cgi’
    That line should be commented out, remove the ‘#’ to uncomment this and add ‘.pl’ to the line (PL files are a common file type used in cgi scripts, so that is why we are adding ‘.pl’ to the line)
    Your line should now look like this: ‘AddHandler cgi-script .cgi .pl’
  • Now search the document for this segment of code:
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
  • Modify the code to look like this:
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Options FollowSymLinks +ExecCGI
</Directory>
  • Open MAMP Application, and restart the server
  • Finished! CGI scripts should now work anywhere you place them.

Execute Scripts

The scripts does not run without customization:

  • You need to store program in cgi-bin directory.
    • Debian Linux default location for cgi-bin directory: /usr/lib/cgi-bin.
    • Red Hat / Fedora it is /var/www/cgi-bin.
    • MAMP: /Application: /Applications/MAMP/cgi-bin

Now take this example Bash-cgi-test program:

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<h1>Hello world</h1>"
echo "Today is $(date)"
echo "</body></html>"

Save and close the file. Setup execute permission on the script:

$ chmod +x first.cgi


See also

top

  • Wireless, Information and Hosts settings for Windows Apache MySQL PHP Server. Contains the HaFr-Wiki site.
    The Hosts file are important to connect to Harm-Subversion and HaFr-Wiki.
  • Pear, Installation of Pear on Mac, which is needed for running phpunit.
  • MAMP Pro, Implementation on Apple

Reference

top

  1. WAMP-Server is a SourceForge Project.
  2. Java with MAMP, Article in Computing on 26 Nov 2012 by Tristan