<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andrew</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andrew"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Andrew"/>
	<updated>2026-11-15T18:17:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2654</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2654"/>
		<updated>2019-04-11T01:29:33Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your HTML document.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' https://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS, so long as that JavaScript library does not defeat the purpose of the assignment. If you have questions about this, ask. In particular, libraries like FullCalendar are unacceptable.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but you are free to explore other databases if you like.&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors or warnings through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points in total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
If you do not include a link to your individual and group portion running on your instance in the respective README.md, you will receive a 0 for the missing portion&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (7 points)&lt;br /&gt;
#** Refreshing the page does not log a user out (3 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and hashed (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
#*  '''Make sure to save a description of your creative portion, and a link to your server in your README.md file.'''&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2652</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2652"/>
		<updated>2019-04-01T14:33:18Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Creating Your Rubric */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
The goal of the creative project is for you to learn a new framework or language that you may be interested in. This is a good opportunity to get a head start on learning the frameworks/languages your employer/potential employer uses.&lt;br /&gt;
&lt;br /&gt;
You’re free to choose which frameworks/languages you’ll use, and you’ll earn more points for learning more or harder frameworks, but '''you’re required to learn at least one new framework/technology.'''&lt;br /&gt;
&lt;br /&gt;
'''As an example''':&lt;br /&gt;
&lt;br /&gt;
You cannot use the combination of Plain HTML/JavaScript (frontend), PHP (backend), and MySQL (Database) because we've covered those extensively in class.&lt;br /&gt;
&lt;br /&gt;
You could, however, use React.JS (frontend), PHP, and MySQL, because your React front end would be new.&lt;br /&gt;
&lt;br /&gt;
== Creating Your Rubric ==&lt;br /&gt;
&lt;br /&gt;
Before creating a rubric, you should come up with an idea for a site you want to build. From there, check [[here]] for guidance on which frameworks/languages to learn for your project and for links on how to get started with each.&lt;br /&gt;
&lt;br /&gt;
As a general structure, your project will consist of:&lt;br /&gt;
*Front-end&lt;br /&gt;
*Back-end&lt;br /&gt;
*Database&lt;br /&gt;
*Styling&lt;br /&gt;
*Best practices&lt;br /&gt;
(Though note that using all may not be necessary for your project! Reallocate as you need)&lt;br /&gt;
&lt;br /&gt;
==== General Rubric Guidelines ====&lt;br /&gt;
Your rubric will add up to '''100 points''' (including the 5 points earned for submitting your rubric on time). For each component of your stack, you can allocate the following numbers of points:&lt;br /&gt;
*5 points for creating a rubric and uploading it to bitbucket on time (yes, we will be checking your commit timestamps!)&lt;br /&gt;
*[10 - 40] points: Learning and implementing new framework(s).&lt;br /&gt;
*Functionality&lt;br /&gt;
**Think about what's happening in your front end, backend, and database that creates functionality. See example rubric.&lt;br /&gt;
*5 points: Best Practices&lt;br /&gt;
**Code well formatted&lt;br /&gt;
**HTML output passes the validator&lt;br /&gt;
*[0 - 20] points: Creative Portion&lt;br /&gt;
*[0 - 5] points: Styling. &amp;quot;Looks really cool&amp;quot; or &amp;quot;Used Bootstrap&amp;quot; would '''not''' earn any points. Learning and implementing SCSS/SASS, animations, or making your page responsive/mobile-friendly would.&lt;br /&gt;
&lt;br /&gt;
''Note that exceptions can be made to these guidelines, but make sure to get approval from a TA.''&lt;br /&gt;
&lt;br /&gt;
===== Points you can allocate for frameworks =====&lt;br /&gt;
Because some stacks have a higher learning curve, more points will be earned for using them. Use the following as a guide:&lt;br /&gt;
*React, Vue, Angular, and other frontend frameworks : 10&lt;br /&gt;
*Express (Node.js framework), Laravel, Bottle, Flask, other back-end micro frameworks: 10&lt;br /&gt;
*Full stack frameworks like Django (python): 20&lt;br /&gt;
*Learning a new database system:&lt;br /&gt;
**Mongo DB: 10&lt;br /&gt;
**Firebase: 5 (lower learning curve)&lt;br /&gt;
**Other SQL Databases (Postgres, MariaDB): 5&lt;br /&gt;
&lt;br /&gt;
== Example Rubric ==&lt;br /&gt;
Say your project idea is to re-create Bitly (the URL shortener), where shortened URLs expire after 1 week, but users can purchase the shortened URL (using stripe) for it to work forever. You decide you want to use Vue for your frontend, Laravel for your backend, and a MySQL database.&lt;br /&gt;
Your rubric could look like the following:&lt;br /&gt;
======Rubric turned in on time (5 points)======&lt;br /&gt;
======Languages/Frameworks used (20 points)======&lt;br /&gt;
*10 - Learned/Used Vue.js frontend&lt;br /&gt;
*10 - Learned/Used PHP Laravel backend&lt;br /&gt;
*0 - MySQL Database&lt;br /&gt;
======Functionality (60 points)======&lt;br /&gt;
*5 Users can input a url and receive a shortened url that redirects to it.&lt;br /&gt;
*10 Url redirect lasts 1 week before the shortened link doesn't work&lt;br /&gt;
*10 Users can register, login, and logout&lt;br /&gt;
*10 Logged in users can edit and delete their shortened URLs&lt;br /&gt;
*15 Logged in users can purchase a shortened URL via Stripe integration&lt;br /&gt;
*10 Database contains Users, Links, and Purchases with the necessary columns and column types to maintain the above functionality&lt;br /&gt;
======Best Practices (5 points)======&lt;br /&gt;
*3 Code is readable and well formatted&lt;br /&gt;
*2 All pages pass the html validator&lt;br /&gt;
======Creative Portion (10 points)======&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
Your project will be graded '''in person''' during the last week of classes, using the rubric you create.&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2650</id>
		<title>Web Frameworks</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2650"/>
		<updated>2019-03-26T06:07:23Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''The following recommendations were last updated Fall 2019''&lt;br /&gt;
&lt;br /&gt;
So far in this class, you have been using PHP, HTML, and now JS to run your web site.  You may have found that PHP can become burdensome for larger applications and difficult to use in collaboration.&lt;br /&gt;
&lt;br /&gt;
Web Frameworks are an alternative method for writing web applications.  Frameworks exist to make writing code more maintainable, scalable, as well as to introduce base functionality for the application you make.&lt;br /&gt;
&lt;br /&gt;
There are ''hundreds'' of frameworks available.  We've categorized and listed some of the more popular below to help you decide what's right for your application.&lt;br /&gt;
&lt;br /&gt;
== Common Features of Frameworks ==&lt;br /&gt;
&lt;br /&gt;
=== Routing ===&lt;br /&gt;
&lt;br /&gt;
A '''key difference''' between PHP and web frameworks is in how routing occurs.&lt;br /&gt;
&lt;br /&gt;
In PHP, if you went to an address like http://www.example.com/welcome.php then Apache would run the script located at, for example, ''/var/www/html/welcome.php''.&lt;br /&gt;
&lt;br /&gt;
With routers, however, you can set arbitrary URLs to run different controller files.&lt;br /&gt;
&lt;br /&gt;
=== Less Code ===&lt;br /&gt;
&lt;br /&gt;
Frameworks are designed to separate your application logic from your HTML and CSS.  In fact, most web frameworks automatically generate all of the HTML and CSS that you need.  So, you could write a fully functional (albeit bland-looking) web site in a Web Framework without writing a singly line of HTML or CSS!&lt;br /&gt;
&lt;br /&gt;
=== MVC Architecture ===&lt;br /&gt;
&lt;br /&gt;
In PHP, your code probably ended up jumbled together in various disorganized places.  This is part of the reason why many Web Frameworks choose to use a Model-View-Controller architecture.&lt;br /&gt;
&lt;br /&gt;
You learned about the Model-View-Controller architecture in CSE 132.  If you need a review, [[wikipedia:Model–view–controller|read the article on Wikipedia]].&lt;br /&gt;
&lt;br /&gt;
A directory structure for an MVC framework might look like the following:&lt;br /&gt;
&lt;br /&gt;
* '''app''' (holds MVC components)&lt;br /&gt;
** '''models''' (contains models)&lt;br /&gt;
** '''controllers''' (contains controllers)&lt;br /&gt;
** '''views''' (contains views)&lt;br /&gt;
* '''config''' (holds global server configurations)&lt;br /&gt;
* '''lib''' (other assorted libraries)&lt;br /&gt;
&lt;br /&gt;
With an MVC architecture, a request to the server typically follows the following path:&lt;br /&gt;
&lt;br /&gt;
# The server routes the request to a certain controller.&lt;br /&gt;
# The controller interprets the request, loading requested information from the models.&lt;br /&gt;
# The controller passes the information from the models to a view.&lt;br /&gt;
# The final view is sent to the user.&lt;br /&gt;
&lt;br /&gt;
== So what do I do? ==&lt;br /&gt;
&lt;br /&gt;
=== Front-end Frameworks ===&lt;br /&gt;
=====React=====&lt;br /&gt;
Get started [https://reactjs.org/docs/getting-started.html Here]&lt;br /&gt;
&lt;br /&gt;
We recommend cloning as a starting point [https://github.com/facebook/create-react-app/ Create React App]&lt;br /&gt;
&lt;br /&gt;
React is the most popular front end framework. React uses JS to create HTML (JSX), as opposed to updating HTML with JS. This makes manipulating the DOM more efficient and smoother.&lt;br /&gt;
&lt;br /&gt;
=====Vue=====&lt;br /&gt;
Get started [https://vuejs.org/v2/guide/ Here]&lt;br /&gt;
&lt;br /&gt;
Really good happy medium between React and Angular. Not fully contained, but separates/organizes your code very nicely. Don't have to use JSX or Angular specific methods. Code structure is better organized than React, but not as opinionated as in Angular.&lt;br /&gt;
&lt;br /&gt;
Vue is partnered with PHP Laravel so a lot of the integrations are very code-friendly.&lt;br /&gt;
&lt;br /&gt;
=====Angular=====&lt;br /&gt;
Get started [https://angular.io/guide/quickstart Here]&lt;br /&gt;
&lt;br /&gt;
Not to be confused with Angular.js (the old version), Angular is the Google developed front-end framework that competes with React and Vue. Angular has it's own more opinionated code practices, making it easy for developers to understand but a higher initial learning curve. &lt;br /&gt;
&lt;br /&gt;
=== Back-end Frameworks ===&lt;br /&gt;
=====Express (NodeJS)=====&lt;br /&gt;
Get started [https://expressjs.com/en/starter/generator.html Here]&lt;br /&gt;
&lt;br /&gt;
If you're planning on using a NodeJS backend, Express is a great option. Other options include [https://hapijs.com/ Hapi.js] or [https://koajs.com/ KOA] if you're already familiar with Express and want to try something else.&lt;br /&gt;
&lt;br /&gt;
=====Laravel (PHP)=====&lt;br /&gt;
Get started [https://laravel.com/docs/5.8 Here]&lt;br /&gt;
&lt;br /&gt;
Laravel is certainly the most popular PHP back-end option. If you aren't sure you want to venture over to a Node, Python, or other back-end, I urge you to try Laravel instead of vanilla PHP. Super clean, super simple, genuinely makes writing PHP enjoyable. As mentioned above, it's coupled extremely well with Vue.js, I would recommend searching for tutorials of the two together if that's the approach you'd like to take.&lt;br /&gt;
&lt;br /&gt;
=====Django (Python)=====&lt;br /&gt;
Get started [https://docs.djangoproject.com/en/2.1/ Here]&lt;br /&gt;
&lt;br /&gt;
Django's tagline is &amp;quot;The Web framework for perfectionists with deadlines&amp;quot;. Take that as you will.&lt;br /&gt;
&lt;br /&gt;
Django is a fairly opinionated full-stack framework, meaning both your front-end and back-end will be written and handled by Django (as opposed to, say Express, which can integrate with whatever sort of front-end you'd like). This doesn't mean it's more difficult to learn, but it does kind of force you to learn how Django does its front-end and back-end which is why it counts for both in terms of points. &lt;br /&gt;
&lt;br /&gt;
=====Flask (Python)=====&lt;br /&gt;
Get started [http://flask.pocoo.org/ Here]&lt;br /&gt;
&lt;br /&gt;
Flask is a micro back-end framework and is extremely easy to setup. Unlike Django, Flask won't handle your Front-end for you. This leaves you the option to use any of the recommended front-end frameworks or to just use regular HTML/JS. &lt;br /&gt;
&lt;br /&gt;
=====Bottle (Python)=====&lt;br /&gt;
Get started [https://bottlepy.org/docs/dev/ Here]&lt;br /&gt;
&lt;br /&gt;
Same gist as Flask, just an alternative.&lt;br /&gt;
&lt;br /&gt;
=== Other and Database Info ===&lt;br /&gt;
=====MongoDB=====&lt;br /&gt;
Get started [https://docs.mongodb.com/manual/ Here]&lt;br /&gt;
&lt;br /&gt;
MongoDB is a very popular no-sql based database. It may seem like a hassle to learn another type of database querying, but as soon as you realize you don't have to mess with foreign keys and it's all essentially javascript objects, it becomes a pretty attractive option. They also have free cloud databases now which is awesome because you don't have to worry about hosting a database on your computer, but much of the security is handled on their end.&lt;br /&gt;
&lt;br /&gt;
=====Firebase=====&lt;br /&gt;
Get started [https://firebase.google.com/ Here]&lt;br /&gt;
&lt;br /&gt;
Firebase is another cloud-based no-sql option. Firebase provides everything from the database itself to real-time crash reporting and analytics. Very easy to integrate into your app and get started with.&lt;br /&gt;
&lt;br /&gt;
=====Other SQL=====&lt;br /&gt;
[https://www.postgresql.org/ PostgreSQL]&lt;br /&gt;
&lt;br /&gt;
[https://mariadb.org/ MariaDB]&lt;br /&gt;
&lt;br /&gt;
=== Structuring Your Project ===&lt;br /&gt;
Once you've outlined your project and have chosen what languages and frameworks you'd like to use, knowing where to start can be a bit daunting. We recommend a straightforward file structure similar to the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
client/&lt;br /&gt;
server/&lt;br /&gt;
config/&lt;br /&gt;
entrypoint&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on what frameworks you're using, it's easy to just place your full front-end framework in the client folder, all of your back-end files in the server folder, and all of your database and other configurations in the config folder. Your entrypoint is just a file containing the command(s) to start everything. Whether this is a package.json file, or a python file that starts your django server, it's nice to keep it in the root of your project.&lt;br /&gt;
&lt;br /&gt;
Have fun!&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2649</id>
		<title>Web Frameworks</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2649"/>
		<updated>2019-03-26T06:02:47Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;So far in this class, you have been using PHP, HTML, and now JS to run your web site.  You may have found that PHP can become burdensome for larger applications and difficult to use in collaboration.&lt;br /&gt;
&lt;br /&gt;
Web Frameworks are an alternative method for writing web applications.  Frameworks exist to make writing code more maintainable, scalable, as well as to introduce base functionality for the application you make.&lt;br /&gt;
&lt;br /&gt;
There are ''hundreds'' of frameworks available.  We've categorized and listed some of the more popular below to help you decide what's right for your application.&lt;br /&gt;
&lt;br /&gt;
== Common Features of Frameworks ==&lt;br /&gt;
&lt;br /&gt;
=== Routing ===&lt;br /&gt;
&lt;br /&gt;
A '''key difference''' between PHP and web frameworks is in how routing occurs.&lt;br /&gt;
&lt;br /&gt;
In PHP, if you went to an address like http://www.example.com/welcome.php then Apache would run the script located at, for example, ''/var/www/html/welcome.php''.&lt;br /&gt;
&lt;br /&gt;
With routers, however, you can set arbitrary URLs to run different controller files.&lt;br /&gt;
&lt;br /&gt;
=== Less Code ===&lt;br /&gt;
&lt;br /&gt;
Frameworks are designed to separate your application logic from your HTML and CSS.  In fact, most web frameworks automatically generate all of the HTML and CSS that you need.  So, you could write a fully functional (albeit bland-looking) web site in a Web Framework without writing a singly line of HTML or CSS!&lt;br /&gt;
&lt;br /&gt;
=== MVC Architecture ===&lt;br /&gt;
&lt;br /&gt;
In PHP, your code probably ended up jumbled together in various disorganized places.  This is part of the reason why many Web Frameworks choose to use a Model-View-Controller architecture.&lt;br /&gt;
&lt;br /&gt;
You learned about the Model-View-Controller architecture in CSE 132.  If you need a review, [[wikipedia:Model–view–controller|read the article on Wikipedia]].&lt;br /&gt;
&lt;br /&gt;
A directory structure for an MVC framework might look like the following:&lt;br /&gt;
&lt;br /&gt;
* '''app''' (holds MVC components)&lt;br /&gt;
** '''models''' (contains models)&lt;br /&gt;
** '''controllers''' (contains controllers)&lt;br /&gt;
** '''views''' (contains views)&lt;br /&gt;
* '''config''' (holds global server configurations)&lt;br /&gt;
* '''lib''' (other assorted libraries)&lt;br /&gt;
&lt;br /&gt;
With an MVC architecture, a request to the server typically follows the following path:&lt;br /&gt;
&lt;br /&gt;
# The server routes the request to a certain controller.&lt;br /&gt;
# The controller interprets the request, loading requested information from the models.&lt;br /&gt;
# The controller passes the information from the models to a view.&lt;br /&gt;
# The final view is sent to the user.&lt;br /&gt;
&lt;br /&gt;
== So what do I do? ==&lt;br /&gt;
&lt;br /&gt;
=== Front-end Frameworks ===&lt;br /&gt;
=====React=====&lt;br /&gt;
Get started [https://reactjs.org/docs/getting-started.html Here]&lt;br /&gt;
&lt;br /&gt;
We recommend cloning as a starting point [https://github.com/facebook/create-react-app/ Create React App]&lt;br /&gt;
&lt;br /&gt;
React is the most popular front end framework. React uses JS to create HTML (JSX), as opposed to updating HTML with JS. This makes manipulating the DOM more efficient and smoother.&lt;br /&gt;
&lt;br /&gt;
=====Vue=====&lt;br /&gt;
Get started [https://vuejs.org/v2/guide/ Here]&lt;br /&gt;
&lt;br /&gt;
Really good happy medium between React and Angular. Not fully contained, but separates/organizes your code very nicely. Don't have to use JSX or Angular specific methods. Code structure is better organized than React, but not as opinionated as in Angular.&lt;br /&gt;
&lt;br /&gt;
Vue is partnered with PHP Laravel so a lot of the integrations are very code-friendly.&lt;br /&gt;
&lt;br /&gt;
=====Angular=====&lt;br /&gt;
Get started [https://angular.io/guide/quickstart Here]&lt;br /&gt;
&lt;br /&gt;
Not to be confused with Angular.js (the old version), Angular is the Google developed front-end framework that competes with React and Vue. Angular has it's own more opinionated code practices, making it easy for developers to understand but a higher initial learning curve. &lt;br /&gt;
&lt;br /&gt;
=== Back-end Frameworks ===&lt;br /&gt;
=====Express (NodeJS)=====&lt;br /&gt;
Get started [https://expressjs.com/en/starter/generator.html Here]&lt;br /&gt;
&lt;br /&gt;
If you're planning on using a NodeJS backend, Express is a great option. Other options include [https://hapijs.com/ Hapi.js] or [https://koajs.com/ KOA] if you're already familiar with Express and want to try something else.&lt;br /&gt;
&lt;br /&gt;
=====Laravel (PHP)=====&lt;br /&gt;
Get started [https://laravel.com/docs/5.8 Here]&lt;br /&gt;
&lt;br /&gt;
Laravel is certainly the most popular PHP back-end option. If you aren't sure you want to venture over to a Node, Python, or other back-end, I urge you to try Laravel instead of vanilla PHP. Super clean, super simple, genuinely makes writing PHP enjoyable. As mentioned above, it's coupled extremely well with Vue.js, I would recommend searching for tutorials of the two together if that's the approach you'd like to take.&lt;br /&gt;
&lt;br /&gt;
=====Django (Python)=====&lt;br /&gt;
Get started [https://docs.djangoproject.com/en/2.1/ Here]&lt;br /&gt;
&lt;br /&gt;
Django's tagline is &amp;quot;The Web framework for perfectionists with deadlines&amp;quot;. Take that as you will.&lt;br /&gt;
&lt;br /&gt;
Django is a fairly opinionated full-stack framework, meaning both your front-end and back-end will be written and handled by Django (as opposed to, say Express, which can integrate with whatever sort of front-end you'd like). This doesn't mean it's more difficult to learn, but it does kind of force you to learn how Django does its front-end and back-end which is why it counts for both in terms of points. &lt;br /&gt;
&lt;br /&gt;
=====Flask (Python)=====&lt;br /&gt;
Get started [http://flask.pocoo.org/ Here]&lt;br /&gt;
&lt;br /&gt;
Flask is a micro back-end framework and is extremely easy to setup. Unlike Django, Flask won't handle your Front-end for you. This leaves you the option to use any of the recommended front-end frameworks or to just use regular HTML/JS. &lt;br /&gt;
&lt;br /&gt;
=====Bottle (Python)=====&lt;br /&gt;
Get started [https://bottlepy.org/docs/dev/ Here]&lt;br /&gt;
&lt;br /&gt;
Same gist as Flask, just an alternative.&lt;br /&gt;
&lt;br /&gt;
=== Other and Database Info ===&lt;br /&gt;
=====MongoDB=====&lt;br /&gt;
Get started [https://docs.mongodb.com/manual/ Here]&lt;br /&gt;
&lt;br /&gt;
MongoDB is a very popular no-sql based database. It may seem like a hassle to learn another type of database querying, but as soon as you realize you don't have to mess with foreign keys and it's all essentially javascript objects, it becomes a pretty attractive option. They also have free cloud databases now which is awesome because you don't have to worry about hosting a database on your computer, but much of the security is handled on their end.&lt;br /&gt;
&lt;br /&gt;
=====Firebase=====&lt;br /&gt;
Get started [https://firebase.google.com/ Here]&lt;br /&gt;
&lt;br /&gt;
Firebase is another cloud-based no-sql option. Firebase provides everything from the database itself to real-time crash reporting and analytics. Very easy to integrate into your app and get started with.&lt;br /&gt;
&lt;br /&gt;
=====Other SQL=====&lt;br /&gt;
[https://www.postgresql.org/ PostgreSQL]&lt;br /&gt;
&lt;br /&gt;
[https://mariadb.org/ MariaDB]&lt;br /&gt;
&lt;br /&gt;
=== Structuring Your Project ===&lt;br /&gt;
Once you've outlined your project and have chosen what languages and frameworks you'd like to use, knowing where to start can be a bit daunting. We recommend a straightforward file structure similar to the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
client/&lt;br /&gt;
server/&lt;br /&gt;
config/&lt;br /&gt;
entrypoint&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on what frameworks you're using, it's easy to just place your full front-end framework in the client folder, all of your back-end files in the server folder, and all of your database and other configurations in the config folder. Your entrypoint is just a file containing the command(s) to start everything. Whether this is a package.json file, or a python file that starts your django server, it's nice to keep it in the root of your project.&lt;br /&gt;
&lt;br /&gt;
Have fun!&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2648</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2648"/>
		<updated>2019-03-25T20:55:44Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
The goal of the creative project is for you to learn a new framework or language that you may be interested in. This is a good opportunity to get a head start on learning the frameworks/languages your employer/potential employer uses.&lt;br /&gt;
&lt;br /&gt;
You’re free to choose which frameworks/languages you’ll use, and you’ll earn more points for learning more or harder frameworks, but '''you’re required to learn at least one new framework/technology.'''&lt;br /&gt;
&lt;br /&gt;
'''As an example''':&lt;br /&gt;
&lt;br /&gt;
You cannot use the combination of Plain HTML/JavaScript (frontend), PHP (backend), and MySQL (Database) because we've covered those extensively in class.&lt;br /&gt;
&lt;br /&gt;
You could, however, use React.JS (frontend), PHP, and MySQL, because your React front end would be new.&lt;br /&gt;
&lt;br /&gt;
== Creating Your Rubric ==&lt;br /&gt;
&lt;br /&gt;
Before creating a rubric, you should come up with an idea for a site you want to build. From there, check [[here]] for guidance on which frameworks/languages to learn for your project and for links on how to get started with each.&lt;br /&gt;
&lt;br /&gt;
As a general structure, your project will consist of:&lt;br /&gt;
*Front end&lt;br /&gt;
*Backend&lt;br /&gt;
*Database&lt;br /&gt;
*Styling&lt;br /&gt;
*Best practices&lt;br /&gt;
(Though note that using all may not be necessary for your project! Reallocate as you need)&lt;br /&gt;
&lt;br /&gt;
==== General Rubric Guidelines ====&lt;br /&gt;
Your rubric will add up to '''100 points''' (including the 5 points earned for submitting your rubric on time). For each component of your stack, you can allocate the following numbers of points:&lt;br /&gt;
*5 points for creating a rubric and uploading it to bitbucket on time (yes, we will be checking your commit timestamps!)&lt;br /&gt;
*[10 - 40] points: Learning and implementing new framework(s).&lt;br /&gt;
*Functionality&lt;br /&gt;
**Think about what's happening in your front end, backend, and database that creates functionality. See example rubric.&lt;br /&gt;
*5 points: Best Practices&lt;br /&gt;
**Code well formatted&lt;br /&gt;
**HTML output passes the validator&lt;br /&gt;
*[0 - 20] points: Creative Portion&lt;br /&gt;
*[0 - 5] points: Styling. &amp;quot;Looks really cool&amp;quot; or &amp;quot;Used Bootstrap&amp;quot; would '''not''' earn any points. Learning and implementing SCSS/SASS, animations, or making your page responsive/mobile-friendly would.&lt;br /&gt;
&lt;br /&gt;
''Note that exceptions can be made to these guidelines, but make sure to get approval from a TA.''&lt;br /&gt;
&lt;br /&gt;
===== Points you can allocate for frameworks =====&lt;br /&gt;
Because some stacks have a higher learning curve, more points will be earned for using them. Use the following as a guide:&lt;br /&gt;
*React, Vue, Angular, and other frontend frameworks : 10&lt;br /&gt;
*Express (Node.js framework), Laravel, Bottle, Flask, other back-end micro frameworks: 10&lt;br /&gt;
*Full stack frameworks like Django (python): 20&lt;br /&gt;
*Learning a new database system:&lt;br /&gt;
**Mongo DB: 10&lt;br /&gt;
**Firebase: 5 (lower learning curve)&lt;br /&gt;
**Other SQL Databases (Postgres, MariaDB): 5&lt;br /&gt;
&lt;br /&gt;
== Example Rubric ==&lt;br /&gt;
Say your project idea is to re-create Bitly (the URL shortener), where shortened URLs expire after 1 week, but users can purchase the shortened URL (using stripe) for it to work forever. You decide you want to use Vue for your frontend, Laravel for your backend, and a MySQL database.&lt;br /&gt;
Your rubric could look like the following:&lt;br /&gt;
======Rubric turned in on time (5 points)======&lt;br /&gt;
======Languages/Frameworks used (20 points)======&lt;br /&gt;
*10 - Learned/Used Vue.js frontend&lt;br /&gt;
*10 - Learned/Used PHP Laravel backend&lt;br /&gt;
*0 - MySQL Database&lt;br /&gt;
======Functionality (60 points)======&lt;br /&gt;
*5 Users can input a url and receive a shortened url that redirects to it.&lt;br /&gt;
*10 Url redirect lasts 1 week before the shortened link doesn't work&lt;br /&gt;
*10 Users can register, login, and logout&lt;br /&gt;
*10 Logged in users can edit and delete their shortened URLs&lt;br /&gt;
*15 Logged in users can purchase a shortened URL via Stripe integration&lt;br /&gt;
*10 Database contains Users, Links, and Purchases with the necessary columns and column types to maintain the above functionality&lt;br /&gt;
======Best Practices (5 points)======&lt;br /&gt;
*3 Code is readable and well formatted&lt;br /&gt;
*2 All pages pass the html validator&lt;br /&gt;
======Creative Portion (10 points)======&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
Your project will be graded '''in person''' during the last week of classes, using the rubric you create.&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2647</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2647"/>
		<updated>2019-03-25T20:49:10Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
= Creative Project =&lt;br /&gt;
The goal of the creative project is for you to learn a new framework or language that you may be interested in. This is a good opportunity to get a head start on learning the frameworks/languages your employer/potential employer uses.&lt;br /&gt;
&lt;br /&gt;
You’re free to choose which frameworks/languages you’ll use, and you’ll earn more points for learning more or harder frameworks, but '''you’re required to learn at least one new framework/technology.'''&lt;br /&gt;
&lt;br /&gt;
'''As an example''':&lt;br /&gt;
&lt;br /&gt;
You cannot use the combination of Plain HTML/JavaScript (frontend), PHP (backend), and MySQL (Database) because we've covered those extensively in class.&lt;br /&gt;
&lt;br /&gt;
You could, however, use React.JS (frontend), PHP, and MySQL, because your React front end would be new.&lt;br /&gt;
&lt;br /&gt;
== Creating Your Rubric ==&lt;br /&gt;
&lt;br /&gt;
Before creating a rubric, you should come up with an idea for a site you want to build. From there, check [[here]] for guidance on which frameworks/languages to learn for your project and for links on how to get started with each.&lt;br /&gt;
&lt;br /&gt;
As a general structure, your project will consist of:&lt;br /&gt;
*Front end&lt;br /&gt;
*Backend&lt;br /&gt;
*Database&lt;br /&gt;
*Styling&lt;br /&gt;
*Best practices&lt;br /&gt;
(Though note that using all may not be necessary for your project! Reallocate as you need)&lt;br /&gt;
&lt;br /&gt;
==== General Rubric Guidelines ====&lt;br /&gt;
Your rubric will add up to '''100 points''' (including the 5 points earned for submitting your rubric on time). For each component of your stack, you can allocate the following numbers of points:&lt;br /&gt;
*5 points for creating a rubric and uploading it to bitbucket on time (yes, we will be checking your commit timestamps!)&lt;br /&gt;
*[10 - 40] points: Learning and implementing new framework(s).&lt;br /&gt;
*Functionality&lt;br /&gt;
**Think about what's happening in your front end, backend, and database that creates functionality. See example rubric.&lt;br /&gt;
*5 points: Best Practices&lt;br /&gt;
**Code well formatted&lt;br /&gt;
**HTML output passes the validator&lt;br /&gt;
*[0 - 20] points: Creative Portion&lt;br /&gt;
*[0 - 5] points: Styling. &amp;quot;Looks really cool&amp;quot; or &amp;quot;Used Bootstrap&amp;quot; would '''not''' earn any points. Learning and implementing SCSS/SASS, animations, or making your page responsive/mobile-friendly would.&lt;br /&gt;
&lt;br /&gt;
''Note that exceptions can be made to these guidelines, but make sure to get approval from a TA.''&lt;br /&gt;
&lt;br /&gt;
===== Points you can allocate for frameworks =====&lt;br /&gt;
Because some stacks have a higher learning curve, more points will be earned for using them. Use the following as a guide:&lt;br /&gt;
*React, Vue, Angular, and other frontend frameworks : 10&lt;br /&gt;
*Express (Node.js framework), Laravel, Bottle, Flask, other back-end micro frameworks: 10&lt;br /&gt;
*Full stack frameworks like Django (python): 20&lt;br /&gt;
*Learning a new database system:&lt;br /&gt;
**Mongo DB: 10&lt;br /&gt;
**Firebase: 5 (lower learning curve)&lt;br /&gt;
**Other SQL Databases (Postgres, MariaDB): 5&lt;br /&gt;
&lt;br /&gt;
== Example Rubric ==&lt;br /&gt;
Say your project idea is to re-create Bitly (the URL shortener), where shortened URLs expire after 1 week, but users can purchase the shortened URL (using stripe) for it to work forever. You decide you want to use Vue for your frontend, Laravel for your backend, and a MySQL database.&lt;br /&gt;
Your rubric could look like the following:&lt;br /&gt;
======Rubric turned in on time (5 points)======&lt;br /&gt;
======Languages/Frameworks used (20 points)======&lt;br /&gt;
*10 - Learned/Used Vue.js frontend&lt;br /&gt;
*10 - Learned/Used PHP Laravel backend&lt;br /&gt;
*0 - MySQL Database&lt;br /&gt;
======Functionality (60 points)======&lt;br /&gt;
*5 Users can input a url and receive a shortened url that redirects to it.&lt;br /&gt;
*10 Url redirect lasts 1 week before the shortened link doesn't work&lt;br /&gt;
*10 Users can register, login, and logout&lt;br /&gt;
*10 Logged in users can edit and delete their shortened URLs&lt;br /&gt;
*15 Logged in users can purchase a shortened URL via Stripe integration&lt;br /&gt;
*10 Database contains Users, Links, and Purchases with the necessary columns and column types to maintain the above functionality&lt;br /&gt;
======Best Practices (5 points)======&lt;br /&gt;
*3 Code is readable and well formatted&lt;br /&gt;
*2 All pages pass the html validator&lt;br /&gt;
======Creative Portion (10 points)======&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
Your project will be graded '''in person''' during the last week of classes, using the rubric you create.&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2646</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2646"/>
		<updated>2019-03-25T20:40:23Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
= Creative Project =&lt;br /&gt;
The goal of the creative project is for you to learn a new framework or language that you may be interested in. This is a good opportunity to get a head start on learning the frameworks/languages your employer/potential employer uses.&lt;br /&gt;
&lt;br /&gt;
You’re free to choose which frameworks/languages you’ll use, and you’ll earn more base points for using more, but '''you’re required to learn at least one new framework/technology.'''&lt;br /&gt;
&lt;br /&gt;
'''As an example''':&lt;br /&gt;
&lt;br /&gt;
You cannot use the combination of Plain HTML/JavaScript (frontend), PHP (backend), and MySQL (Database) because we've covered those extensively in class.&lt;br /&gt;
&lt;br /&gt;
You could, however, use React.JS (frontend), PHP, and MySQL, because your React front end would be new.&lt;br /&gt;
&lt;br /&gt;
== Creating Your Rubric ==&lt;br /&gt;
&lt;br /&gt;
Before creating a rubric, you should come up with an idea for a site you want to build. From there, check [[here]] for guidance on which frameworks/languages to learn for your project and for links on how to get started with each.&lt;br /&gt;
&lt;br /&gt;
As a general structure, your project will consist of:&lt;br /&gt;
*Front end&lt;br /&gt;
*Backend&lt;br /&gt;
*Database&lt;br /&gt;
*Styling&lt;br /&gt;
*Best practices&lt;br /&gt;
(Though note that using all may not be necessary for your project! Reallocate as you need)&lt;br /&gt;
&lt;br /&gt;
==== General Rubric Guidelines ====&lt;br /&gt;
Your rubric will add up to '''100 points''' (including the 5 points earned for submitting your rubric on time). For each component of your stack, you can allocate the following numbers of points:&lt;br /&gt;
*5 points for creating a rubric and uploading it to bitbucket on time (yes, we will be checking your commit timestamps!)&lt;br /&gt;
*[10 - 40] points: Learning and implementing new framework(s).&lt;br /&gt;
*Functionality&lt;br /&gt;
**Think about what's happening in your front end, backend, and database that creates functionality. See example rubric.&lt;br /&gt;
*5 points: Best Practices&lt;br /&gt;
**Code well formatted&lt;br /&gt;
**HTML output passes the validator&lt;br /&gt;
*[0 - 20] points: Creative Portion&lt;br /&gt;
*[0 - 5] points: Styling. &amp;quot;Looks really cool&amp;quot; or &amp;quot;Used Bootstrap&amp;quot; would '''not''' earn any points. Learning and implementing SCSS/SASS, animations, or making your page responsive/mobile-friendly would.&lt;br /&gt;
&lt;br /&gt;
''Note that exceptions can be made to these guidelines, but make sure to get approval from a TA.''&lt;br /&gt;
&lt;br /&gt;
===== Points you can allocate for frameworks =====&lt;br /&gt;
Because some stacks have a higher learning curve, more points will be earned for using them. Use the following as a guide:&lt;br /&gt;
*React, Vue, Angular, and other frontend frameworks : 10&lt;br /&gt;
*Express (Node.js framework), Laravel, Bottle, Flask, other back-end micro frameworks: 10&lt;br /&gt;
*Full stack frameworks like Django (python): 20&lt;br /&gt;
*Learning a new database system:&lt;br /&gt;
**Mongo DB: 10&lt;br /&gt;
**Firebase: 5 (lower learning curve)&lt;br /&gt;
**Other SQL Databases (Postgres, MariaDB): 5&lt;br /&gt;
&lt;br /&gt;
== Example Rubric ==&lt;br /&gt;
Say your project idea is to re-create Bitly (the URL shortener), where shortened URLs expire after 1 week, but users can purchase the shortened URL (using stripe) for it to work forever. You decide you want to use Vue for your frontend, Laravel for your backend, and a MySQL database.&lt;br /&gt;
Your rubric could look like the following:&lt;br /&gt;
======Rubric turned in on time (5 points)======&lt;br /&gt;
======Languages/Frameworks used (20 points)======&lt;br /&gt;
*10 - Learned/Used Vue.js frontend&lt;br /&gt;
*10 - Learned/Used PHP Laravel backend&lt;br /&gt;
*0 - MySQL Database&lt;br /&gt;
======Functionality (60 points)======&lt;br /&gt;
*5 Users can input a url and receive a shortened url that redirects to it.&lt;br /&gt;
*10 Url redirect lasts 1 week before the shortened link doesn't work&lt;br /&gt;
*10 Users can register, login, and logout&lt;br /&gt;
*10 Logged in users can edit and delete their shortened URLs&lt;br /&gt;
*15 Logged in users can purchase a shortened URL via Stripe integration&lt;br /&gt;
*10 Database contains Users, Links, and Purchases with the necessary columns and column types to maintain the above functionality&lt;br /&gt;
======Best Practices (5 points)======&lt;br /&gt;
*3 Code is readable and well formatted&lt;br /&gt;
*2 All pages pass the html validator&lt;br /&gt;
======Creative Portion (10 points)======&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
Your project will be graded '''in person''' during the last week of classes, using the rubric you create.&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2645</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2645"/>
		<updated>2019-03-25T20:32:38Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
= Creative Project =&lt;br /&gt;
The goal of the creative project is for you to learn a new framework or language that you may be interested in. This is a good opportunity to get a head start on learning the frameworks/languages your employer/potential employer uses.&lt;br /&gt;
&lt;br /&gt;
You’re free to choose which frameworks/languages you’ll use, and you’ll earn more base points for using more, but '''you’re required to learn at least one new framework/technology.'''&lt;br /&gt;
&lt;br /&gt;
'''As an example''':&lt;br /&gt;
&lt;br /&gt;
You cannot use the combination of Plain HTML/JavaScript (frontend), PHP (backend), and MySQL (Database) because we've covered those extensively in class.&lt;br /&gt;
&lt;br /&gt;
You could, however, use React.JS (frontend), PHP, and MySQL, because your React front end would be new.&lt;br /&gt;
&lt;br /&gt;
== Creating Your Rubric ==&lt;br /&gt;
&lt;br /&gt;
Before creating a rubric, you should come up with an idea for a site you want to build. From there, check [[here]] for guidance on which frameworks/languages to learn for your project and for links on how to get started with each.&lt;br /&gt;
&lt;br /&gt;
As a general structure, your project will consist of:&lt;br /&gt;
*Front end&lt;br /&gt;
*Backend&lt;br /&gt;
*Database&lt;br /&gt;
*Styling&lt;br /&gt;
*Best practices&lt;br /&gt;
(Though note that using all may not be necessary for your project! Reallocate as you need)&lt;br /&gt;
&lt;br /&gt;
==== General Rubric Guidelines ====&lt;br /&gt;
Your rubric will add up to '''100 points''' (including the 5 points earned for submitting your rubric on time). For each component of your stack, you can allocate the following numbers of points:&lt;br /&gt;
*5 points for creating a rubric and uploading it to bitbucket on time (yes, we will be checking your commit timestamps!)&lt;br /&gt;
*[10 - 40] points: Learning and implementing new framework(s).&lt;br /&gt;
*Functionality&lt;br /&gt;
**Think about what's happening in your front end, backend, and database that creates functionality. See example rubric.&lt;br /&gt;
*5 points: Best Practices&lt;br /&gt;
**Code well formatted&lt;br /&gt;
**HTML output passes the validator&lt;br /&gt;
*[0 - 20] points: Creative Portion&lt;br /&gt;
*[0 - 5] points: Styling. &amp;quot;Looks really cool&amp;quot; or &amp;quot;Used Bootstrap&amp;quot; would '''not''' earn any points. Learning and implementing SCSS/SASS, animations, or making your page responsive/mobile-friendly would.&lt;br /&gt;
&lt;br /&gt;
''Note that exceptions can be made to these guidelines, but make sure to get approval from a TA.''&lt;br /&gt;
&lt;br /&gt;
===== Points you can allocate for frameworks =====&lt;br /&gt;
Because some stacks have a higher learning curve, more points will be earned for using them. Use the following as a guide:&lt;br /&gt;
*React, Vue, Angular, and other frontend frameworks : 10&lt;br /&gt;
*Express (Node.js framework), Laravel, Flask, other back-end micro frameworks: 10&lt;br /&gt;
*Full stack frameworks like Django (python): 20&lt;br /&gt;
*Learning a new database system:&lt;br /&gt;
**Mongo DB: 10&lt;br /&gt;
**Firebase: 5 (lower learning curve)&lt;br /&gt;
**Other SQL Databases (Postgres, MariaDB): 5&lt;br /&gt;
&lt;br /&gt;
== Example Rubric ==&lt;br /&gt;
Say your project idea is to re-create Bitly (the URL shortener), where shortened URLs expire after 1 week, but users can purchase the shortened URL (using stripe) for it to work forever. You decide you want to use Vue for your frontend, Laravel for your backend, and a MySQL database.&lt;br /&gt;
Your rubric could look like the following:&lt;br /&gt;
======Rubric turned in on time (5 points)======&lt;br /&gt;
======Languages/Frameworks used (20 points)======&lt;br /&gt;
*10 - Learned/Used Vue.js frontend&lt;br /&gt;
*10 - Learned/Used PHP Laravel backend&lt;br /&gt;
*0 - MySQL Database&lt;br /&gt;
======Functionality (60 points)======&lt;br /&gt;
*5 Users can input a url and receive a shortened url that redirects to it.&lt;br /&gt;
*10 Url redirect lasts 1 week before the shortened link doesn't work&lt;br /&gt;
*10 Users can register, login, and logout&lt;br /&gt;
*10 Logged in users can edit and delete their shortened URLs&lt;br /&gt;
*15 Logged in users can purchase a shortened URL via Stripe integration&lt;br /&gt;
*10 Database contains Users, Links, and Purchases with the necessary columns and column types to maintain the above functionality&lt;br /&gt;
======Best Practices (5 points)======&lt;br /&gt;
*3 Code is readable and well formatted&lt;br /&gt;
*2 All pages pass the html validator&lt;br /&gt;
======Creative Portion (10 points)======&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
Your project will be graded '''in person''' during the last week of classes, using the rubric you create.&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2632</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2632"/>
		<updated>2019-01-16T17:06:35Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Configure SSH */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To save from typing this command in every time you want to access your server, you can set an '''alias''' in your terminal.&lt;br /&gt;
&lt;br /&gt;
In the '''Mac''' terminal, vim ~/.bash_profile and input the following command:&lt;br /&gt;
 $ alias aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
Now, whenever you type aws in your terminal, it will type your ssh command.&lt;br /&gt;
&lt;br /&gt;
In '''Cygwin''', vim ~/.bash_profile and input the following:&lt;br /&gt;
 export aws=&amp;quot;ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com&amp;quot;&lt;br /&gt;
And you run this command by typing '''$aws'''&lt;br /&gt;
Also note that you may have to restart your terminal for this to take effect, or put the command in your ~/.bashrc file&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Follow the SFTP and Git instructions on the [[VS Code]] page&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2631</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2631"/>
		<updated>2019-01-16T17:06:19Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Configure SSH */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To save from typing this command in every time you want to access your server, you can set an '''alias''' in your terminal.&lt;br /&gt;
&lt;br /&gt;
In the '''Mac''' terminal, vim ~/.bash_profile and input the following command:&lt;br /&gt;
 $ alias aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
Now, whenever you type aws in your terminal, it will type your ssh command.&lt;br /&gt;
&lt;br /&gt;
In '''Cygwin''', vim ~/.bash_profile and input the following:&lt;br /&gt;
 export aws=&amp;quot;ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com&amp;quot;&lt;br /&gt;
And you run this command by typing *$aws*&lt;br /&gt;
Also note that you may have to restart your terminal for this to take effect, or put the command in your ~/.bashrc file&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Follow the SFTP and Git instructions on the [[VS Code]] page&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2630</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2630"/>
		<updated>2019-01-16T17:01:20Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Module 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
* Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
* Navigate to the created repo in Bitbucket&lt;br /&gt;
* Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
* In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
* If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
* You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config.json file should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/public_html/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP https://sourceforge.net/projects/wampserver/&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, run php files, and use phpmyadmin.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions&lt;br /&gt;
 /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2628</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2628"/>
		<updated>2019-01-13T04:00:26Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO. This project must be completed using Node.JS.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 75 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. '''&lt;br /&gt;
&lt;br /&gt;
'''Additionally, for this module, the TA should be able to simply download your repo and start up your file server, without having to copy files or create additional subdirectories.  This applies to both the individual and the creative portion'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (5 points)&lt;br /&gt;
#*: ''Take a screenshot of your browser visiting your EC2 instance serving up the college.html web page on port 3456, make sure the URL is visible in the screenshot.''&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* Discuss in the README.md why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
#* Make sure all of your individual portion files are pushed to Bitbucket (include your node.js file, hello.txt, brookings.jpg, college.html, and phpinfo.php)&lt;br /&gt;
&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (2 points)&lt;br /&gt;
#** node_modules folder is ignored by version control (1 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
#* '''Creative Portion (10 Points)'''&lt;br /&gt;
&amp;lt;!-- #** Make sure to create a README.md file pointing to your server --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2627</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2627"/>
		<updated>2019-01-13T04:00:14Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO. This project must be completed using Node.JS.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 75 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. '''&lt;br /&gt;
&lt;br /&gt;
'''Additionally, the TA should be able to simply download your repo and start up your file server, without having to copy files or create additional subdirectories.  This applies to both the individual and the creative portion'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (5 points)&lt;br /&gt;
#*: ''Take a screenshot of your browser visiting your EC2 instance serving up the college.html web page on port 3456, make sure the URL is visible in the screenshot.''&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* Discuss in the README.md why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
#* Make sure all of your individual portion files are pushed to Bitbucket (include your node.js file, hello.txt, brookings.jpg, college.html, and phpinfo.php)&lt;br /&gt;
&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (2 points)&lt;br /&gt;
#** node_modules folder is ignored by version control (1 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
#* '''Creative Portion (10 Points)'''&lt;br /&gt;
&amp;lt;!-- #** Make sure to create a README.md file pointing to your server --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2626</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2626"/>
		<updated>2019-01-13T03:32:49Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
To add phpMyAdmin to apache's root server, you need to make your user apart of the apache group, and change the owner of the root directory to apache.&lt;br /&gt;
&lt;br /&gt;
To add your user to the apache group:&lt;br /&gt;
 $ sudo usermod -a -G apache YOUR_USERNAME&lt;br /&gt;
'''Note you may have to exit your server and ssh back in for this to take effect'''&lt;br /&gt;
&lt;br /&gt;
Change the owner of the www folders to your user, and the group apache&lt;br /&gt;
 $ sudo chown -R YOUR_USERNAME:apache /var/www&lt;br /&gt;
&lt;br /&gt;
'''Now that you can access the /var/www/html directory''' download phpMyAdmin to apache's root directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ mkdir phpmyadmin &amp;amp;&amp;amp; tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpmyadmin  phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ rm phpMyAdmin-latest-all-languages.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2625</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2625"/>
		<updated>2019-01-13T03:32:28Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
To add phpMyAdmin to apache's root server, you need to make your user apart of the apache group, and change the owner of the root directory to apache.&lt;br /&gt;
&lt;br /&gt;
To add your user to the apache group:&lt;br /&gt;
 $ sudo usermod -a -G apache YOUR_USERNAME&lt;br /&gt;
'''Note you may have to exit your server and ssh back in for this to take effect'''&lt;br /&gt;
&lt;br /&gt;
Navigate to /var&lt;br /&gt;
 $ cd /var&lt;br /&gt;
&lt;br /&gt;
Change the owner of the www folders to your user, and the group apache&lt;br /&gt;
 $ sudo chown -R YOUR_USERNAME:apache /var/www&lt;br /&gt;
&lt;br /&gt;
'''Now that you can access the /var/www/html directory''' download phpMyAdmin to apache's root directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ mkdir phpmyadmin &amp;amp;&amp;amp; tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpmyadmin  phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ rm phpMyAdmin-latest-all-languages.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2624</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2624"/>
		<updated>2019-01-13T03:24:44Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
To add phpMyAdmin to apache's root server, you need to make your user apart of the apache group, and change the owner of the root directory to apache.&lt;br /&gt;
&lt;br /&gt;
To add your user to the apache group:&lt;br /&gt;
 $ sudo usermod -a -G apache USERNAME&lt;br /&gt;
'''Note you may have to exit your server and ssh back in for this to take effect'''&lt;br /&gt;
&lt;br /&gt;
Navigate to /var&lt;br /&gt;
 $ cd /var&lt;br /&gt;
&lt;br /&gt;
Change the owner of the www folders to your user, and the group apache&lt;br /&gt;
 $ sudo chown -R YOUR_USERNAME:apache /var/www&lt;br /&gt;
&lt;br /&gt;
'''Now that you can access the /var/www/html directory''' download phpMyAdmin to apache's root directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ mkdir phpmyadmin &amp;amp;&amp;amp; tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpmyadmin  phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ rm phpMyAdmin-latest-all-languages.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2623</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2623"/>
		<updated>2019-01-13T03:19:45Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Inside your server via SSH, download the file to apache's root directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ mkdir phpmyadmin &amp;amp;&amp;amp; tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpmyadmin  phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ rm phpMyAdmin-latest-all-languages.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, move the directory to your web server root, and set ownership of the directory to the Apache user (example commands below). In RHEL, the Apache user is '''apache:apache''' (that is, the username '''apache''' in the group name '''apache''')&lt;br /&gt;
&lt;br /&gt;
As a refresher, the web server root is located at '''/var/www/html'''.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chown -R apache:apache phpMyAdmin-3.5.2.2-english&lt;br /&gt;
$ sudo mv phpMyAdmin-3.5.2.2-english /var/www/html/phpmyadmin&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2622</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2622"/>
		<updated>2019-01-13T03:18:57Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Inside your server via SSH, download the file to your home directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ mkdir phpmyadmin &amp;amp;&amp;amp; tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1&lt;br /&gt;
&lt;br /&gt;
$ ls&lt;br /&gt;
phpmyadmin  phpMyAdmin-latest-all-languages.tar.gz&lt;br /&gt;
&lt;br /&gt;
$ rm phpMyAdmin-latest-all-languages.tar.gz &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, move the directory to your web server root, and set ownership of the directory to the Apache user (example commands below). In RHEL, the Apache user is '''apache:apache''' (that is, the username '''apache''' in the group name '''apache''')&lt;br /&gt;
&lt;br /&gt;
As a refresher, the web server root is located at '''/var/www/html'''.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chown -R apache:apache phpMyAdmin-3.5.2.2-english&lt;br /&gt;
$ sudo mv phpMyAdmin-3.5.2.2-english /var/www/html/phpmyadmin&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2621</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2621"/>
		<updated>2019-01-13T03:11:38Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing phpMyAdmin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Inside your server via SSH, download the file to your home directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html&lt;br /&gt;
$ wget 'https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz'&lt;br /&gt;
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.&lt;br /&gt;
Saving to: “phpMyAdmin-3.5.2.2-english.tar.gz”&lt;br /&gt;
&lt;br /&gt;
100%[==================&amp;gt;] 2,972,789    910K/s   in 3.2s&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ tar -xzvf phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
...&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english  phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, move the directory to your web server root, and set ownership of the directory to the Apache user (example commands below). In RHEL, the Apache user is '''apache:apache''' (that is, the username '''apache''' in the group name '''apache''')&lt;br /&gt;
&lt;br /&gt;
As a refresher, the web server root is located at '''/var/www/html'''.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chown -R apache:apache phpMyAdmin-3.5.2.2-english&lt;br /&gt;
$ sudo mv phpMyAdmin-3.5.2.2-english /var/www/html/phpmyadmin&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2620</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2620"/>
		<updated>2019-01-13T03:08:36Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Installing and Configuring MySQL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries. In '''yum (RHEL)''', you need the packages '''mysql56-server''' and '''php70-mysqlnd''' and '''php70-mcrypt''' and '''php70-mbstring'''&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
Run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Get the link to the latest '''*.tar.gz''' version of phpMyAdmin here: http://www.phpmyadmin.net/home_page/downloads.php&lt;br /&gt;
&lt;br /&gt;
Inside your server via SSH, download the file to your home directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ wget 'https://files.phpmyadmin.net/phpMyAdmin/4.4.15/phpMyAdmin-4.4.15-all-languages.tar.gz'&lt;br /&gt;
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.&lt;br /&gt;
Saving to: “phpMyAdmin-3.5.2.2-english.tar.gz”&lt;br /&gt;
&lt;br /&gt;
100%[==================&amp;gt;] 2,972,789    910K/s   in 3.2s&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ tar -xzvf phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
...&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english  phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, move the directory to your web server root, and set ownership of the directory to the Apache user (example commands below). In RHEL, the Apache user is '''apache:apache''' (that is, the username '''apache''' in the group name '''apache''')&lt;br /&gt;
&lt;br /&gt;
As a refresher, the web server root is located at '''/var/www/html'''.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chown -R apache:apache phpMyAdmin-3.5.2.2-english&lt;br /&gt;
$ sudo mv phpMyAdmin-3.5.2.2-english /var/www/html/phpmyadmin&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2619</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2619"/>
		<updated>2019-01-13T02:50:02Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Module 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
* Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
* Navigate to the created repo in Bitbucket&lt;br /&gt;
* Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
* In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
* If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
* You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config.json file should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP https://sourceforge.net/projects/wampserver/&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, run php files, and use phpmyadmin.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions&lt;br /&gt;
 /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2618</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2618"/>
		<updated>2019-01-13T02:49:40Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
* Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
* Navigate to the created repo in Bitbucket&lt;br /&gt;
* Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
* In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
* If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
* You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP https://sourceforge.net/projects/wampserver/&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, run php files, and use phpmyadmin.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions&lt;br /&gt;
 /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2617</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2617"/>
		<updated>2019-01-13T02:45:08Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP https://sourceforge.net/projects/wampserver/&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, run php files, and use phpmyadmin.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions&lt;br /&gt;
 /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2616</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2616"/>
		<updated>2019-01-13T02:43:49Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Testing Everything Locally */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, run php files, and use phpmyadmin.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2615</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2615"/>
		<updated>2019-01-13T02:43:13Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Module 1 -- Using the Git Integration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win . You can check if you have Git running by typing git --version in your terminal'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2614</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2614"/>
		<updated>2019-01-13T02:21:09Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;br /&gt;
# In VS Code, search for the extension '''Php Server'''. After installing, use VS Code's command pallette with CMD+Shift+P , search for PHP, and select start server.  You should be able to view your project in your localhost&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2613</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2613"/>
		<updated>2019-01-13T02:18:25Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win'''&lt;br /&gt;
&lt;br /&gt;
* First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
[[File:New-file.png|400px|center]]&lt;br /&gt;
* Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
* Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
* Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
* To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
* Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings with '''CMD + ,''' (Mac) or '''Ctrl + ,''' (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=File:New-file.png&amp;diff=2612</id>
		<title>File:New-file.png</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=File:New-file.png&amp;diff=2612"/>
		<updated>2019-01-13T02:15:23Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2611</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2611"/>
		<updated>2019-01-13T02:13:15Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Module 1 -- Using the Git Integration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
'''Note: If you're using Windows, you may need to install Git on your machine first. https://git-scm.com/download/win'''&lt;br /&gt;
&lt;br /&gt;
# First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
# Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
# Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
# Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
# To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
# Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/public_html/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2610</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2610"/>
		<updated>2019-01-13T02:09:39Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Set Up your Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To save from typing this command in every time you want to access your server, you can set an '''alias''' in your terminal.&lt;br /&gt;
&lt;br /&gt;
In the '''Mac''' terminal, vim ~/.bash_profile and input the following command:&lt;br /&gt;
 $ alias aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
Now, whenever you type aws in your terminal, it will type your ssh command.&lt;br /&gt;
&lt;br /&gt;
In '''Cygwin''', vim ~/.bash_profile and input the following:&lt;br /&gt;
 $ export aws=&amp;quot;ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com&amp;quot;&lt;br /&gt;
And you run this command by typing $aws&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Follow the SFTP and Git instructions on the [[VS Code]] page&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2609</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2609"/>
		<updated>2019-01-13T02:08:09Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Configure SSH */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To save from typing this command in every time you want to access your server, you can set an '''alias''' in your terminal.&lt;br /&gt;
&lt;br /&gt;
In the '''Mac''' terminal, vim ~/.bash_profile and input the following command:&lt;br /&gt;
 $ alias aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
Now, whenever you type aws in your terminal, it will type your ssh command.&lt;br /&gt;
&lt;br /&gt;
In '''Cygwin''', vim ~/.bash_profile and input the following:&lt;br /&gt;
 $ export aws=&amp;quot;ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com&amp;quot;&lt;br /&gt;
And you run this command by typing $aws&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2608</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2608"/>
		<updated>2019-01-13T02:07:36Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Configure SSH */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To save from typing this command in every time you want to access your server, you can set an '''alias''' in your terminal.&lt;br /&gt;
&lt;br /&gt;
In the '''Mac''' terminal, vim ~/.bash_profile and input the following command:&lt;br /&gt;
 $ alias aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
Now, whenever you type aws in your terminal, it will type your ssh command.&lt;br /&gt;
&lt;br /&gt;
In '''Cygwin''', vim ~/.bash_profile and input the following:&lt;br /&gt;
 $ export aws='ssh your-username@ec2.xx-xx-xx-xx.compute-1.amazonaws.com'&lt;br /&gt;
And you run this command by typing $aws&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2607</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2607"/>
		<updated>2019-01-13T01:58:53Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Starting a Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
'''Not uploading your key is perfectly fine, and in many cases easier.  Here are the instructions though, if you'd like'''&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
'''Again, if you're following along with the [[VS Code]] page, using FileZilla is not necessary, and harder to use'''&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2606</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2606"/>
		<updated>2019-01-13T01:58:37Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Komodo Edit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
'''Not uploading your key is perfectly fine, and in many cases easier.  Here are the instructions though, if you'd like'''&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
'''Again, if you're following along with the [[VS Code]] page, using FileZilla is not necessary, and harder to use'''&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2605</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2605"/>
		<updated>2019-01-13T01:57:53Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* FileZilla */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
'''Not uploading your key is perfectly fine, and in many cases easier.  Here are the instructions though, if you'd like'''&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
'''Again, if you're following along with the [[VS Code]] page, using FileZilla is not necessary, and harder to use'''&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2604</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2604"/>
		<updated>2019-01-13T01:57:07Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
'''Not uploading your key is perfectly fine, and in many cases easier.  Here are the instructions though, if you'd like'''&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2603</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2603"/>
		<updated>2019-01-13T01:55:32Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Bitbucket */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
'''Not uploading your key is perfectly fine, and in many cases easier.  Here are the instructions though, if you'd like'''&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== SourceTree ==&lt;br /&gt;
&lt;br /&gt;
'''SourceTree''' is a tool that enables you to perform version control using a graphical user interface.  It is free and available for Windows 7+ and Mac OS X 10.6+.&lt;br /&gt;
&lt;br /&gt;
SourceTree is available on the Mac App Store.  Windows users (and OS X users who don't like the App Store) may install it from http://sourcetreeapp.com/&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
&lt;br /&gt;
'''[[wikipedia:Git (software)|Git]]''' is a ''distributed version control system'' that enables you to track changes to your code and work with collaborators on the same code base.  In CSE 132, you used ''Subversion (SVN)'', which is also version control system.&lt;br /&gt;
&lt;br /&gt;
Git, like SVN, is a command-line tool.  However, SourceTree enables you to use Git without having to pull up a Terminal window every time you need to perform an action.&lt;br /&gt;
&lt;br /&gt;
[[Git|In Module 5]], you will learn more advanced techniques for using Git.  However, for Modules 2-4, you will be using Git primarily as a method to push your changes to your remote repository.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Git/SourceTree ===&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you install SourceTree, you need to tell it your name so that it knows how to tag changes you make.&lt;br /&gt;
&lt;br /&gt;
# Open the SourceTree Preferences (SourceTree-&amp;gt;Preferences on OS X or Tools-&amp;gt;Options on Windows).&lt;br /&gt;
# Check the box that says &amp;quot;Allow SourceTree to modify your global Mercurial and Git configuration files&amp;quot;.&lt;br /&gt;
# Enter your name and e-mail address.&lt;br /&gt;
#: '''Note:''' This actually does the same thing as running &amp;lt;code&amp;gt;git config --global user.name &amp;lt;NAME HERE&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;git config --global user.email &amp;lt;EMAIL HERE&amp;gt;&amp;lt;/code&amp;gt; from the command line.&lt;br /&gt;
# Go to the &amp;quot;Git&amp;quot; tab, and make the following change:&lt;br /&gt;
#* Check &amp;quot;Disable SSL certificate validation&amp;quot;.  This is necessary for the git repos hosted in the CEC.  (Note: this semester we are using BitBucket repos instead of CEC repos, so you can leave this box unchecked if you prefer.)&lt;br /&gt;
# Close the preferences window.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Cloning a Repository ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Clone.png|400px|thumb|right|Screenshot of cloning a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
We will start by ''cloning'' a remote Git repository.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Cloning&amp;quot; in Git is much like &amp;quot;checking out&amp;quot; in SVN: a remote copy of the repository is copied down to a local working directory.  '''Word of Caution:''' Git uses the term &amp;quot;checkout&amp;quot; to mean something different (which you will learn in Module 5), so ''do not'' use the words &amp;quot;clone&amp;quot; and &amp;quot;checkout&amp;quot; interchangeably.&lt;br /&gt;
&lt;br /&gt;
If you wanted to clone a repository on the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://www.example.com/url-of-repo destination-path&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, go to '''File-&amp;gt;New''', enter the remote repository URL and the destination path, and press &amp;quot;Clone&amp;quot;.  The destination path is where you want the repository's files to be copied on your personal computer; the path should point to either an empty or a nonexistent directory on your personal computer.  In the screenshot, I am cloning the repository for the Fedora Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The remote repository will now be cloned onto your personal computer and all ready to use.&lt;br /&gt;
&lt;br /&gt;
=== Committing ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-commit.jpg|400px|thumb|right|Screenshot of committing to a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
When you make changes to files or add new files, you need to ''commit'' them to your working repository.  '''Note:''' When you &amp;quot;commit&amp;quot; something in SVN, it means that you are sending your changes to the remote repository.  This is ''not'' the case in Git, as we will see shortly.&lt;br /&gt;
&lt;br /&gt;
To prepare your commit, press the &amp;quot;Commit&amp;quot; button in the SourceTree toolbar.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
Select the files you want to commit, and enter a commit message summarizing the changes you've made since your last commit.  When you're ready, press &amp;quot;Commit&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The command line equivalent of this would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add --all # adds untracked files to the repository and stages them for the commit&lt;br /&gt;
$ git commit -am &amp;quot;This is an example commit&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens now is that your changes are recorded ''in your own local working copy of the Git repository''.  The changes have '''''not''''' been saved in the remote repository.  You need to do this by ''pushing'' them.&lt;br /&gt;
&lt;br /&gt;
=== Pushing ===&lt;br /&gt;
&lt;br /&gt;
Git is different from SVN in that you can use it completely independently from a remote repository.  Thus, in Git, you need to perform the &amp;quot;commit&amp;quot; and &amp;quot;push&amp;quot; steps separately.&lt;br /&gt;
&lt;br /&gt;
''After'' you perform a commit, you need to ''push'' your commit to your remote repository.  To do this, press the &amp;quot;Push&amp;quot; button in SourceTree, and then press &amp;quot;OK&amp;quot;.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git push master # assuming your branch is still named the default &amp;quot;master&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You do not need to push after every commit.  You could have 4 or 5 commits before you actually perform the push.  When you push, all commits will be pushed.&lt;br /&gt;
&lt;br /&gt;
=== Pulling ===&lt;br /&gt;
&lt;br /&gt;
In SVN, if you want to download changes from your remote repository, you performed an ''update''.  In Git, you perform a ''pull''.&lt;br /&gt;
&lt;br /&gt;
Pulling is (usually) as simple as pressing the &amp;quot;Pull&amp;quot; button in SourceTree.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git pull master&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to download the changes from the remote repository but not overwrite your current working copy, you can perform a ''fetch'' instead.&lt;br /&gt;
&lt;br /&gt;
== Pageant and PuTTYgen: SSH Keys for Windows ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Pageant''' is a Windows utility that enables applications like SourceTree and Komodo Edit (which we will install in the next step) to be able to use your SSH keys when authenticating on remote services (like Bitbucket and your EC2 instance).  '''PuTTYgen''' is a utility that converts SSH keys into a format that Pageant can understand.&lt;br /&gt;
&lt;br /&gt;
'''Mac OS X and Linux users may skip this section.'''&lt;br /&gt;
&lt;br /&gt;
=== Installing Pageant and PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
Pageant and PuTTYgen both come bundled with SourceTree, so you do not need to install them separately.  However, if you weren't using SourceTree, you could install them from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&lt;br /&gt;
&lt;br /&gt;
=== Using PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
We will use PuTTYgen to convert our SSH keys into Pageant's format, ''*.ppk''.&lt;br /&gt;
&lt;br /&gt;
# Launch PuTTYgen.  If you downloaded ''puttygen.exe'', just open it; if you are using the SourceTree version, you can find it under the Tools menu:&lt;br /&gt;
#: [[File:LaunchPuTTYgen.jpg]]&lt;br /&gt;
# Inside PuTTYgen, click &amp;quot;Load&amp;quot; next to &amp;quot;Load an existing private key file&amp;quot;.  We want to load the private key we generated in [[SSH|the SSH guide]] using ''ssh-keygen''.&lt;br /&gt;
#* If you are using a CEC machine, the key will be at: &amp;lt;code&amp;gt;H:\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#* If you are using your own computer, the key should be at: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#: Note that you might need to choose &amp;quot;All Files (*.*)&amp;quot; in order to see the file.&lt;br /&gt;
# When the key gets loaded, click &amp;quot;Save private key&amp;quot;&lt;br /&gt;
#: FileZilla, which will also need this *.ppk key, does not play nicely with passphrases, so leave the passphrase blank.&lt;br /&gt;
#: A good place to save the file would be back in Cygwin's ''.ssh'' directory:&lt;br /&gt;
#* CEC lab machines: &amp;lt;code&amp;gt;H:\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Personal machines: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
# Close PuTTYgen.&lt;br /&gt;
&lt;br /&gt;
=== Using Pageant ===&lt;br /&gt;
&lt;br /&gt;
To launch Pageant, either run ''pageant.exe'' or select it from the Tools menu in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:LaunchPageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
The first time you launch pageant, it will ask you to select a key.  Select the ''*.ppk'' file you saved in the previous section.&lt;br /&gt;
&lt;br /&gt;
If you wish to add more keys to Pageant, right-click on its icon down in the start bar:&lt;br /&gt;
&lt;br /&gt;
[[File:UsePageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Adding Pageant as a Startup Item ===&lt;br /&gt;
&lt;br /&gt;
If you are using your own computer, it may be convenient to add Pageant as a startup item so that you don't need to go into SourceTree and turn it on every time you reboot your computer.&lt;br /&gt;
&lt;br /&gt;
# Download ''pageant.exe'' if you were using SourceTree&lt;br /&gt;
# Open your Startup Items folder, located at Start Menu -&amp;gt; All Programs -&amp;gt; Startup (right-click and say &amp;quot;Open&amp;quot;)&lt;br /&gt;
# Right-click inside the folder and say &amp;quot;New -&amp;gt; Shortcut&amp;quot;.  For the location, enter:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&amp;quot;C:\path\to\pageant.exe&amp;quot; &amp;quot;c:\path\to\key.ppk&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
#: This will cause Pageant to open and automatically load your key.&lt;br /&gt;
# Press &amp;quot;Next&amp;quot;.  Enter a name and press &amp;quot;Finish&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Thanks to [http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/pka-putty.html the University of Alberta] for this tip.&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2602</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2602"/>
		<updated>2019-01-13T01:53:27Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* File Transfer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
See [[VS Code]] and the Module 2 section to see our recommended file transfer method. If you're not using VS Code, you may use '''FileZilla''' to transport files from your local computer to your server.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== SourceTree ==&lt;br /&gt;
&lt;br /&gt;
'''SourceTree''' is a tool that enables you to perform version control using a graphical user interface.  It is free and available for Windows 7+ and Mac OS X 10.6+.&lt;br /&gt;
&lt;br /&gt;
SourceTree is available on the Mac App Store.  Windows users (and OS X users who don't like the App Store) may install it from http://sourcetreeapp.com/&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
&lt;br /&gt;
'''[[wikipedia:Git (software)|Git]]''' is a ''distributed version control system'' that enables you to track changes to your code and work with collaborators on the same code base.  In CSE 132, you used ''Subversion (SVN)'', which is also version control system.&lt;br /&gt;
&lt;br /&gt;
Git, like SVN, is a command-line tool.  However, SourceTree enables you to use Git without having to pull up a Terminal window every time you need to perform an action.&lt;br /&gt;
&lt;br /&gt;
[[Git|In Module 5]], you will learn more advanced techniques for using Git.  However, for Modules 2-4, you will be using Git primarily as a method to push your changes to your remote repository.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Git/SourceTree ===&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you install SourceTree, you need to tell it your name so that it knows how to tag changes you make.&lt;br /&gt;
&lt;br /&gt;
# Open the SourceTree Preferences (SourceTree-&amp;gt;Preferences on OS X or Tools-&amp;gt;Options on Windows).&lt;br /&gt;
# Check the box that says &amp;quot;Allow SourceTree to modify your global Mercurial and Git configuration files&amp;quot;.&lt;br /&gt;
# Enter your name and e-mail address.&lt;br /&gt;
#: '''Note:''' This actually does the same thing as running &amp;lt;code&amp;gt;git config --global user.name &amp;lt;NAME HERE&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;git config --global user.email &amp;lt;EMAIL HERE&amp;gt;&amp;lt;/code&amp;gt; from the command line.&lt;br /&gt;
# Go to the &amp;quot;Git&amp;quot; tab, and make the following change:&lt;br /&gt;
#* Check &amp;quot;Disable SSL certificate validation&amp;quot;.  This is necessary for the git repos hosted in the CEC.  (Note: this semester we are using BitBucket repos instead of CEC repos, so you can leave this box unchecked if you prefer.)&lt;br /&gt;
# Close the preferences window.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Cloning a Repository ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Clone.png|400px|thumb|right|Screenshot of cloning a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
We will start by ''cloning'' a remote Git repository.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Cloning&amp;quot; in Git is much like &amp;quot;checking out&amp;quot; in SVN: a remote copy of the repository is copied down to a local working directory.  '''Word of Caution:''' Git uses the term &amp;quot;checkout&amp;quot; to mean something different (which you will learn in Module 5), so ''do not'' use the words &amp;quot;clone&amp;quot; and &amp;quot;checkout&amp;quot; interchangeably.&lt;br /&gt;
&lt;br /&gt;
If you wanted to clone a repository on the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://www.example.com/url-of-repo destination-path&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, go to '''File-&amp;gt;New''', enter the remote repository URL and the destination path, and press &amp;quot;Clone&amp;quot;.  The destination path is where you want the repository's files to be copied on your personal computer; the path should point to either an empty or a nonexistent directory on your personal computer.  In the screenshot, I am cloning the repository for the Fedora Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The remote repository will now be cloned onto your personal computer and all ready to use.&lt;br /&gt;
&lt;br /&gt;
=== Committing ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-commit.jpg|400px|thumb|right|Screenshot of committing to a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
When you make changes to files or add new files, you need to ''commit'' them to your working repository.  '''Note:''' When you &amp;quot;commit&amp;quot; something in SVN, it means that you are sending your changes to the remote repository.  This is ''not'' the case in Git, as we will see shortly.&lt;br /&gt;
&lt;br /&gt;
To prepare your commit, press the &amp;quot;Commit&amp;quot; button in the SourceTree toolbar.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
Select the files you want to commit, and enter a commit message summarizing the changes you've made since your last commit.  When you're ready, press &amp;quot;Commit&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The command line equivalent of this would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add --all # adds untracked files to the repository and stages them for the commit&lt;br /&gt;
$ git commit -am &amp;quot;This is an example commit&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens now is that your changes are recorded ''in your own local working copy of the Git repository''.  The changes have '''''not''''' been saved in the remote repository.  You need to do this by ''pushing'' them.&lt;br /&gt;
&lt;br /&gt;
=== Pushing ===&lt;br /&gt;
&lt;br /&gt;
Git is different from SVN in that you can use it completely independently from a remote repository.  Thus, in Git, you need to perform the &amp;quot;commit&amp;quot; and &amp;quot;push&amp;quot; steps separately.&lt;br /&gt;
&lt;br /&gt;
''After'' you perform a commit, you need to ''push'' your commit to your remote repository.  To do this, press the &amp;quot;Push&amp;quot; button in SourceTree, and then press &amp;quot;OK&amp;quot;.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git push master # assuming your branch is still named the default &amp;quot;master&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You do not need to push after every commit.  You could have 4 or 5 commits before you actually perform the push.  When you push, all commits will be pushed.&lt;br /&gt;
&lt;br /&gt;
=== Pulling ===&lt;br /&gt;
&lt;br /&gt;
In SVN, if you want to download changes from your remote repository, you performed an ''update''.  In Git, you perform a ''pull''.&lt;br /&gt;
&lt;br /&gt;
Pulling is (usually) as simple as pressing the &amp;quot;Pull&amp;quot; button in SourceTree.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git pull master&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to download the changes from the remote repository but not overwrite your current working copy, you can perform a ''fetch'' instead.&lt;br /&gt;
&lt;br /&gt;
== Pageant and PuTTYgen: SSH Keys for Windows ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Pageant''' is a Windows utility that enables applications like SourceTree and Komodo Edit (which we will install in the next step) to be able to use your SSH keys when authenticating on remote services (like Bitbucket and your EC2 instance).  '''PuTTYgen''' is a utility that converts SSH keys into a format that Pageant can understand.&lt;br /&gt;
&lt;br /&gt;
'''Mac OS X and Linux users may skip this section.'''&lt;br /&gt;
&lt;br /&gt;
=== Installing Pageant and PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
Pageant and PuTTYgen both come bundled with SourceTree, so you do not need to install them separately.  However, if you weren't using SourceTree, you could install them from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&lt;br /&gt;
&lt;br /&gt;
=== Using PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
We will use PuTTYgen to convert our SSH keys into Pageant's format, ''*.ppk''.&lt;br /&gt;
&lt;br /&gt;
# Launch PuTTYgen.  If you downloaded ''puttygen.exe'', just open it; if you are using the SourceTree version, you can find it under the Tools menu:&lt;br /&gt;
#: [[File:LaunchPuTTYgen.jpg]]&lt;br /&gt;
# Inside PuTTYgen, click &amp;quot;Load&amp;quot; next to &amp;quot;Load an existing private key file&amp;quot;.  We want to load the private key we generated in [[SSH|the SSH guide]] using ''ssh-keygen''.&lt;br /&gt;
#* If you are using a CEC machine, the key will be at: &amp;lt;code&amp;gt;H:\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#* If you are using your own computer, the key should be at: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#: Note that you might need to choose &amp;quot;All Files (*.*)&amp;quot; in order to see the file.&lt;br /&gt;
# When the key gets loaded, click &amp;quot;Save private key&amp;quot;&lt;br /&gt;
#: FileZilla, which will also need this *.ppk key, does not play nicely with passphrases, so leave the passphrase blank.&lt;br /&gt;
#: A good place to save the file would be back in Cygwin's ''.ssh'' directory:&lt;br /&gt;
#* CEC lab machines: &amp;lt;code&amp;gt;H:\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Personal machines: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
# Close PuTTYgen.&lt;br /&gt;
&lt;br /&gt;
=== Using Pageant ===&lt;br /&gt;
&lt;br /&gt;
To launch Pageant, either run ''pageant.exe'' or select it from the Tools menu in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:LaunchPageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
The first time you launch pageant, it will ask you to select a key.  Select the ''*.ppk'' file you saved in the previous section.&lt;br /&gt;
&lt;br /&gt;
If you wish to add more keys to Pageant, right-click on its icon down in the start bar:&lt;br /&gt;
&lt;br /&gt;
[[File:UsePageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Adding Pageant as a Startup Item ===&lt;br /&gt;
&lt;br /&gt;
If you are using your own computer, it may be convenient to add Pageant as a startup item so that you don't need to go into SourceTree and turn it on every time you reboot your computer.&lt;br /&gt;
&lt;br /&gt;
# Download ''pageant.exe'' if you were using SourceTree&lt;br /&gt;
# Open your Startup Items folder, located at Start Menu -&amp;gt; All Programs -&amp;gt; Startup (right-click and say &amp;quot;Open&amp;quot;)&lt;br /&gt;
# Right-click inside the folder and say &amp;quot;New -&amp;gt; Shortcut&amp;quot;.  For the location, enter:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&amp;quot;C:\path\to\pageant.exe&amp;quot; &amp;quot;c:\path\to\key.ppk&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
#: This will cause Pageant to open and automatically load your key.&lt;br /&gt;
# Press &amp;quot;Next&amp;quot;.  Enter a name and press &amp;quot;Finish&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Thanks to [http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/pka-putty.html the University of Alberta] for this tip.&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2601</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2601"/>
		<updated>2019-01-13T01:51:57Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Text Editing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
Although we highly recommend '''VS Code''', you may use '''Sublime Text''', '''Komodo Edit''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
You may use '''FileZilla''' as your tool for uploading files from your local working directory to your remote server. Another excellent option is '''Cyberduck'''.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== SourceTree ==&lt;br /&gt;
&lt;br /&gt;
'''SourceTree''' is a tool that enables you to perform version control using a graphical user interface.  It is free and available for Windows 7+ and Mac OS X 10.6+.&lt;br /&gt;
&lt;br /&gt;
SourceTree is available on the Mac App Store.  Windows users (and OS X users who don't like the App Store) may install it from http://sourcetreeapp.com/&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
&lt;br /&gt;
'''[[wikipedia:Git (software)|Git]]''' is a ''distributed version control system'' that enables you to track changes to your code and work with collaborators on the same code base.  In CSE 132, you used ''Subversion (SVN)'', which is also version control system.&lt;br /&gt;
&lt;br /&gt;
Git, like SVN, is a command-line tool.  However, SourceTree enables you to use Git without having to pull up a Terminal window every time you need to perform an action.&lt;br /&gt;
&lt;br /&gt;
[[Git|In Module 5]], you will learn more advanced techniques for using Git.  However, for Modules 2-4, you will be using Git primarily as a method to push your changes to your remote repository.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Git/SourceTree ===&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you install SourceTree, you need to tell it your name so that it knows how to tag changes you make.&lt;br /&gt;
&lt;br /&gt;
# Open the SourceTree Preferences (SourceTree-&amp;gt;Preferences on OS X or Tools-&amp;gt;Options on Windows).&lt;br /&gt;
# Check the box that says &amp;quot;Allow SourceTree to modify your global Mercurial and Git configuration files&amp;quot;.&lt;br /&gt;
# Enter your name and e-mail address.&lt;br /&gt;
#: '''Note:''' This actually does the same thing as running &amp;lt;code&amp;gt;git config --global user.name &amp;lt;NAME HERE&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;git config --global user.email &amp;lt;EMAIL HERE&amp;gt;&amp;lt;/code&amp;gt; from the command line.&lt;br /&gt;
# Go to the &amp;quot;Git&amp;quot; tab, and make the following change:&lt;br /&gt;
#* Check &amp;quot;Disable SSL certificate validation&amp;quot;.  This is necessary for the git repos hosted in the CEC.  (Note: this semester we are using BitBucket repos instead of CEC repos, so you can leave this box unchecked if you prefer.)&lt;br /&gt;
# Close the preferences window.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Cloning a Repository ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Clone.png|400px|thumb|right|Screenshot of cloning a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
We will start by ''cloning'' a remote Git repository.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Cloning&amp;quot; in Git is much like &amp;quot;checking out&amp;quot; in SVN: a remote copy of the repository is copied down to a local working directory.  '''Word of Caution:''' Git uses the term &amp;quot;checkout&amp;quot; to mean something different (which you will learn in Module 5), so ''do not'' use the words &amp;quot;clone&amp;quot; and &amp;quot;checkout&amp;quot; interchangeably.&lt;br /&gt;
&lt;br /&gt;
If you wanted to clone a repository on the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://www.example.com/url-of-repo destination-path&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, go to '''File-&amp;gt;New''', enter the remote repository URL and the destination path, and press &amp;quot;Clone&amp;quot;.  The destination path is where you want the repository's files to be copied on your personal computer; the path should point to either an empty or a nonexistent directory on your personal computer.  In the screenshot, I am cloning the repository for the Fedora Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The remote repository will now be cloned onto your personal computer and all ready to use.&lt;br /&gt;
&lt;br /&gt;
=== Committing ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-commit.jpg|400px|thumb|right|Screenshot of committing to a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
When you make changes to files or add new files, you need to ''commit'' them to your working repository.  '''Note:''' When you &amp;quot;commit&amp;quot; something in SVN, it means that you are sending your changes to the remote repository.  This is ''not'' the case in Git, as we will see shortly.&lt;br /&gt;
&lt;br /&gt;
To prepare your commit, press the &amp;quot;Commit&amp;quot; button in the SourceTree toolbar.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
Select the files you want to commit, and enter a commit message summarizing the changes you've made since your last commit.  When you're ready, press &amp;quot;Commit&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The command line equivalent of this would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add --all # adds untracked files to the repository and stages them for the commit&lt;br /&gt;
$ git commit -am &amp;quot;This is an example commit&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens now is that your changes are recorded ''in your own local working copy of the Git repository''.  The changes have '''''not''''' been saved in the remote repository.  You need to do this by ''pushing'' them.&lt;br /&gt;
&lt;br /&gt;
=== Pushing ===&lt;br /&gt;
&lt;br /&gt;
Git is different from SVN in that you can use it completely independently from a remote repository.  Thus, in Git, you need to perform the &amp;quot;commit&amp;quot; and &amp;quot;push&amp;quot; steps separately.&lt;br /&gt;
&lt;br /&gt;
''After'' you perform a commit, you need to ''push'' your commit to your remote repository.  To do this, press the &amp;quot;Push&amp;quot; button in SourceTree, and then press &amp;quot;OK&amp;quot;.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git push master # assuming your branch is still named the default &amp;quot;master&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You do not need to push after every commit.  You could have 4 or 5 commits before you actually perform the push.  When you push, all commits will be pushed.&lt;br /&gt;
&lt;br /&gt;
=== Pulling ===&lt;br /&gt;
&lt;br /&gt;
In SVN, if you want to download changes from your remote repository, you performed an ''update''.  In Git, you perform a ''pull''.&lt;br /&gt;
&lt;br /&gt;
Pulling is (usually) as simple as pressing the &amp;quot;Pull&amp;quot; button in SourceTree.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git pull master&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to download the changes from the remote repository but not overwrite your current working copy, you can perform a ''fetch'' instead.&lt;br /&gt;
&lt;br /&gt;
== Pageant and PuTTYgen: SSH Keys for Windows ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Pageant''' is a Windows utility that enables applications like SourceTree and Komodo Edit (which we will install in the next step) to be able to use your SSH keys when authenticating on remote services (like Bitbucket and your EC2 instance).  '''PuTTYgen''' is a utility that converts SSH keys into a format that Pageant can understand.&lt;br /&gt;
&lt;br /&gt;
'''Mac OS X and Linux users may skip this section.'''&lt;br /&gt;
&lt;br /&gt;
=== Installing Pageant and PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
Pageant and PuTTYgen both come bundled with SourceTree, so you do not need to install them separately.  However, if you weren't using SourceTree, you could install them from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&lt;br /&gt;
&lt;br /&gt;
=== Using PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
We will use PuTTYgen to convert our SSH keys into Pageant's format, ''*.ppk''.&lt;br /&gt;
&lt;br /&gt;
# Launch PuTTYgen.  If you downloaded ''puttygen.exe'', just open it; if you are using the SourceTree version, you can find it under the Tools menu:&lt;br /&gt;
#: [[File:LaunchPuTTYgen.jpg]]&lt;br /&gt;
# Inside PuTTYgen, click &amp;quot;Load&amp;quot; next to &amp;quot;Load an existing private key file&amp;quot;.  We want to load the private key we generated in [[SSH|the SSH guide]] using ''ssh-keygen''.&lt;br /&gt;
#* If you are using a CEC machine, the key will be at: &amp;lt;code&amp;gt;H:\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#* If you are using your own computer, the key should be at: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#: Note that you might need to choose &amp;quot;All Files (*.*)&amp;quot; in order to see the file.&lt;br /&gt;
# When the key gets loaded, click &amp;quot;Save private key&amp;quot;&lt;br /&gt;
#: FileZilla, which will also need this *.ppk key, does not play nicely with passphrases, so leave the passphrase blank.&lt;br /&gt;
#: A good place to save the file would be back in Cygwin's ''.ssh'' directory:&lt;br /&gt;
#* CEC lab machines: &amp;lt;code&amp;gt;H:\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Personal machines: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
# Close PuTTYgen.&lt;br /&gt;
&lt;br /&gt;
=== Using Pageant ===&lt;br /&gt;
&lt;br /&gt;
To launch Pageant, either run ''pageant.exe'' or select it from the Tools menu in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:LaunchPageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
The first time you launch pageant, it will ask you to select a key.  Select the ''*.ppk'' file you saved in the previous section.&lt;br /&gt;
&lt;br /&gt;
If you wish to add more keys to Pageant, right-click on its icon down in the start bar:&lt;br /&gt;
&lt;br /&gt;
[[File:UsePageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Adding Pageant as a Startup Item ===&lt;br /&gt;
&lt;br /&gt;
If you are using your own computer, it may be convenient to add Pageant as a startup item so that you don't need to go into SourceTree and turn it on every time you reboot your computer.&lt;br /&gt;
&lt;br /&gt;
# Download ''pageant.exe'' if you were using SourceTree&lt;br /&gt;
# Open your Startup Items folder, located at Start Menu -&amp;gt; All Programs -&amp;gt; Startup (right-click and say &amp;quot;Open&amp;quot;)&lt;br /&gt;
# Right-click inside the folder and say &amp;quot;New -&amp;gt; Shortcut&amp;quot;.  For the location, enter:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&amp;quot;C:\path\to\pageant.exe&amp;quot; &amp;quot;c:\path\to\key.ppk&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
#: This will cause Pageant to open and automatically load your key.&lt;br /&gt;
# Press &amp;quot;Next&amp;quot;.  Enter a name and press &amp;quot;Finish&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Thanks to [http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/pka-putty.html the University of Alberta] for this tip.&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2600</id>
		<title>Workflow</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Workflow&amp;diff=2600"/>
		<updated>2019-01-13T01:49:51Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* Version Control */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
There are going to be several aspects to our workflow in CSE 330, and we will be switching between multiple different programs.  Here is how they all fit together.&lt;br /&gt;
&lt;br /&gt;
=== Running Commands ===&lt;br /&gt;
&lt;br /&gt;
''Mac OS X:'' You will be running commands on your local machine using '''Terminal''', which you can find in your Applications -&amp;gt; Utilities folder.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
''Windows:'' You will be running commands on your local machine using '''WSL''' or '''Cygwin''', which you will install in the next section.  You will be connecting to your server via SSH.&lt;br /&gt;
&lt;br /&gt;
=== Version Control ===&lt;br /&gt;
&lt;br /&gt;
You will be using '''Git''' as your version control system.  Git enables you to keep track of changes to your source code.  If you're using VS Code, the Git integration makes is very user friendly.&lt;br /&gt;
&lt;br /&gt;
=== Text Editing ===&lt;br /&gt;
&lt;br /&gt;
You may use '''Komodo Edit''' as your text editing tool, but don't have to. Other excellent programs include '''Sublime Text''', '''Notepad++''' (for Windows), and '''TextWrangler''' (for Mac). You can also use an IDE, like '''PHPStorm''', if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== File Transfer ===&lt;br /&gt;
&lt;br /&gt;
You may use '''FileZilla''' as your tool for uploading files from your local working directory to your remote server. Another excellent option is '''Cyberduck'''.&lt;br /&gt;
&lt;br /&gt;
=== Flowchart ===&lt;br /&gt;
&lt;br /&gt;
If you are more visual, this flowchart might help:&lt;br /&gt;
&lt;br /&gt;
[[File:CSE-330-Workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The flowchart illustrates 3 methods to copy files to your cloud instance: via your text editor, via an external SFTP client, and by cloning your remote Git repository.  We will be primarily using '''Option 2''' in CSE 330 this semester.&lt;br /&gt;
&lt;br /&gt;
In the flowchart, your ''Git Client'' is SourceTree and your ''Text Editor'' is Komodo.  The ''SFTP Client'' could be FileZilla.&lt;br /&gt;
&lt;br /&gt;
== Installing a Terminal Emulator ==&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Windows is based on a fundamentally different architecture than Linux, meaning that, if you want to run Linux programs on Windows, you'll have to enable or install a special terminal emulator for it. Mac users do not need to install a terminal emulator since MacOs itself is a derivative of Unix, which is an ancestor of Linux.  The Terminal utility is all you need.&lt;br /&gt;
&lt;br /&gt;
=== Windows Subsystem for Linux ===&lt;br /&gt;
&lt;br /&gt;
Starting in Windows 10, Windows has the ability to emulate Linux, meaning that you can run Linux commands on Windows, without having to install Cygwin. To enable WSL, follow [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide these instructions]. Once those instructions are complete, you can open a shell by clicking on the Start menu, typing &amp;quot;Bash&amp;quot;, then clicking on the entry labeled &amp;quot;Bash on Ubuntu on Windows&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
'''Cygwin''' is a Linux Terminal emulator for Windows.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
&lt;br /&gt;
The CEC lab machines already have Cygwin installed.  Follow these instructions to get Cygwin up and running on your personal PC.&lt;br /&gt;
&lt;br /&gt;
# Run ''setup.exe'' from http://www.cygwin.com/&lt;br /&gt;
# Keep the Cygwin directory as the default, ''C:\cygwin''.  Choose a place like ''C:\cygwin\downloads'' to download the installation files.  Choose any download site, although probably one with a .com suffix is best when you're in the US.&lt;br /&gt;
# In the &amp;quot;Select Packages&amp;quot; screen, select the following packages:&lt;br /&gt;
#* Net -&amp;gt; openssh&lt;br /&gt;
#* Net -&amp;gt; openssl&lt;br /&gt;
#* Python -&amp;gt; python (you will need this for Module 4)&lt;br /&gt;
#* Devel -&amp;gt; git (version control system)&lt;br /&gt;
#* One or more of the following:&lt;br /&gt;
#** Editors -&amp;gt; vim&lt;br /&gt;
#** Editors -&amp;gt; emacs&lt;br /&gt;
#** Editors -&amp;gt; nano&lt;br /&gt;
# Allow the installation to complete.&lt;br /&gt;
&lt;br /&gt;
Throughout the rest of this course, when we say to &amp;quot;open a terminal&amp;quot;, if you are on Windows, we mean to &amp;quot;open WSL/Cygwin&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Bitbucket ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Bitbucket''' is a service that enables you to store your code for free in the cloud.  It is similar in spirit to Github, but with a different mission statement.&lt;br /&gt;
&lt;br /&gt;
=== Creating a Bitbucket Account ===&lt;br /&gt;
&lt;br /&gt;
Go to [https://bitbucket.org/account/signup/ Bitbucket.org] to create an account.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' Use your @wustl.edu e-mail address to create your account.  This will put your account on the &amp;quot;educational plan&amp;quot;, which removes some limitations of the free account.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you know someone who uses Bitbucket, you can ask them to invite you as a friend.  This will increase the member limit on the inviter's private repos.&lt;br /&gt;
&lt;br /&gt;
=== Adding Your Key to Bitbucket ===&lt;br /&gt;
&lt;br /&gt;
# First make sure that you've finished the [[SSH]] guide configuration instructions.&lt;br /&gt;
#: We will use the same key for connecting to your remote server as for connecting to Bitbucket.  (This is completely valid practice.)&lt;br /&gt;
# Go to the &amp;quot;SSH keys&amp;quot; section of the settings panel (Manage Account -&amp;gt; SSH Keys)&lt;br /&gt;
# Add a new key.&lt;br /&gt;
#* I recommend naming it after the computer you're using; if you're in the CEC, for example, you could name it &amp;quot;Warehouse Cygwin&amp;quot;.&lt;br /&gt;
#* The contents of your key is the contents of your ''id_rsa.pub''.  It looks like &amp;lt;code&amp;gt;ssh-rsa AAAAB3blahblahblahblah yourname@somedomain&amp;lt;/code&amp;gt;.  It is exactly the same thing that you had to paste into the ''authorized_keys'' file on your EC2 instance.&lt;br /&gt;
&lt;br /&gt;
You will now be able to push code to your Bitbucket repository using your personal SSH key.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== SourceTree ==&lt;br /&gt;
&lt;br /&gt;
'''SourceTree''' is a tool that enables you to perform version control using a graphical user interface.  It is free and available for Windows 7+ and Mac OS X 10.6+.&lt;br /&gt;
&lt;br /&gt;
SourceTree is available on the Mac App Store.  Windows users (and OS X users who don't like the App Store) may install it from http://sourcetreeapp.com/&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
&lt;br /&gt;
'''[[wikipedia:Git (software)|Git]]''' is a ''distributed version control system'' that enables you to track changes to your code and work with collaborators on the same code base.  In CSE 132, you used ''Subversion (SVN)'', which is also version control system.&lt;br /&gt;
&lt;br /&gt;
Git, like SVN, is a command-line tool.  However, SourceTree enables you to use Git without having to pull up a Terminal window every time you need to perform an action.&lt;br /&gt;
&lt;br /&gt;
[[Git|In Module 5]], you will learn more advanced techniques for using Git.  However, for Modules 2-4, you will be using Git primarily as a method to push your changes to your remote repository.&lt;br /&gt;
&lt;br /&gt;
=== Configuring Git/SourceTree ===&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you install SourceTree, you need to tell it your name so that it knows how to tag changes you make.&lt;br /&gt;
&lt;br /&gt;
# Open the SourceTree Preferences (SourceTree-&amp;gt;Preferences on OS X or Tools-&amp;gt;Options on Windows).&lt;br /&gt;
# Check the box that says &amp;quot;Allow SourceTree to modify your global Mercurial and Git configuration files&amp;quot;.&lt;br /&gt;
# Enter your name and e-mail address.&lt;br /&gt;
#: '''Note:''' This actually does the same thing as running &amp;lt;code&amp;gt;git config --global user.name &amp;lt;NAME HERE&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;git config --global user.email &amp;lt;EMAIL HERE&amp;gt;&amp;lt;/code&amp;gt; from the command line.&lt;br /&gt;
# Go to the &amp;quot;Git&amp;quot; tab, and make the following change:&lt;br /&gt;
#* Check &amp;quot;Disable SSL certificate validation&amp;quot;.  This is necessary for the git repos hosted in the CEC.  (Note: this semester we are using BitBucket repos instead of CEC repos, so you can leave this box unchecked if you prefer.)&lt;br /&gt;
# Close the preferences window.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Cloning a Repository ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Clone.png|400px|thumb|right|Screenshot of cloning a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
We will start by ''cloning'' a remote Git repository.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Cloning&amp;quot; in Git is much like &amp;quot;checking out&amp;quot; in SVN: a remote copy of the repository is copied down to a local working directory.  '''Word of Caution:''' Git uses the term &amp;quot;checkout&amp;quot; to mean something different (which you will learn in Module 5), so ''do not'' use the words &amp;quot;clone&amp;quot; and &amp;quot;checkout&amp;quot; interchangeably.&lt;br /&gt;
&lt;br /&gt;
If you wanted to clone a repository on the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git clone git://www.example.com/url-of-repo destination-path&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, go to '''File-&amp;gt;New''', enter the remote repository URL and the destination path, and press &amp;quot;Clone&amp;quot;.  The destination path is where you want the repository's files to be copied on your personal computer; the path should point to either an empty or a nonexistent directory on your personal computer.  In the screenshot, I am cloning the repository for the Fedora Linux kernel.&lt;br /&gt;
&lt;br /&gt;
The remote repository will now be cloned onto your personal computer and all ready to use.&lt;br /&gt;
&lt;br /&gt;
=== Committing ===&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-commit.jpg|400px|thumb|right|Screenshot of committing to a repository in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
When you make changes to files or add new files, you need to ''commit'' them to your working repository.  '''Note:''' When you &amp;quot;commit&amp;quot; something in SVN, it means that you are sending your changes to the remote repository.  This is ''not'' the case in Git, as we will see shortly.&lt;br /&gt;
&lt;br /&gt;
To prepare your commit, press the &amp;quot;Commit&amp;quot; button in the SourceTree toolbar.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
Select the files you want to commit, and enter a commit message summarizing the changes you've made since your last commit.  When you're ready, press &amp;quot;Commit&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The command line equivalent of this would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add --all # adds untracked files to the repository and stages them for the commit&lt;br /&gt;
$ git commit -am &amp;quot;This is an example commit&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What happens now is that your changes are recorded ''in your own local working copy of the Git repository''.  The changes have '''''not''''' been saved in the remote repository.  You need to do this by ''pushing'' them.&lt;br /&gt;
&lt;br /&gt;
=== Pushing ===&lt;br /&gt;
&lt;br /&gt;
Git is different from SVN in that you can use it completely independently from a remote repository.  Thus, in Git, you need to perform the &amp;quot;commit&amp;quot; and &amp;quot;push&amp;quot; steps separately.&lt;br /&gt;
&lt;br /&gt;
''After'' you perform a commit, you need to ''push'' your commit to your remote repository.  To do this, press the &amp;quot;Push&amp;quot; button in SourceTree, and then press &amp;quot;OK&amp;quot;.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git push master # assuming your branch is still named the default &amp;quot;master&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You do not need to push after every commit.  You could have 4 or 5 commits before you actually perform the push.  When you push, all commits will be pushed.&lt;br /&gt;
&lt;br /&gt;
=== Pulling ===&lt;br /&gt;
&lt;br /&gt;
In SVN, if you want to download changes from your remote repository, you performed an ''update''.  In Git, you perform a ''pull''.&lt;br /&gt;
&lt;br /&gt;
Pulling is (usually) as simple as pressing the &amp;quot;Pull&amp;quot; button in SourceTree.  The command line equivalent is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git pull master&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to download the changes from the remote repository but not overwrite your current working copy, you can perform a ''fetch'' instead.&lt;br /&gt;
&lt;br /&gt;
== Pageant and PuTTYgen: SSH Keys for Windows ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
'''Pageant''' is a Windows utility that enables applications like SourceTree and Komodo Edit (which we will install in the next step) to be able to use your SSH keys when authenticating on remote services (like Bitbucket and your EC2 instance).  '''PuTTYgen''' is a utility that converts SSH keys into a format that Pageant can understand.&lt;br /&gt;
&lt;br /&gt;
'''Mac OS X and Linux users may skip this section.'''&lt;br /&gt;
&lt;br /&gt;
=== Installing Pageant and PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
Pageant and PuTTYgen both come bundled with SourceTree, so you do not need to install them separately.  However, if you weren't using SourceTree, you could install them from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html&lt;br /&gt;
&lt;br /&gt;
=== Using PuTTYgen ===&lt;br /&gt;
&lt;br /&gt;
We will use PuTTYgen to convert our SSH keys into Pageant's format, ''*.ppk''.&lt;br /&gt;
&lt;br /&gt;
# Launch PuTTYgen.  If you downloaded ''puttygen.exe'', just open it; if you are using the SourceTree version, you can find it under the Tools menu:&lt;br /&gt;
#: [[File:LaunchPuTTYgen.jpg]]&lt;br /&gt;
# Inside PuTTYgen, click &amp;quot;Load&amp;quot; next to &amp;quot;Load an existing private key file&amp;quot;.  We want to load the private key we generated in [[SSH|the SSH guide]] using ''ssh-keygen''.&lt;br /&gt;
#* If you are using a CEC machine, the key will be at: &amp;lt;code&amp;gt;H:\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#* If you are using your own computer, the key should be at: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa&amp;lt;/code&amp;gt;&lt;br /&gt;
#: Note that you might need to choose &amp;quot;All Files (*.*)&amp;quot; in order to see the file.&lt;br /&gt;
# When the key gets loaded, click &amp;quot;Save private key&amp;quot;&lt;br /&gt;
#: FileZilla, which will also need this *.ppk key, does not play nicely with passphrases, so leave the passphrase blank.&lt;br /&gt;
#: A good place to save the file would be back in Cygwin's ''.ssh'' directory:&lt;br /&gt;
#* CEC lab machines: &amp;lt;code&amp;gt;H:\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
#* Personal machines: &amp;lt;code&amp;gt;C:\cygwin\home\&amp;lt;your name&amp;gt;\.ssh\id_rsa.ppk&amp;lt;/code&amp;gt;&lt;br /&gt;
# Close PuTTYgen.&lt;br /&gt;
&lt;br /&gt;
=== Using Pageant ===&lt;br /&gt;
&lt;br /&gt;
To launch Pageant, either run ''pageant.exe'' or select it from the Tools menu in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:LaunchPageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
The first time you launch pageant, it will ask you to select a key.  Select the ''*.ppk'' file you saved in the previous section.&lt;br /&gt;
&lt;br /&gt;
If you wish to add more keys to Pageant, right-click on its icon down in the start bar:&lt;br /&gt;
&lt;br /&gt;
[[File:UsePageant.jpg]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Adding Pageant as a Startup Item ===&lt;br /&gt;
&lt;br /&gt;
If you are using your own computer, it may be convenient to add Pageant as a startup item so that you don't need to go into SourceTree and turn it on every time you reboot your computer.&lt;br /&gt;
&lt;br /&gt;
# Download ''pageant.exe'' if you were using SourceTree&lt;br /&gt;
# Open your Startup Items folder, located at Start Menu -&amp;gt; All Programs -&amp;gt; Startup (right-click and say &amp;quot;Open&amp;quot;)&lt;br /&gt;
# Right-click inside the folder and say &amp;quot;New -&amp;gt; Shortcut&amp;quot;.  For the location, enter:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&amp;quot;C:\path\to\pageant.exe&amp;quot; &amp;quot;c:\path\to\key.ppk&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
#: This will cause Pageant to open and automatically load your key.&lt;br /&gt;
# Press &amp;quot;Next&amp;quot;.  Enter a name and press &amp;quot;Finish&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Thanks to [http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/pka-putty.html the University of Alberta] for this tip.&lt;br /&gt;
&lt;br /&gt;
== FileZilla ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
You can use SFTP from the command line, or you can use any GUI file transfer client.  All FTP clients I have seen also support SFTP.  One popular FTP client is [http://www.filezilla-project.org/ Filezilla].&lt;br /&gt;
&lt;br /&gt;
# Download and install FileZilla from http://filezilla-project.org/download.php?type=client&lt;br /&gt;
#: If you are using a lab computer, you can save it to your H drive.&lt;br /&gt;
# When you launch FileZilla, go to Edit→Settings or FileZilla→Preferences, and go to the SFTP options (under Connection).  Click &amp;quot;Add keyfile…&amp;quot;.&lt;br /&gt;
#* '''Windows users:''' Choose the *.ppk file that you made earlier using Puttygen.&lt;br /&gt;
#* '''Unix users:'''&lt;br /&gt;
#*# Choose your ''id_rsa'' file.   '''OS X Tip:''' Press Shift+Command+Period to reveal hidden files in the file chooser window.&lt;br /&gt;
#*# FileZilla will want to make a *.ppk file.  A good place to save it would be the .ssh directory as ''id_rsa.ppk''.&lt;br /&gt;
#: When finished, press '''OK''' (not the red ×) to save your changes.&lt;br /&gt;
# Back on the main FileZilla screen, there are four fields: Host, Username, Password, and Port.  Fill them in as follows:&lt;br /&gt;
#* '''Hostname:''' sftp://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/&lt;br /&gt;
#* '''Username:''' The username you created on your server.&lt;br /&gt;
#* '''Password:''' Since you are using a key, you may leave this blank.&lt;br /&gt;
#*: If you changed your SSH settings to allow password-based authentication, then you could put your password in here.&lt;br /&gt;
#* '''Port:''' 22&lt;br /&gt;
# Then click Quickconnect.  If everything is configured correctly, FileZilla should log into your server.&lt;br /&gt;
&lt;br /&gt;
[[File:FileZilla.png]]&lt;br /&gt;
&lt;br /&gt;
On the left and right of the FileZilla window, you can drag files between your computer and your server.  Thus, you can edit a file in a text editor like Notepad++ on your decktop, and then upload it to your server by simply dragging it from the left pane to the right pane in FileZilla.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Komodo Edit ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
[[File:Komodo.png|200px]]&lt;br /&gt;
&lt;br /&gt;
This semester in CSE 330, we will be using Komodo Edit as our editor of choice.  We chose this editor because:&lt;br /&gt;
&lt;br /&gt;
# It is free for everyone.&lt;br /&gt;
# It runs on Windows, Mac OS X, and Linux.&lt;br /&gt;
# It supports all of the languages we will be using in this class.&lt;br /&gt;
# It has a decent amount tools like auto-completion that will speed up your workflow.&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
Komodo Edit is already installed on the CEC lab machines.  If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== SSH Access ===&lt;br /&gt;
&lt;br /&gt;
You can configure Komodo Edit to connect to your EC2 instance (to implement option 1 in the flowchart above) .  However, because of a buggy and incomplete implementation in Komodo, '''this is not recommended or required for the purposes of CSE 330.'''  For the brave-hearted, instructions can be found here: [[Komodo Edit with SSH Access]]&lt;br /&gt;
&lt;br /&gt;
== Starting a Project ==&lt;br /&gt;
&lt;br /&gt;
Start a new Komodo Project whenever you start a new assignment.&lt;br /&gt;
&lt;br /&gt;
# Create a repo on Bitbucket and clone it to your local machine.&lt;br /&gt;
# In Komodo, choose '''Project -&amp;gt; New Project''' (or press shift-ctrl-N).&lt;br /&gt;
# Navigate to the cloned directory, enter a name for the project (e.g., ''Module2Group.komodoproject''), and press &amp;quot;Save&amp;quot;.&lt;br /&gt;
# You should now see a window like this:&lt;br /&gt;
#: [[File:Workflow-1.png]]&lt;br /&gt;
# Press ctrl-N (or cmd-N) to create a new file.  Save it in your project.  For example, you could create a page named ''index.html'' with the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy Page Layout]]:&lt;br /&gt;
#: [[File:Workflow-2.png]]&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X).  Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down.  For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.&lt;br /&gt;
&lt;br /&gt;
When you are ready, use FileZilla to upload your files to your server via SFTP.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2599</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2599"/>
		<updated>2019-01-13T01:48:47Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Windows Users Only: Enable Windows Subsystem for Linux (WSL) or Install Cygwin ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need WSL or Cygwin in order to log into and configure your EC2 instance. Cygwin is already installed on the CEC machines. If you're using Windows 10, you can use WSL, which is an officially-supported way of accessing a Linux terminal on Windows. If not, you'll have to use Cygwin. Instructions for installing either on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through a package manager, like '''yum'''.  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn about the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Setup a repo using the CSE 330 Repo Creation Tool&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to BitBucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions with floating point numbers (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your individual repo with the the link to your calculator.''''' See the Creative Portion section for more information about .md files.&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module and all future modules will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn the material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2598</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2598"/>
		<updated>2019-01-13T01:39:19Z</updated>

		<summary type="html">&lt;p&gt;Andrew: /* SFTP Integration (Shipping files to your server) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
&lt;br /&gt;
# First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
# Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
# Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
# Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
# To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
# Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/public_html/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=PHP&amp;diff=2597</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=PHP&amp;diff=2597"/>
		<updated>2019-01-13T01:37:50Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PHP is an open-source language used widely for writing server-side code for web servers.  PHP is a good starting point for web developers, as it is straightforward to learn and yet powerful at the same time.  Indeed, some of the internet's most popular web sites (including Facebook and Wikipedia) are written using PHP as their language of choice!  This article introduces the syntax of PHP and how to make a basic PHP web application.&lt;br /&gt;
&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=mac_pc&lt;br /&gt;
|id=934&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== What is PHP? ==&lt;br /&gt;
&lt;br /&gt;
PHP is a server-side scripting language widely used in web development.  PHP is what turns your web site from a static fileserver into a dynamic web application.&lt;br /&gt;
&lt;br /&gt;
By default, Apache only knows how to serve static HTML pages to the client.  You can write as many HTML pages as you want, which is fine for basic web sites.  But if you want to have users post to a forum, or process credit card transactions, or make your own online calendar, a server-side language like PHP is what you need.&lt;br /&gt;
&lt;br /&gt;
=== Document Generation Language ===&lt;br /&gt;
&lt;br /&gt;
If PHP's original core purpose had to be described in three words, it would be this: '''document generation language'''.  Unlike languages including Java, Ruby, Python, and Perl, which consist of classes in a strict program layout, PHP code is most often embedded inside a template document.  When the PHP interpreter runs, it &amp;quot;fills in the gaps&amp;quot; and generates a finished product document.&lt;br /&gt;
&lt;br /&gt;
This isn't to say that PHP can ''only'' be a document generating language, because this is certainly not true.  However, for the purposes of Module 2, it is safe to think of it this way when you are learning the concepts behind a web server.&lt;br /&gt;
&lt;br /&gt;
==== MIME Types ====&lt;br /&gt;
&lt;br /&gt;
By default, PHP generates HTML documents.  (Recall that an HTML document is simply a block of text consisting of markup conforming to the HTML standard.)&lt;br /&gt;
&lt;br /&gt;
However, PHP does not need to generate HTML documents.  It can also generate images, PDFs, or any other type of document.  Each of these document types has its own unique markup language.  The markup language used by a certain document is defined by its ''MIME Type''.&lt;br /&gt;
&lt;br /&gt;
The HTML MIME Type is '''text/html'''.  Other MIME Types include '''image/jpeg''', '''image/png''', and '''application/xml'''.&lt;br /&gt;
&lt;br /&gt;
To change the MIME Type of the document generated by PHP, use the statement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
header(&amp;quot;Content-Type: image/jpeg&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since PHP generates HTML documents by default, you can think of there being an implicit &amp;lt;code&amp;gt;header(&amp;quot;Content-Type: text/html&amp;quot;);&amp;lt;/code&amp;gt; at the top of every PHP script.&lt;br /&gt;
&lt;br /&gt;
=== PHP and Apache ===&lt;br /&gt;
&lt;br /&gt;
When you request a PHP file over Apache, the file is ''not'' sent verbatim.  Instead, it is first sent through the PHP interpreter.  Here is an oversimplified schematic of the process:&lt;br /&gt;
&lt;br /&gt;
[[File:PHP-Apache_Flowchart.png]]&lt;br /&gt;
&lt;br /&gt;
In summary, here are some points to keep in mind.&lt;br /&gt;
&lt;br /&gt;
# A PHP file on your server is not an HTML document.  It is a PHP script.&lt;br /&gt;
# PHP generates documents.  By default, it generates HTML documents.&lt;br /&gt;
# PHP can generate other document types by changing the MIME Type in the Content-Type HTTP Header.&lt;br /&gt;
# Apache runs the PHP interpreter on your PHP script before transmitting it to the browser.  The content that is generated after the PHP interpreter runs is expected to match the MIME type: by default, an HTML document.&lt;br /&gt;
# The W3C Validator checks for valid markup in an HTML document.  Everywhere that PHP generates an HTML document, that HTML document should be valid.&lt;br /&gt;
&lt;br /&gt;
== Installing PHP ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
To install PHP 7, you need both the PHP interpreter and the Apache module that runs PHP code. Run the following command to install both&lt;br /&gt;
  sudo yum install -y php70&lt;br /&gt;
&lt;br /&gt;
Once you install the required packages, [[Web Server Configuration#Restarting Apache and Testing|restart Apache]] for the changes to take effect.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== PHP Configurations ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
The PHP configuration file is called ''php.ini''.  In RHEL, it is located at ''/etc/php.ini''.&lt;br /&gt;
&lt;br /&gt;
The configuration file is largely self-documenting as to what the different options mean.  There is one value in particular that we want to change for the purposes of CSE330.  Open php.ini in your favorite text editor, find the '''display_errors''' option, and set it to '''On''':&lt;br /&gt;
&lt;br /&gt;
 display_errors = On&lt;br /&gt;
&lt;br /&gt;
You will need to restart Apache for any php.ini changes to take effect.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You can turn errors on or off for a certain PHP script by using the '''error_reporting()''' and/or '''ini_set()''' functions.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you tell PHP to log its errors, they will be stored in the Apache error log file, at ''/var/log/httpd/error_log''.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Your First PHP Script ==&lt;br /&gt;
&lt;br /&gt;
By default, all files that have the *.php extension will be interpreted as containing PHP code.  &lt;br /&gt;
All files with PHP need to be saved as '.php'; not '.html'.&lt;br /&gt;
Here is the most basic PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save that code into a file named phpinfo.php, and save it in your web server directory.  Load it up in your browser like this: ''http://ec2-blah-blah.compute-1.amazonaws.com/phpinfo.php''&lt;br /&gt;
&lt;br /&gt;
If you see something like this, your PHP installation is working!&lt;br /&gt;
&lt;br /&gt;
[[Image:Php_info.png]]&lt;br /&gt;
&lt;br /&gt;
Look at the source code of that page.  Notice that even though there were only three lines of code in our PHP file, PHP filled it up with hundreds of lines of HTML!&lt;br /&gt;
&lt;br /&gt;
Your own PHP scripts will probably look something more like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
	&amp;lt;title&amp;gt;My First PHP Script&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo &amp;quot;\t&amp;lt;p&amp;gt;Hello World!&amp;lt;/p&amp;gt;\n&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code will send the following HTML to the browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
	&amp;lt;title&amp;gt;My First PHP Script&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;Hello World!&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here's the take-home message of this section.  To run PHP code, enclose it in &amp;lt;code&amp;gt;&amp;lt;?php  ?&amp;gt;&amp;lt;/code&amp;gt; tags; HTML code can be used in a PHP file (although not inside the PHP code block!); and just a few lines of code can generate an arbitrary amount of HTML.&lt;br /&gt;
&lt;br /&gt;
== PHP Language Components ==&lt;br /&gt;
&lt;br /&gt;
PHP is a programming language much like others you have learned: it has variables, arrays, functions, objects etc.  However, the syntax for PHP and the way PHP handles variables may be new to you.  This section gives an overview of PHP the language.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
All variables start with the currency '''$''' symbol.  The '''$''' is necessary for both setting and accessing.&lt;br /&gt;
&lt;br /&gt;
PHP is a weak-typed language; that is, you can set any type of value to a variable (string, array, number, etc), and PHP will accept it, even if that variable previously contained a different data type.  In some ways this is convenient, but in others it can lead to hard-to-detect bugs, so be careful.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$i = 5;  # Set the integer 5 to the variable $i&lt;br /&gt;
$msg = &amp;quot;Hello World&amp;quot;;  # Set the string Hello World to the variable $msg&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that all lines in PHP necessarily end with a semicolon.  If you forget a semicolon, the PHP will fail to parse!&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
Strings in PHP can be either single-quoted or double-quoted.  Single-quoted strings are always taken literally; double-quoted strings allow for additional elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$a = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$b = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits_double = &amp;quot;$a\n$b&amp;quot;;   # $fruits_double now contains the string Apple (line break) Banana&lt;br /&gt;
$fruits_single = '$a\n$b';   # $fruits_single now contains the string $a\n$b&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to use special characters in a double-quoted strings, escape them using the backslash operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$a = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$b = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits = &amp;quot;\$a\\n$b&amp;quot;;   # $fruits now contains the string $a\nBanana&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can concatenate multiple strings together using the concatenation operator, which in php is a period:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$c = &amp;quot;Cherry&amp;quot;;&lt;br /&gt;
$g = &amp;quot;Grapefruit&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits = $c.&amp;quot;\n&amp;quot;.$g;   # $fruits contains the string Cherry (line break) Grapefruit&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
Declaring arrays is very simple in PHP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$fruits = array(&amp;quot;Apple&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Cherry&amp;quot;, &amp;quot;Grapefruit&amp;quot;);   # $arr now contains an array with 4 items&lt;br /&gt;
&lt;br /&gt;
echo $fruits[1];   # displays Banana&lt;br /&gt;
&lt;br /&gt;
echo count($fruits);   # displays 4&lt;br /&gt;
&lt;br /&gt;
array_shift($fruits);   # remove the first element of the array&lt;br /&gt;
&lt;br /&gt;
echo $fruits[1];   # displays Cherry&lt;br /&gt;
&lt;br /&gt;
echo count($fruits);   # displays 3&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: '''echo''' outputs a string to the browser.  We will see more ways to output data [[#Outputting Data|later in this guide]].&lt;br /&gt;
&lt;br /&gt;
PHP also supports ''associative arrays''.  Associative arrays are arrays whose keys are strings rather than numbers; in some languages, they are called Dictionaries.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$fruits[&amp;quot;a&amp;quot;] = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;b&amp;quot;] = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;c&amp;quot;] = &amp;quot;Cherry&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;g&amp;quot;] = &amp;quot;Grapefruit&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
echo $fruits[&amp;quot;c&amp;quot;];   # displays Cherry&lt;br /&gt;
&lt;br /&gt;
$keys = array_keys($fruits);   # get an array containing indexed values of the fruits' keys&lt;br /&gt;
&lt;br /&gt;
echo $keys[3];   # displays g&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conditional Statements ===&lt;br /&gt;
&lt;br /&gt;
Conditional statements work similarly to how they do in other languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$grade = 85;&lt;br /&gt;
&lt;br /&gt;
if ($grade &amp;lt; 60) {&lt;br /&gt;
	echo &amp;quot;F&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 70) {&lt;br /&gt;
	echo &amp;quot;D&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 80) {&lt;br /&gt;
	echo &amp;quot;C&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 90) {&lt;br /&gt;
	echo &amp;quot;B&amp;quot;;&lt;br /&gt;
} else {&lt;br /&gt;
	echo &amp;quot;A&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP also supports switch statements, which are convenient for simplifying long if/elseif/else blocks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$food = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
switch ($food) {&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;Apple&amp;quot;:&lt;br /&gt;
case &amp;quot;Banana&amp;quot;:&lt;br /&gt;
case &amp;quot;Cherry&amp;quot;:&lt;br /&gt;
case &amp;quot;Grapefruit&amp;quot;:&lt;br /&gt;
	echo &amp;quot;You must like fruit!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
case &amp;quot;Broccoli&amp;quot;:&lt;br /&gt;
case &amp;quot;Spinach&amp;quot;:&lt;br /&gt;
	echo &amp;quot;You must like vegetables!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
default:&lt;br /&gt;
	echo &amp;quot;You don't like fruits or vegetables!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
&lt;br /&gt;
PHP supports several different kinds of loops, including while, for, and foreach:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
$i = 0;&lt;br /&gt;
while ($i &amp;lt; 5) {&lt;br /&gt;
	$mystring .= &amp;quot;Blah&amp;quot;;&lt;br /&gt;
	$i++;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   # displays BlahBlahBlahBlahBlah&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$myarray = array(&amp;quot;Apple&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Cherry&amp;quot;, &amp;quot;Grapefruit&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
# The following two loops are functionally equivalent.&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
for($i=0; $i&amp;lt;count($myarray); $i++){&lt;br /&gt;
	$mystring .= $i.&amp;quot;: &amp;quot;.$myarray[$i].&amp;quot;, &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   # displays 0: Apple, 1: Banana, 2: Cherry, 3: Grapefruit&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
foreach($myarray as $key =&amp;gt; $value){&lt;br /&gt;
	$mystring .= $key.&amp;quot;: &amp;quot;.$value;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   #displays 0: Apple, 1: Banana, 2: Cherry, 3: Grapefruit&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
&lt;br /&gt;
Just like with all modern programming languages, you can define your own functions with PHP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function add($x, $y){&lt;br /&gt;
	return $x + $y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
echo add(3, 5);   # displays 8&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A neat shortcut for PHP is that you can specify default parameter values directly in the argument list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function sayHello($name=&amp;quot;John Doe&amp;quot;){&lt;br /&gt;
	return &amp;quot;Hello, $name... how do you do?&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
echo sayHello(&amp;quot;Todd&amp;quot;);   # displays Hello, Todd... how do you do?&lt;br /&gt;
echo sayHello();   # displays Hello, John Doe... how do you do?&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Object-Oriented Programming ===&lt;br /&gt;
&lt;br /&gt;
PHP5 supports object-oriented programming, and many new libraries come as classes rather than simple functions.  Here is an example class definition:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class Food {&lt;br /&gt;
	protected $name;&lt;br /&gt;
	&lt;br /&gt;
	function __construct($name){&lt;br /&gt;
		$this-&amp;gt;name = $name;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	static function getDefinition(){&lt;br /&gt;
		return &amp;quot;Food is nourishment for carbon-based lifeforms.&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	function formatName(){&lt;br /&gt;
		return &amp;quot;Gotta love to eat &amp;quot; . $this-&amp;gt;name;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Fruit extends Food {&lt;br /&gt;
	function formatName(){&lt;br /&gt;
		return Food::formatName() . &amp;quot; (fruit)&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$fruit = new Fruit(&amp;quot;Cherry&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
echo $fruit-&amp;gt;formatName() . &amp;quot;\n&amp;quot;;   # displays: Gotta love to eat Cherry (fruit)&lt;br /&gt;
&lt;br /&gt;
echo Fruit::getDefinition() . &amp;quot;\n&amp;quot;;   # displays: Food is nourishment for carbon-based lifeforms.&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Things to notice:&lt;br /&gt;
&lt;br /&gt;
* All methods in a class must be preceded by the function keyword.&lt;br /&gt;
* Static methods require the '''static''' keyword&lt;br /&gt;
* Instance methods can refer to the current instance through the implicit variable '''$this'''&lt;br /&gt;
* To access properties and methods from an instance, use an arrow: '''$instance-&amp;gt;property'''&lt;br /&gt;
* To access static properties and methods from a class, use two colons: '''ClassName::StaticPropertyOrMethod'''&lt;br /&gt;
* Instances of classes are defined using the syntax '''$instance = new ClassName();''' like in Java&lt;br /&gt;
&lt;br /&gt;
== Outputting Data ==&lt;br /&gt;
&lt;br /&gt;
What's the point of a web language if we can't output data?  The most basic method for outputting data is using either the '''echo''' or '''print''' statement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo &amp;quot;Hello World&amp;quot;;   # outputs Hello World to the browser&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You often find yourself wanting to print all information associated with a variable for debugging purposes.  PHP provides the handy '''var_dump''' function for that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
var_dump($myvar);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Content Type ===&lt;br /&gt;
&lt;br /&gt;
PHP is just a factory for generating documents.  We've so far seen it create HTML documents, but it can just as easily create images, PDFs, or any other type of interpreted file format.  Each of these files formats has a '''MIME Type''' associated with it.  To specify a MIME type for a page served over HTTP, the &amp;lt;code&amp;gt;Content-Type&amp;lt;/code&amp;gt; header must be set.&lt;br /&gt;
&lt;br /&gt;
This brings up an important point.  '''Every PHP document has an implicit &amp;lt;code&amp;gt;Content-Type: text/html&amp;lt;/code&amp;gt; header.'''  This means that by default, PHP will generate HTML documents.  '''The MIME type for a document can be changed using the header() function:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header(&amp;quot;Content-Type: text/plain&amp;quot;);&lt;br /&gt;
echo time();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example creates a plain text file containing the current timestamp (number of seconds since January 1, 1970).&lt;br /&gt;
&lt;br /&gt;
For another application of the Content-Type header, see [[#Sending a File to the Browser]]&lt;br /&gt;
&lt;br /&gt;
=== sprintf() ===&lt;br /&gt;
&lt;br /&gt;
Code in PHP that outputs information can get very ugly.  Consider, for example, the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$medals = array(&lt;br /&gt;
	&amp;quot;United States&amp;quot; =&amp;gt; array(46, 29, 29),&lt;br /&gt;
	&amp;quot;China&amp;quot; =&amp;gt; array(38, 27, 23),&lt;br /&gt;
	&amp;quot;Russia&amp;quot; =&amp;gt; array(24, 26, 32)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
foreach($medals as $country =&amp;gt; $counts){&lt;br /&gt;
	echo &amp;quot;\t&amp;lt;tr&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($country).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[0]).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[1]).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[2]).&amp;quot;&amp;lt;/td&amp;gt;\n\t&amp;lt;/tr&amp;gt;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will generate the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;United States&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;46&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;29&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;29&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;China&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;38&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;27&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;23&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;Russia&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;24&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;26&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;32&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's not very clear, though, that this is what the PHP code is going to generate.  In particular, the ''echo'' line inside the ''foreach'' loop is 196 jumbled characters!&lt;br /&gt;
&lt;br /&gt;
'''sprintf()''' is a nifty PHP function (with roots in C) that allows us to clean up that code.  We get the same output as above if we use the following PHP instead:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$medals = array(&lt;br /&gt;
	&amp;quot;United States&amp;quot; =&amp;gt; array(46, 29, 29),&lt;br /&gt;
	&amp;quot;China&amp;quot; =&amp;gt; array(38, 27, 23),&lt;br /&gt;
	&amp;quot;Russia&amp;quot; =&amp;gt; array(24, 26, 32)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
foreach($medals as $country =&amp;gt; $counts){&lt;br /&gt;
	echo sprintf(&amp;quot;\t&amp;lt;tr&amp;gt;\n\t\t&amp;lt;td&amp;gt;%s&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t&amp;lt;/tr&amp;gt;\n&amp;quot;,&lt;br /&gt;
		htmlentities($country),&lt;br /&gt;
		$counts[0],&lt;br /&gt;
		$counts[1],&lt;br /&gt;
		$counts[2]&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code is more straightforward and self-explanatory than the first example, and it is also easier to edit and maintain.&lt;br /&gt;
&lt;br /&gt;
Here's how '''sprintf()''' works.  The first argument is a ''format string''.  A format string can contain ''conversion specifications'' for additional data that will be inserted into the format string.  The most common conversion specifications are:&lt;br /&gt;
&lt;br /&gt;
* '''%s''' for a string&lt;br /&gt;
* '''%d''' for a signed integer&lt;br /&gt;
* '''%u''' for an unsigned integer&lt;br /&gt;
* '''%f''' for a floating-point number&lt;br /&gt;
** '''%.2f''' for a floating-point number with 2 decimal places&lt;br /&gt;
* '''%%''' for a literal percentage sign&lt;br /&gt;
&lt;br /&gt;
For more detail on sprintf formats, refer to [http://us.php.net/sprintf the PHP documentation].&lt;br /&gt;
&lt;br /&gt;
The remaining arguments are the data that are inserted into each of the conversion specifications.  In the example above, there are four conversion specifications ('''%s''', '''%d''', '''%d''', and '''%d'''), so '''sprintf()''' takes 4 additional arguments after the format string.&lt;br /&gt;
&lt;br /&gt;
Note that we still need to sanitize string output (using '''htmlentities()''' ) when we are using '''sprintf()'''.  However, since our format string specifies integers for the remaining three arguments, '''sprintf()''' will take care of type casting, so we no longer need to worry about sanitizing the integers.&lt;br /&gt;
&lt;br /&gt;
An additional tip: '''printf()''' is a shortcut for '''echo sprintf()'''.  That is, the following lines are functionally equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$n = 12345.678;&lt;br /&gt;
printf(&amp;quot;%.2f\n&amp;quot;, $n); // prints 12345.68&lt;br /&gt;
echo sprintf(&amp;quot;%.2f\n&amp;quot;, $n); // also prints 12345.68&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Passing Variables ==&lt;br /&gt;
&lt;br /&gt;
Input values can be passed to a script either through the URL request line or through data submitted by a form. Built in arrays $_GET['var'] and $_POST['var'] return the value of ''var'' depending on the access method. As we will see in the next section, values can also be passed through session variables. Finally, you can use cookies to store and retrieve values. &lt;br /&gt;
&lt;br /&gt;
Note that upon submitting a form, the page specified in the form tag's action attribute is loaded (with variables sent via post or get).&lt;br /&gt;
&lt;br /&gt;
=== GET: Passing Variables via URL ===&lt;br /&gt;
&lt;br /&gt;
If you want to pass values in a URL, the format is &amp;lt;nowiki&amp;gt;''http://example.com/yourphpfile.php?var1=value1&amp;amp;var2=value2.....''&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP saves URL variables in the associative array '''$_GET'''.&lt;br /&gt;
&lt;br /&gt;
For example, the following PHP document would print a hello message according to a name given in the URL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Hello World&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$name = $_GET['name'];&lt;br /&gt;
&lt;br /&gt;
printf(&amp;quot;&amp;lt;p&amp;gt;Hello, %s; how do you do?&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
	htmlentities($name)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you access the URL like this: ''greeting.php?name=Alice'', it will show ''Hello, Alice; how do you do?''&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Before we output the name, we pass it through '''htmlentities()''', which sanitizes it for output to the HTML document.  This is necessary because if we displayed the name verbatim from the URL, the name could be ''anything'': that includes malicious code that could be run on a victim's computer!  You will learn more about this type of cyberattack, called '''Cross-Site Scripting''', in Module 4.  For now, just know that whenever you display anything to the end user, you need to pass it through '''htmlentities()'''.&lt;br /&gt;
&lt;br /&gt;
=== POST: Passing Variables via Form ===&lt;br /&gt;
&lt;br /&gt;
Another method for passing variables from page to page is by sending it via POST variables.  Like with GET, POST variables are saved in an associative array, this time named '''$_POST'''.&lt;br /&gt;
&lt;br /&gt;
Consider the following form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Hello World&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;info.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;firstnameinput&amp;quot;&amp;gt;First Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;firstname&amp;quot; id=&amp;quot;firstnameinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;lastnameinput&amp;quot;&amp;gt;Last Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lastname&amp;quot; id=&amp;quot;lastnameinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;birthyearinput&amp;quot;&amp;gt;Birth Year:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;number&amp;quot; name=&amp;quot;birthyear&amp;quot; id=&amp;quot;birthyearinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;strong&amp;gt;Gender:&amp;lt;/strong&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;male&amp;quot; id=&amp;quot;maleinput&amp;quot; /&amp;gt; &amp;lt;label for=&amp;quot;maleinput&amp;quot;&amp;gt;Male&amp;lt;/label&amp;gt; &amp;amp;nbsp;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;female&amp;quot; id=&amp;quot;femaleinput&amp;quot; /&amp;gt; &amp;lt;label for=&amp;quot;femaleinput&amp;quot;&amp;gt;Female&amp;lt;/label&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Send&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;reset&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information on the HTML markup in the above example, refer to [[HTML and CSS|the HTML and CSS guide]].&lt;br /&gt;
&lt;br /&gt;
This submits a form with POST data to '''info.php'''.  Inside '''info.php''', the provided values will be available in the associative $_POST array under the keys ''firstname'', ''lastname'', ''birthyear'', and ''gender''.&lt;br /&gt;
&lt;br /&gt;
To display the submitted input on a target page, '''info.php''' could contain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Person Information&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$first = $_POST['firstname'];&lt;br /&gt;
$last = $_POST['lastname'];&lt;br /&gt;
$birthyear = (int) $_POST['birthyear'];&lt;br /&gt;
$gender = $_POST['gender'];&lt;br /&gt;
$age = 2012 - $birthyear;&lt;br /&gt;
&lt;br /&gt;
printf(&amp;quot;&amp;lt;p&amp;gt;Hello, %s %s!  You were born in %d, so you are %d years old.  You are %s.&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
	htmlentities($first),&lt;br /&gt;
	htmlentities($last),&lt;br /&gt;
	$birthyear,&lt;br /&gt;
	$age,&lt;br /&gt;
	htmlentities($gender)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' It is ''very'' important that you always sanitize strings that you output to the browser using '''htmlentities()''' or a similar function.  If you don't, your site will be vulnerable to all sorts of malware.  For more information, refer to the [[Web Application Security, Part 1|Web Application Security]] guide.&lt;br /&gt;
&lt;br /&gt;
For further help with using HTML forms with PHP, we recommend [http://www.tizag.com/phpT/forms.php this tutorial].&lt;br /&gt;
&lt;br /&gt;
=== Self-Submitting Forms ===&lt;br /&gt;
&lt;br /&gt;
Oftentimes we don't want to pass form values to a different page, but rather to the same page as contains the form so that we can process the information and display output on that same page.  To do this, you can simply omit the '''action''' parameter from the form.  Alternatively, you can use a PHP environment variable like $_SERVER['PHP_SELF'].&lt;br /&gt;
&lt;br /&gt;
The following example simply takes the data input from a form and, via POST variables, echoes it back to the user as bold text on the same page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Bold Printer&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&amp;gt;&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;name&amp;quot;&amp;gt;Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;name&amp;quot; id=&amp;quot;name&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Print in Bold&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if(isset($_POST['name'])){&lt;br /&gt;
	printf(&amp;quot;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;%s&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
		htmlentities($_POST['name'])&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
If you need to keep track of information associated with a user between page loads, you should use a ''session''.  Sessions are excellent for keeping track of the currently-logged-in user, for example.&lt;br /&gt;
&lt;br /&gt;
PHP makes session management dirt simple.  Whenever you need to use session variables, simply call '''session_start()'''.  Then, you may interact with the $_SESSION associative array, and PHP will take care of accessing and saving all session variables for you!&lt;br /&gt;
&lt;br /&gt;
For example, the following page will display a number, and then double that number on each page reload:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
 &lt;br /&gt;
$oldnum = (int) @$_SESSION['inc_num'];&lt;br /&gt;
if($oldnum&amp;lt;1) $oldnum=1;&lt;br /&gt;
$newnum = $oldnum*2;&lt;br /&gt;
 &lt;br /&gt;
echo $newnum;&lt;br /&gt;
$_SESSION['inc_num'] = $newnum;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sessions also work across different pages, as long as they are on the same web server.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To log out a user, you can call '''session_destroy()''' after '''session_start()''' on the logout page.&lt;br /&gt;
&lt;br /&gt;
== Other PHP Tips ==&lt;br /&gt;
&lt;br /&gt;
=== Redirecting to a Different Page ===&lt;br /&gt;
&lt;br /&gt;
If you want to redirect the user to a different page, you need to send a '''Location''' header.  For example, a page containing only this code would redirect the user to the ''login.php'' file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header(&amp;quot;Location: login.php&amp;quot;);&lt;br /&gt;
exit;   // we call exit here so that the script will stop executing before the connection is broken&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is often useful to perform redirects after you perform server-side operations.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' You should generally not leave a user sitting on a page that has POST data, because if they refresh the page, their POST data will be submitted again, causing your server to perform an action twice.  Rather, you should perform the operation, and then redirect them to another page that does not contain POST data in the header.&lt;br /&gt;
&lt;br /&gt;
=== Reading a File Line-by-Line ===&lt;br /&gt;
&lt;br /&gt;
If you want to read a file line-by-line, open a file handler using '''fopen()''', use '''fgets()''' to read lines until you've reached the end, and then close the file using '''fclose()'''.&lt;br /&gt;
&lt;br /&gt;
The following example reads '''file_with_lines.txt''' and outputs its content in an unordered list, where each list item is a line in the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$h = fopen(&amp;quot;file_with_lines.txt&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
$linenum = 1;&lt;br /&gt;
echo &amp;quot;&amp;lt;ul&amp;gt;\n&amp;quot;;&lt;br /&gt;
while( !feof($h) ){&lt;br /&gt;
	printf(&amp;quot;\t&amp;lt;li&amp;gt;Line %d: %s&amp;lt;/li&amp;gt;\n&amp;quot;,&lt;br /&gt;
		$linenum++,&lt;br /&gt;
		fgets($h)&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
echo &amp;quot;&amp;lt;/ul&amp;gt;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
fclose($h);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Most files in Linux end with an empty line, so the very last iteration of the above loop will output an empty bullet point.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The function '''fgets()''' reads the contents of a line ''in addition to the line feed at the end of the line''.  If you want to compare a string to the line that was read by '''fgets()''', you need to pass the value returned by '''fgets()''' to a function like '''[http://php.net/trim trim()]'''.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to read an entire file, PHP provides the '''file_get_contents()''' function, which is basically a shortcut for '''fopen()''', '''fread()''', and '''fclose()'''.  ('''fread()''' is similar to '''fgets()''', except it reads the entire file instead of just one line.)&lt;br /&gt;
&lt;br /&gt;
=== Sending a File to the Browser ===&lt;br /&gt;
&lt;br /&gt;
Another useful function to know is the '''readfile''' function. It takes a file on the webserver's file system and sends it to the web browser. A simple example is given below, but note that you'll probably need to specify addition header fields in order to have the web browser download the file correctly.&lt;br /&gt;
&lt;br /&gt;
The following example loads a file associated with a certain username and displays it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
&lt;br /&gt;
$filename = $_GET['file'];&lt;br /&gt;
&lt;br /&gt;
// We need to make sure that the filename is in a valid format; if it's not, display an error and leave the script.&lt;br /&gt;
// To perform the check, we will use a regular expression.&lt;br /&gt;
if( !preg_match('/^[\w_\.\-]+$/', $filename) ){&lt;br /&gt;
	echo &amp;quot;Invalid filename&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Get the username and make sure that it is alphanumeric with limited other characters.&lt;br /&gt;
// You shouldn't allow usernames with unusual characters anyway, but it's always best to perform a sanity check&lt;br /&gt;
// since we will be concatenating the string to load files from the filesystem.&lt;br /&gt;
$username = $_SESSION['username'];&lt;br /&gt;
if( !preg_match('/^[\w_\-]+$/', $username) ){&lt;br /&gt;
	echo &amp;quot;Invalid username&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$full_path = sprintf(&amp;quot;/srv/uploads/%s/%s&amp;quot;, $username, $filename);&lt;br /&gt;
&lt;br /&gt;
// Now we need to get the MIME type (e.g., image/jpeg).  PHP provides a neat little interface to do this called finfo.&lt;br /&gt;
$finfo = new finfo(FILEINFO_MIME_TYPE);&lt;br /&gt;
$mime = $finfo-&amp;gt;file($full_path);&lt;br /&gt;
&lt;br /&gt;
// Finally, set the Content-Type header to the MIME type of the file, and display the file.&lt;br /&gt;
header(&amp;quot;Content-Type: &amp;quot;.$mime);&lt;br /&gt;
readfile($full_path);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Uploading a File ===&lt;br /&gt;
&lt;br /&gt;
Uploading files is similar to submitting data in forms.  For starters, you need a form that submits to your uploading script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form enctype=&amp;quot;multipart/form-data&amp;quot; action=&amp;quot;uploader.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;MAX_FILE_SIZE&amp;quot; value=&amp;quot;20000000&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;uploadfile_input&amp;quot;&amp;gt;Choose a file to upload:&amp;lt;/label&amp;gt; &amp;lt;input name=&amp;quot;uploadedfile&amp;quot; type=&amp;quot;file&amp;quot; id=&amp;quot;uploadfile_input&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Upload File&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that we need to specify &amp;lt;code&amp;gt;enctype=&amp;quot;multipart/form-data&amp;quot;&amp;lt;/code&amp;gt; on the form.  This is to enable files to be uploaded and recognized by PHP.&lt;br /&gt;
&lt;br /&gt;
PHP puts all files submitted with a form into the '''$_FILES''' superglobal array.  Each entry in the $_FILES array contains the following information:&lt;br /&gt;
&lt;br /&gt;
* '''$_FILES['uploadedfile']['name']''' is the original name of the file on the client's machine&lt;br /&gt;
* '''$_FILES['uploadedfile']['type']''' is the MIME type of the file according to the browser (don't take it for granted)&lt;br /&gt;
* '''$_FILES['uploadedfile']['size']''' is the size, in bytes, of the uploaded file&lt;br /&gt;
* '''$_FILES['uploadedfile']['tmp_name']''' is the temporary location on your filesystem where Apache saved the uploaded file&lt;br /&gt;
* '''$_FILES['uploadedfile']['error']''' is the error code associated with the file upload (if applicable)&lt;br /&gt;
&lt;br /&gt;
To upload the file submitted by the form above in a user's special folder, we could use the following PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
&lt;br /&gt;
// Get the filename and make sure it is valid&lt;br /&gt;
$filename = basename($_FILES['uploadedfile']['name']);&lt;br /&gt;
if( !preg_match('/^[\w_\.\-]+$/', $filename) ){&lt;br /&gt;
	echo &amp;quot;Invalid filename&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Get the username and make sure it is valid&lt;br /&gt;
$username = $_SESSION['username'];&lt;br /&gt;
if( !preg_match('/^[\w_\-]+$/', $username) ){&lt;br /&gt;
	echo &amp;quot;Invalid username&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$full_path = sprintf(&amp;quot;/srv/uploads/%s/%s&amp;quot;, $username, $filename);&lt;br /&gt;
&lt;br /&gt;
if( move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $full_path) ){&lt;br /&gt;
	header(&amp;quot;Location: upload_success.html&amp;quot;);&lt;br /&gt;
	exit;&lt;br /&gt;
}else{&lt;br /&gt;
	header(&amp;quot;Location: upload_failure.html&amp;quot;);&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' A lot of the code above is the same as the code in the file download example.  In your project, you should save the logic of generating the file path (in a function) in a third file that you include into the upload and download scripts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' By default, PHP will not allow a file upload of more than 2 MB.  SitePoint has an excellent tutorial for how to increase this limit: http://www.sitepoint.com/upload-large-files-in-php/&lt;br /&gt;
&lt;br /&gt;
== PEAR ==&lt;br /&gt;
&lt;br /&gt;
The PHP Extension and Application Repository, or '''PEAR''', is a package manager that enables you to install classes and/or extensions to PHP.  In other words, it is a yum/apt for PHP.  You can think of PEAR as PHP's analog of ''gem'' in Ruby or ''pip'' in Python.&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
PEAR is available through both the yum and apt repositories under the package name '''php-pear'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo yum install php-pear  # in RHEL&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installing PHP Extensions ===&lt;br /&gt;
&lt;br /&gt;
Using PEAR to install PHP extensions is just as easy as yum, apt, gem, and pip.  Just run '''sudo pear install xxx'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo pear install Archive_Tar&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go here for a list of available packages in PEAR: http://pear.php.net/packages.php&lt;br /&gt;
&lt;br /&gt;
=== Using PHP Extensions ===&lt;br /&gt;
&lt;br /&gt;
To make use an extension installed in PEAR, you must '''include''' or '''require''' it into the PHP file of interest.  For example, if you wanted to use the Archive_Tar class from the above example in a PHP file, you would do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require &amp;quot;Archive/Tar.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// your code here&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By convention, the filepath you need to specify is the name of the PEAR package with underscores replaced with slashes and a .php extension at the end.  For example, the package ''Console_Getargs'' becomes &amp;lt;code&amp;gt;require &amp;quot;Console/Getargs.php&amp;quot;;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PECL ===&lt;br /&gt;
&lt;br /&gt;
The PHP Extension Community Library, or '''PECL''', is a repository for additional PHP extensions, the difference being that PECL extensions are written in compiled C code rather than PHP.&lt;br /&gt;
&lt;br /&gt;
PECL is installed automatically when you install PEAR from yum or apt-get.&lt;br /&gt;
&lt;br /&gt;
Installing an extension using PECL is almost identical to PEAR, except that you use '''pecl''' instead of '''pear''' on the command prompt:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo pecl install imagick&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You do not need to '''require''' or '''include''' PECL extensions since they are already compiled into PHP.&lt;br /&gt;
&lt;br /&gt;
== PHP Reference ==&lt;br /&gt;
&lt;br /&gt;
If you ever have a question about PHP, first check the well-written documentation.  To skip immediately to the documentation on any function, simply visit &amp;lt;nowiki&amp;gt;http://php.net/&amp;lt;/nowiki&amp;gt;'''functionname'''.  For example: http://php.net/var_dump&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Amazon_Web_Services&amp;diff=2596</id>
		<title>Amazon Web Services</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Amazon_Web_Services&amp;diff=2596"/>
		<updated>2019-01-13T01:19:56Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Amazon Web Services provides a method to publish web sites on virtual machines in the &amp;quot;cloud.&amp;quot;  In CSE330, you will be using an EC2 instance to host your web site.&lt;br /&gt;
&lt;br /&gt;
Before reading this guide, you should be familiar with Linux and the various distributions of Linux.  Fore more information, refer to [[Linux#Linux Distributions|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
== Creating and Configuring your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Follow these steps to get to the AWS Management Console:&lt;br /&gt;
&lt;br /&gt;
# Create an AWS account: http://aws.amazon.com/&lt;br /&gt;
# Sign up for the EC2 Web Service: http://aws.amazon.com/ec2/&lt;br /&gt;
# Log in to the AWS Management Console&lt;br /&gt;
&lt;br /&gt;
To create your new virtual machine, click '''Launch Instance'''.  Do the following to configure your instance:&lt;br /&gt;
&lt;br /&gt;
# Use the Classic Wizard.&lt;br /&gt;
# Please... Just please choose distribution of Linux labeled &amp;quot;Amazon Linux AMI&amp;quot;.  For more information on distributions, refer to [[Linux#Linux Distributions|the Linux guide]].&lt;br /&gt;
[[File:Aws-ami.png|600px|center]]&lt;br /&gt;
# The default instance variables are all fine.  Click Continue until you get to the &amp;quot;Create Key Pair&amp;quot; screen.&lt;br /&gt;
# Create a new Key Pair.  Enter some name for it, and then click &amp;quot;Create &amp;amp; Download your Key Pair&amp;quot;.  '''Save your key somewhere secure.'''  In addition to using it to authenticate for this instance, you will be able to use the same key for additional instances.&lt;br /&gt;
# Create a new Security Group and connect it to your server.  The security groups you create determine whether a port is open or blocked for your server.&lt;br /&gt;
#* You need to open the SSH port on your server.  To do this, select &amp;quot;SSH&amp;quot; from the drop-down box, and then click &amp;quot;Add Rule.&amp;quot;&lt;br /&gt;
#: We will be opening more ports by modifying the security group at a later time.  Click Continue.&lt;br /&gt;
# You are now ready to launch your virtual server!  Click Launch.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Starting and Stopping your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
You can start and stop your instance by right-clicking on the instance.  The options are down in the &amp;quot;Instance Lifecycle&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
=== Amazon EC2 Gives You One Free Micro Instance ===&lt;br /&gt;
&lt;br /&gt;
It is free to keep '''''one''''' micro instance running at all times.  Keeping your instance running around the clock will make your life easier, because then you won't need to always change your hostname in your SSH clients.&lt;br /&gt;
&lt;br /&gt;
For additional Micro instances, or for larger instances, you will be charged hourly for their use.  One non-free Micro instance costs about $14/month; a Small instance costs about $43/month.&lt;br /&gt;
&lt;br /&gt;
=== Terminate vs Stop ===&lt;br /&gt;
&lt;br /&gt;
Never &amp;quot;terminate&amp;quot; your instance, as this PERMANENTLY DELETES the instance! Any time you are done using the instance you should instead &amp;quot;stop&amp;quot; the instance and then when you are ready to resume work you should &amp;quot;start&amp;quot; the instance.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Frequently committing your work to your repository is a safety net in case something horrible happens to your instance.&lt;br /&gt;
&lt;br /&gt;
== Enabling Web Access to your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you have configured [[Apache]] (which you will do later in this Module), you will need to open up your EC2 instance to web traffic.  (By default amazon blocks all traffic to our instance.)&lt;br /&gt;
&lt;br /&gt;
Go to the Security Groups under Network &amp;amp; Security on the EC2 webpage. Select your security group, click on the Inbound Tab. Add a new Custom TCP rule with a Port range of 80.  Leave the Source at 0.0.0.0/0 (for all traffic). Click Add Rule, and then click Apply Rule Change.&lt;br /&gt;
&lt;br /&gt;
To make sure things are working, create a file, like '''hello.txt''', in your web server root.  Give it some content (might I suggest &amp;quot;Hello, world!&amp;quot;). The web server root is at /var/www/html&lt;br /&gt;
&lt;br /&gt;
For more information on editing files on the command line, refer to [[Linux#File Editors|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
You should now be able to visit your server load up the file using your web browser!  Example Link: http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com/hello.txt&lt;br /&gt;
&lt;br /&gt;
NOTE:depending on the city in which your server is located, your link might look like:&lt;br /&gt;
&lt;br /&gt;
http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/hello.txt&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=File:Aws-ami.png&amp;diff=2595</id>
		<title>File:Aws-ami.png</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=File:Aws-ami.png&amp;diff=2595"/>
		<updated>2019-01-13T01:14:26Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2594</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2594"/>
		<updated>2019-01-13T01:08:17Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
&lt;br /&gt;
# First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
# Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
# Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
# Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
# To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
# Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the SFTP integration working well, you don't need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2593</id>
		<title>Module 1</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2593"/>
		<updated>2019-01-13T01:05:26Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 1 introduces the fundamentals of HTML and CSS.  You will first make a static document using HTML and CSS, and then you will make a portal to a DuckDuckGo search.  This module is worth 50 points.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
* [[Git]]&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
* [[VS Code]]&lt;br /&gt;
&lt;br /&gt;
== Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Write a Birthday Card ===&lt;br /&gt;
&lt;br /&gt;
'''Write a birthday card to a friend or family member using HTML and CSS.'''  Use HTML to define the content of the card (like the headings and the paragraphs), and use CSS to define the appearance.  Some ideas:&lt;br /&gt;
&lt;br /&gt;
* Make the background-color of the page baby blue and use purple ink to write a card to a little boy&lt;br /&gt;
* Make the text big and include pictures of hearts&lt;br /&gt;
* Use a font with text shadows (more advanced)&lt;br /&gt;
&lt;br /&gt;
Use this opportunity to experiment with the plethora of CSS properties.  Remember that you're in a computer science class (not an art class), so we don't care if your card looks ugly.  The main thing is that you learn HTML and CSS and use them appropriately.&lt;br /&gt;
&lt;br /&gt;
==== How to Edit Your File ====&lt;br /&gt;
&lt;br /&gt;
Throughout this course we '''highly''' recommend using VS Code https://code.visualstudio.com/download, and have included tips for each module specific to VS Code.&lt;br /&gt;
Visit the wiki page [[VS Code]] and check out the Module 1 section&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  You need a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// and https:// protocols.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validators for both HTML and CSS with no errors.'''  You can upload your HTML to [https://validator.w3.org/ the HTML validator] and your CSS to [https://jigsaw.w3.org/css-validator/ the CSS validator].&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page. In this HTML document you must also include this course's regrade policy to ensure that you have read it and understand it. [https://www.arl.wustl.edu/~todd/cse330/info.html Regrade Policy]&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
- Additionally, we want you to copy/paste this course's regrade policy somewhere into this html document to ensure your familiarity.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments (including code) must be committed to Bitbucket by the end of class on the due date. Commit early and often. Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a separate stylesheet and link your HTML file to it.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for HTML 5 and CSS. (10 points).&lt;br /&gt;
# '''Search Portal (10 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (9 points).&lt;br /&gt;
#* Your search portal page includes the text of this course's regrade policy (1 point).&lt;br /&gt;
# '''Account Creation and Version Control (10 Points):'''&lt;br /&gt;
#* Bitbucket account created (2 Points)&lt;br /&gt;
#* Module 1 repo created using the link provided on Piazza (2 Points)&lt;br /&gt;
#* Account created on Amazon Web Services and an image file containing a screenshot of your account page pushed to Bitbucket. (4 Points)&lt;br /&gt;
#* Files pushed to repo on Bitbucket using Git (2 Points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2592</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2592"/>
		<updated>2019-01-13T00:59:13Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Module 1 -- Using the Git Integration ==&lt;br /&gt;
&lt;br /&gt;
# First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
# Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
# Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
# Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
# To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
# Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the above integration working well, you don't necessarily need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2591</id>
		<title>VS Code</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=VS_Code&amp;diff=2591"/>
		<updated>2019-01-13T00:56:07Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started With Each Module ==&lt;br /&gt;
&lt;br /&gt;
# Create Bitbucket repo using the CSE 330 repo creator  (Check Piazza for the link)&lt;br /&gt;
# Navigate to the created repo in Bitbucket&lt;br /&gt;
# Clone the repo via https to a dedicated folder on your computer&lt;br /&gt;
&lt;br /&gt;
[[File:File-Structure.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
# In VS Code, File &amp;gt; Open the Spring2019-module1-individual-STUDENTID '''folder''' that you cloned to your computer&lt;br /&gt;
&lt;br /&gt;
If you followed the above steps correctly, the folder's Git should be configured to your Bitbucket repository!  I highly recommend creating your bitbucket repo, cloning the folder to a designated spot, and keeping all modules separated for the semester as shown in the image above.&lt;br /&gt;
&lt;br /&gt;
== Using the Git Integration (Module 1 example) ==&lt;br /&gt;
&lt;br /&gt;
# First, open the File Explorer tab on the left, and right click to create a new file, birthday.html&lt;br /&gt;
# Ensure VS Code has it marked as an html file (see the file type next to the smiley face)&lt;br /&gt;
# Type '''doc''' followed by enter, and allow VS Code to generate a basic HTML file for you (use VS Code to your advantage! It can do a lot of your coding for you).&lt;br /&gt;
# Save the file, you should see a popup next to the Version Control symbol on the left. VS Code has detected that your project is different than what it is in your remote Bitbucket repo.&lt;br /&gt;
# To commit, simply type a message in the box and click the check mark above it.  To push to your bitbucket repo, click the 3 dots next to the check mark and select 'push'&lt;br /&gt;
# Note this is also where you can pull from your remote.&lt;br /&gt;
&lt;br /&gt;
==== Bonus - Module 1 ====&lt;br /&gt;
# If you like your text editor to look pretty, you can go to the Extensions tab and search for different themes. (Check out the Material theme!)&lt;br /&gt;
# You can view your settings by clicking CMD + , (Mac) or Ctrl + , (Windows).  Search for Theme and choose one that works for you!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Module 2 == &lt;br /&gt;
=== SFTP Integration (Shipping files to your server) ===&lt;br /&gt;
# Open the Extensions tab and search for 'sftp'. Download the first one.&lt;br /&gt;
# To use commands in VS Code, type '''Cmd + Shift + P''' (Mac), or '''Ctrl + Shift + P''' on windows. &lt;br /&gt;
#Type SFTP and open the sftp config command. &lt;br /&gt;
&lt;br /&gt;
Your config should look like the following:&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;protocol&amp;quot;: &amp;quot;sftp&amp;quot;,&lt;br /&gt;
    &amp;quot;host&amp;quot;: &amp;quot;YOUR.EC2.DNS&amp;quot;,&lt;br /&gt;
    &amp;quot;port&amp;quot;: 22,&lt;br /&gt;
    &amp;quot;username&amp;quot;: &amp;quot;YOUR USERNAME&amp;quot;,&lt;br /&gt;
    &amp;quot;privateKeyPath&amp;quot;: &amp;quot;/path/to/your/id_rsa&amp;quot;,&lt;br /&gt;
    &amp;quot;remotePath&amp;quot;: &amp;quot;/home/YOUR USERNAME/module2&amp;quot;,&lt;br /&gt;
    &amp;quot;uploadOnSave&amp;quot;: true&lt;br /&gt;
  }&lt;br /&gt;
- Note the uploadOnSave field is optional, but can be nice!&lt;br /&gt;
- Check the VS Code output for errors in your config.&lt;br /&gt;
&lt;br /&gt;
Additionally: You should notice an SFTP tab on the side of VS Code. Here, you can view the file structure on your server.&lt;br /&gt;
&lt;br /&gt;
=== Testing Everything Locally ===&lt;br /&gt;
If you get the above integration working well, you don't necessarily need to set up a local php server.  If you can't get the above working, however, we highly recommend coding all of your projects locally, and only uploading them to your ec2 instance when complete.&lt;br /&gt;
&lt;br /&gt;
'''To run PHP locally'''&lt;br /&gt;
&lt;br /&gt;
'''Windows'''&lt;br /&gt;
# Download WAMP (https://sourceforge.net/projects/wampserver/)&lt;br /&gt;
# Place your project repositories in Wamp's www/ directory, and navigate to http://localhost in your browser.  You should see your projects listed here, and should be able to run php files.&lt;br /&gt;
&lt;br /&gt;
'''Mac'''&lt;br /&gt;
# Download Homebrew. Homebrew is a great package manager for OSx and we will be using it in future modules. &lt;br /&gt;
# Type the following in your terminal and follow instructions &lt;br /&gt;
  /usr/bin/ruby -e &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&amp;quot;&lt;br /&gt;
# In your terminal, type '''php -v'''. If your version is less than 7, update with brew. '''brew install php'''&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=File:File-Structure.png&amp;diff=2590</id>
		<title>File:File-Structure.png</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=File:File-Structure.png&amp;diff=2590"/>
		<updated>2019-01-13T00:55:06Z</updated>

		<summary type="html">&lt;p&gt;Andrew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Andrew</name></author>
		
	</entry>
</feed>