Hungry Shark World mod
XAMPP, PHP, MySql
Setting up the XAMPP PHP/MySql Environment on a Macintosh
We will install the XAMPP bundled PHP/MySql system. Installing the XAMPP (or similar) bundle is much easier than installing all the components separately.Pre-Requisite: TextWrangler
Please download and install TextWrangler from this site.http://www.barebones.com/products/TextWrangler/download.html
Installing XAMPP
There is a screen cast of this process below on YouTube. You can watch the screen cast and follow along to complete the tasks. There are notes below the YouTube video as well. You may want to print this page to have the notes as you follow the steps in the video. You may find that watching this on YouTube does not work so well because you may have a slow network connection, or you need to stop and start the video too often as you watch it. Also the text is difficult to read on the YouTube version. Below the video is a link to download the entire high-quality video to your desktop so you can play it locally with QuickTime.(Right-Click or Control-Click and Save this file)
Installation Notes
Download the installation package from:http://www.apachefriends.org/en/xampp.htmlIt will mount as a drive and you will need to drag the "XAMPP" folder into your "Applications" folder. Make sure you are doing this on an administrator account.
If you are already running the built-in copy of the Apache web Server, you will have to turn it off before XAMPP will start. If the Apple-provided Web Sharing is running, XAMPP will warn you of this before it starts. To turn Web Sharing on or off Navigate to:
Apple Menu -> System Preferences -> SharingYou may have to press the little "Unlock" button and then uncheck the "Web Sharing" tick box and press the lock button to re-lock the preferences. This turns off the built-in web server so that XAMPP can connect to port 80. You can flip this off and on as often as you like. You can switch back and forth between Apples web server and XAMPP as long as only one is running at any given time.
Once you get two little green indicators (Apache and MySql) in the XAMPP control panel, open a web browser and point it to:
http://localhost/It should initially start with an XAMPP splash screen so you can select your language and then proceed to the XAMPP main screen with an orange navigation bar along the right side.
Your First PHP Program
Before you can create your first PHP program we need to change the permissions on one of the folders to allow you to make changes to the folder. Navigate to:/Applications/XAMPP/htdocsAnd then in the Finder, choose File -> Get Info. Scroll to the very bottom of the information dialog and find Sharing & Permissions. Press the little "Lock" so you can make changes and then change the permission for "admin" to "Read & Write" and press the Lock icon again to re-lock the dialog.
Normally, we are not supposed to modify files in the /Applications area, but we will be modifying files in this particular directory so we will have to give ourselves permission to edit this folder.
Now that we have given ourselves permission to modify the web documents for our XAMPP server, lets get back to building our first program.
Open a text editor (i.e. TextWrangler) and put the following text in the file putting your own name in instead of mine:
<h1>Hello from Dr. Chucks HTML Page</h1>We will start simple and since PHP is simply an extension of HTML, our first program is just an HTML file. Save this file as:
/Applications/XAMPP/htdocs/si572/index.phpCreate the folder si572 under the htdocs folder when you save the file. If you get a permissions error while creating the folder or saving the file it likely means that you either are not running as the administrator or you neglected to change the permissions on the htdocs folder above. Once you have saved this file, navigate your browser to:
http://localhost/si572/index.phpAnd you should see your web page in your browser.
<h1>Hello from Dr. Chucks HTML Page</h1>After you save, press "Refresh" in your browser and it should appear as follows:
<p>
<?php
echo "Hi there. ";
$answer = 6 * 7;
echo "The answer is $answer, what was the question again? ";
?>
</p>
<p>Yes another paragraph.</p>
Displaying Syntax Errors
XAMPP usually comes configured by default not to display errors when you make a mistake in your PHP code. This is an appropriate setting for production servers but very inconvienent when developing PHP code.The solution is to find and edit the php.ini file that controls the XAMPP configuration, search for the setting display_errorsand set the value to On and then restart your Apache server.
On XAMPP the php.ini file is located by default here:
/Applications/XAMPP/xamppfiles/etc/php.iniYou can always find where php.ini is by looking at your PHPInfo screen. You should find and change the setting to be:
display_errors = OnThere is a screen cast of this process below on YouTube. The quality of the YouTube version is not too good so you may want to Also the text is difficult to read on the YouTube version. download the entire high-quality video to your desktop so you can play it locally with QuickTime using the link below.
Comments
Post a Comment