RU beehive logo ITEC dept promo banner
ITEC 325
2017spring
ibarland

homelectshws
D2Lbreeze (snow day)

running-php-on-rucs
running php on rucs
(not using a web server)

We will look at:

video from distance lecture (breeze), 2017-jan-24b (0h30m): syllabus-review; running php @ 0h21m

Reviewing a few linux commands

You'll want to be familiar with the main options for the following:

If you want to brush up (or, learn) basic unix, this is a good tutorial (sections 1,2 on using teh command-line for file basics, and section 5 for file permissions).

Accessing rucs

Before we even revisit the code, let's talk about the machine rucs.radford.edu (“radford university computer science”): it's a machine for use by ITEC department students, and is a compute-server which you can access from anywhere.

How to log on to rucs, so that you can run php on it:
First, start the VPN, if you are off campus. Then, either use ssh yourUserName@rucs.radford.edu or run putty. Note that if rucs is down, then ruacad.radford.edu can also be used.

Be aware: rucs is not the campus web server, nor the php server! You don't have accounts on those machines (although your H: drive is shared by those machines). In particular: the version of php you run from rucs's command-line is slightly different than the version run by php.radford.edu !-o

Running PHP from the command line

Once logged on to rucs, it is straightforward to run a php program:

However, this raises the question of how to get your php program-files onto your H: drive in the first place.

How to edit files on rucs

Either

I do not suggest editing the file locally, and then scp’ing them over after each edit.

Note that if you have your own computer and have installed XAMP, it includes a PHP interpreter (that's the ‘P’ in “XAMP”). So you may find it easy to
However, you'll still need to know how to connect to rucs and run php there: the reason is that the rather-quite-old version of PHP installed on rucs is much closer to the old version of PHP used by php.radford.edu. So when debugging, you'll want to be able to run PHP using the exact H: files and the similar php version as the web server uses.


splitting into multiple files

We can take blend.php (src), and separate the code from the test-cases: utils.php (src), and separately utils-test.php (src). The directive require-once is a run-time instruction which just goes to the require'd file and (effectively) splices it into the current file, and continues evaluating line-by-line. (So it's reminiscent of java's import, but require-once significantly more simple-minded. Beware trampling on identifiers, and it's poor practice to have any dangling tags / code in the require'd file.)

This also lets us separate a program that uses blend from the test cases: some-web-page.php (src), and some-web-page.php (output).



Running a php file via the web

Note:We won't demo this in class yet, since it is not required for hw01. (And hw01 doesn't do this because it's important to be able to run your php programs without using the web at all, for debugging purposes.)

Recall that when a web-server gets a request, it decides how to respond. For php.radford.edu, some of the configuration rules:

Let's put our php program on the web!


XHTML

xhtml: Even though original HTML doesn't require the following, they are best practices, and they are required for this class:

See also:

homelectshws
D2Lbreeze (snow day)


©2017, Ian Barland, Radford University
Last modified 2017.Mar.18 (Sat)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.