Friday, March 27, 2009

LIS 9710 Posts

Posts from 9710



Just to keep everything in the one place and because we won't use the other thing again.

Portable Apps for Mac



The portable apps environment we have been using in class is only for windows but FreeSMUG (the free software mac users group) page now has a portable apps environment and downloads for osx.



The page is at: http://www.freesmug.org/portableapps



Most of the applications are the same open source ones such as Audacity, Firefox, VLC etc - which is good because you can have cross-platform coverage. However, there are some very interesting appz like:



Cletx - http://celtx.com/overview.html is media pre-production software for the entire pre-production process - write scripts, storyboard scenes and sequences, develop characters, breakdown & tag elements, schedule production etc.

as well as the mac only appz like ical and ichat.



Installing Drupal on Ubuntu - part 1



In the past installing drupal was very difficult as you had to install apache, php,mysql separately and set them up and then install drupal.



I just found out in ubuntu 8.10 there is an entry for Drupal5 in the synaptic package manager. So with the shiny new frankencomputer i decided to give it a whirl.

I selected the package and it install LAMP (minus phpmyadmin, i think) and asks a couple of questions such as setting up a mysql root password etc.



It does not seem to create a menu item or link anywhere. There is an index.html file created in var\www which can be viewed from http://127.0.0.1 to prove LAMP is running but where is the drupal admin page located?

looks like /usr/share where apache2 is, which has a folder called default-site with the index.html ‘it works’ page.

the user/share/drupal5 folder has the index.php page and the install.php page.

Do we have to set up a virtual directory in apache to tell it to use this? Time to RTFM i guess…This is probably why we ended up using Joomla.

XAMPP Tutorial NotesJanuary 20, 2009

Installing Configuring and Developing With XAMPP



NOTE: The article says to start and stop processes by running start and stop.bat files, this is for installed versions. Since we are using XAMPP as a portable application do not use those files to start and stop the servers. Use the XAMPP control panel.



PHP Hello World



PHP is the programming language in LAMP. We will write a small program as an example using Notepad.





Note that php code begins with a bracket and p plus a question mark and lines of php code end with a semi-colon and the php code ends with a ?> and that the file must have a .php extension.



Only files with .php are executed, files with .htm or .html are ignored and passed straight to the web server for sending to the user’s browser.



Save the file with a filename of helloworld.php to your USB stick in the xampp\htdocs folder.



Create a Database and Insert Data



Click the back arrow of your web browser to return to the XAMPP screen



Under Tools, click phpMyadmin



Type in addressbook as the database and click CREATE



Type colleague as the table name with 5 fields and click GO



When creating the id field select the radio button under the primary key icon



When alll 5 fields are defined click SAVE (we might decide to make email or phone allow null values)



NOTE: this page shows you the actual SQL used to create the table. Copy this code to your session log or diary that you are keeping in Notepad.



It also has a create PHP code button that will provide the code to create the table from PHP.Copy the PHP code to your notepad session log/diary.



Click on the INSERT menu item at the top of the page.



Select Restart Insertion and select 5 Rows from the dropdown menu



Add the data as shown in the handout by clicking on the text box in the Value column.



DO NOT add a value for the primary key as this has been set to autonumber.



Entering data into mySQL with myPHPadmin



Once the data for the 5 records has been typed in click the GO button on the bottom of the page to insert all 5 records.



Copy the SQL statement into your diary in notepad.



Note that how the first field inserted is just the name of the field with



no specified value - the database will automatically assign id numbers for each record. You might also want to click CREATE PHP code and copy that code to your diary.



Click the BROWSE menu item at the top of the screen to see the data in the database. Note the id numbers.



Write the PHP program



Switch over to Notepad and create a new document and type the code:



// connect and select a database


mysql_connect(”localhost”,”root”,”");

mysql_select_db(”addressbook”);

// Run a Query

$result = mysql_query(”SELECT * FROM colleague”);


mysql_connect connects the web server to the database and requires a host address, username, and password(our mysql database does not have a password yet - it is blank thus the “”)mysql_select_db selects a database and requres a database name (a database server can have many databases) mysql_query sends a SQL statement to the database server and returns a result.

We are also using a variable called $result to hold the results of the query. Variables in PHP are indicated by a dollar sign $. A variable is a container that can hold anything we want (sort of like tupperware!).



Home PC Kills Apache - Skype is the culprit

January 29, 2009

Some students have reported that the XAMPP control panel runs apache and mysql but then the servers quit.

As it turns out this is due to a decision by Skype to use PORT 80 as a secondary PORT for communicating with their Main Server. Port 80 of course is the standard port for web traffic and so Skype and Apache collide.

There are a number of possible solutions:

Start Skype, selecting TOOLS, OPTIONS, Connections and un-check the use of PORT 80 as an alternative port for incoming calls. Then close and re-open Skype. XAMPP should now run.

The second solution is to change the port on which Apache operates. In a related post we detailed how to edit the httpd.conf file for Apache to can tell Apache to “listen”only on 127.0.0.1 and the same approach can be done to get apache to listen on another port. Change the Listen line from using 80 to 8080 and then restart Apache after saving the configuration file. The only problem with this is instead of typing in the regular http://localhost/ as the address, you’ll have to type in http://localhost:8080/

Some have asked what is a port? We will cover in class next week but you might want to see:

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

If you are using VISTA you probably have worse problems. You might try this video:

http://www.youtube.com/watch?v=owVu-ZpLrZc

Changing Apache to only use Localhost

February 4, 2009

Some windows configurations will block XAMPP, specifically the Apache web server on port 80. Most people use hardware firewalls on their routers instead of the windows firewall but if you have windows security problems the following may help:

You can change the Apache web server so that it is ‘bound’ only to the loopback network interface known as localhost which has an IP address of 127.0.0.1

To do this:

  1. Insert your XAMPP usb stick
  2. Goto the xampp\apache\conf folder
  3. Select the httpd.conf file and right-click
  4. Select Copy from the menu
  5. Select Edit, Paste or press CTRL C to make a backup copy of the Apache configuration file
  6. Now select httpd.conf, right-click and choose Edit from the menu
  7. Scroll down the file and find the Listen section, which looks like this:

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the
# directive.

Find the line with Listen 80 and put a # in front of it to turn it into a comment. Type in a new line:

Listen 127.0.0.1:80

and select File, Save from the menu. This means the Apache web server will only listen for requests coming from localhost, the machine you are on - not for requests coming over the network or internet. This is how it should be for a development environment. We were going to cover this in the session on security but it might help those who are having trouble running XAMPP under specific windows setups.


Home PC Kills Apache - Skype is the culprit

January 29, 2009

Some students have reported that the XAMPP control panel runs apache and mysql but then the servers quit.

As it turns out this is due to a decision by Skype to use PORT 80 as a secondary PORT for communicating with their Main Server. Port 80 of course is the standard port for web traffic and so Skype and Apache collide.

There are a number of possible solutions:

Start Skype, selecting TOOLS, OPTIONS, Connections and un-check the use of PORT 80 as an alternative port for incoming calls. Then close and re-open Skype. XAMPP should now run.

The second solution is to change the port on which Apache operates. In a related post we detailed how to edit the httpd.conf file for Apache to can tell Apache to “listen”only on 127.0.0.1 and the same approach can be done to get apache to listen on another port. Change the Listen line from using 80 to 8080 and then restart Apache after saving the configuration file. The only problem with this is instead of typing in the regular http://localhost/ as the address, you’ll have to type in http://localhost:8080/

Some have asked what is a port? We will cover in class next week but you might want to see:

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers


XAMPP and PHP Sessions

February 27, 2009

We assign a php session variable with:

$_SESSION['UserID'] = $Username;

and later check it with:

if (isset($_SESSION['UserID']))

but it does not work. We check it out with echo but it is always empty. This is odd as the same code works perfectly on the web server running WAMP.

The WAMP server is php4 and the XAMPP usb stick is PHP 5. Maybe we should add:

session_write_close();

To the program.

The other possibility is that windows security is to blame - this morning after another reboot for an update the trend anti-virus software quarantined the ATI control panel as it is a risk as well as the Snagit screen capture software. Soon you won’t be able to run any applications on windows…

Found a post where the user edited php.ini and changed line #839 from:

;session.save_path = /tmp

to

session.save_path = /tmp

save and restart php. I don’t think that is the problem as i checked the xampp\tmp directory and found the session file. It has the correct contents:

UserID|s:1:”5″;

so why is the code not working?

No comments: