RIT NSSA 714 (Adv Large-Scale Computing)
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Lab 2 links and tips

Go down

Lab 2 links and tips Empty Lab 2 links and tips

Post by Alex Cohen Wed Feb 17, 2016 3:01 pm

This one is tough and it requires you to know MySQL and know a lot about either PHP or Python to do it.  So learn one of those full languages in about a week before you have to hand this thing in no pressure.  But really its not that hard, here's a video that will teach you about everything you need to know about python to get started and its only 40 min long, go through this and in two days you'll be ready and there's one on MySQL too:


Here's how to do it with PHP also if you would rather do that:


I did this whole lab on ubuntu machines in python (I don't know php) so if you want to do this in php ignore what I'm saying.

First create two servers one with apache2 and another with MySQL Server.

In python there is a concept called Python CGI that lets you use python scripts as web pages (essentially doing the same thing as php).  You can use python cgi to get info from a web page, put it in a python script and use python to talk to the MySQL database.  

To get some working python CGI check out this link, it will tell you how to install CGI properly and then you will want to scroll down to the part of this link that says "Simple FORM Example:GET Method" and essentially copy and paste that stuff to start off your web pages. http://www.tutorialspoint.com/python/python_cgi_programming.htm

Next I had to get the servers talking to each other so info could be transferred over to the database and I did that ... with TCP clients and servers.  In python its really not that bad, you don't have to do any multithreading or complex class and error handling like you do in java or c++, but it can still be a pain if you don't know what your doing.  Here's a good video on learning how to use TCP with python:

Also here are a few TCP scripts to play around with one set of them sends and receives data on the local machine, the other is designed to work in a lan between two computers.
https://app.box.com/s/sxfp4yl1d4ln9bhh7gbr4142vatmajfg

Last you have to talk to the database.  There's a python package called mysqldb that lets you use python to input code to a mysql database. You can install this in ubuntu by using this command:

sudo apt-get install python2.7-mysqldb

For a simple expanation on how to use it for our purposes go to this link and scroll to "Step 5 — Testing the Final Product"
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-apache-mysql-and-python-lamp-server-without-frameworks-on-ubuntu-14-04

Alex Cohen
Admin

Posts : 8
Join date : 2016-01-04

https://ritnssa714.board-directory.net

Back to top Go down

Lab 2 links and tips Empty Re: Lab 2 links and tips

Post by Alex Cohen Tue Apr 19, 2016 3:22 pm

UPDATE: here's a better way to get the servers talking if you are working in AWS

So the best way to get the servers to talk to each other is not through networking its thought the mysql client.  On you web server machine install the mysql client with the command:

sudo apt-get install mysql-client-core-5.5

To get your python script to talk to the mysql server use the package MYSQLdb as I said before you install it with:

sudo apt-get install python2.7-mysqldb

Here's a tutorial on using it:


Then what you will want to do is use an AWS RDS for your database, its the first option under the database tools in the AWS main console.  Make sure its in a security group that allows incoming traffic through port 3306.

Then when you make your python MYSQLdb script use the endpoint address of your RDS (you will see it when you click on it) as the address in your connection function like this:

conn = MySQLdb.connect(host = "myRDSname.cxxxxsdfasdbxo.us-east-1.rds.amazonaws.com", user = "alex", passwd = "mypassword", db = "lab2")

Alex Cohen
Admin

Posts : 8
Join date : 2016-01-04

https://ritnssa714.board-directory.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum