CS637 Development Setup: on Linux at cs.umb.edu and on your home machine, Spring 2016

We will use topcat.cs.umb.edu, a Linux server, for any development work done at cs.umb.edu, since it is a system with PHP and the Apache web server installed, as well as mysql. We do have another such system, pe07.cs.umb.edu, as backup in case of trouble with topcat: you should be able to log in there as well. Most development work for this course will be done on your own system.

Using PHP on topcat.cs.umb.edu:
 On topcat, you should not need to do any setup to use php.  To check that php is in /usr/bin as expected, use the which command as follows:

topcat$ which php
/usr/bin/php
topcat$ #To check its version, use php -v
topcat$ php -v
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
Linux at cs.umb.edu:  editors  Hopefully you know emacs or vi or another Linux editor.  You can display a text file with cat or more.

We will do most of our software development on PCs, and then test the systems on Linux as well as PC.  This works well because of the robust portability of PHP.  Project deliveries are to the Linux filesystem. See AccessToCSHosts.html for more info on file transfers.

Home System Software Setup

For logging in to cs.umb.edu systems from home systems and transferring files, see AccessToCSHosts

Browser: covered in Appendixes. We will use Chrome as the default browser. Please install it if you don't have it already.

Text Editor: mostly covered in Appendixes
XAMPP: see Appendices. Note that the current XAMPP distributions have version numbers equal to their PHP versions, for example, 5.6.11.  We need 5.5 or later.
mysql: Note that phpMyAdmin is just a GUI for mysql. We can do everything we need with mysql by using mysql commands from the command line, once the initial setup is complete.  That's a good thing since we won't have phpMyAdmin for topcat's mysql.  In fact, we can do the password change (part of the setup) in command-line mysql: from http://dev.mysql.com/doc/refman/5.6/en/set-password.html
$mysql -u root -p
Enter password: xxxx     (just carriage return if root has null password)
mysql> SET PASSWORD = PASSWORD('cleartext password');     (usually typed in lowercase) mysql> exit
Note: to enable command-line mysql access, add xampp's mysql/bin directory to your Path, as discussed below under System Search Path.

Linux systems only: MySQL still has some problems with case-sensitive identifiers (table names, database names). By the SQL standard, all database identifiers are caseless, but by default on Linux and other UNIX (but not MacOSX) systems, mysql database identifiers (table names, database names, but not column names) are case-sensitive. I have overridden this bad behavior on topcat by setting lower_case_names = 1 in /etc/mysql/my.cnf. If you have a Linux development system, add this line to mysql/bin/my.ini.

IDE: Netbeans, see Appendices of text. You can download a version of Netbeans that can handle Java as well as PHP and HTML5 if you wish.

System Search Path

We would like to be able to use mysql and php on the command line. This means editing the PATH environment variable as detailed below.

The environment variable PATH holds the search path used by the system (Windows, Linux, or MacOSX)  to locate executables. When we add a new executable located in a directory not listed in PATH, we need to add its directory to PATH, so we can run the program from anywhere on the system. How to do this depends on the system as follows.

For a Windows machine: Use System Control Panel>Advanced>Environment Variables to add and change enviroment variables. There is a shortcut method to get to this control panel, as follows. Click the Start button, fill in "env" in the text box, and click on "Edit Environmant Variables for your account". In this control panel, edit the Path variable and add \xampp\mysql\bin;\xampp\php. Use a semicolon between entries in the value of Path. For example, my Path value has c:\Program Files\emacs\bin; c:\xampp\mysql\bin;c:\xampp\php  Test the environment variables by creating a new command window and using the path command. Also the mysql and php commands.

For a Linux machine: It should work to add the environment variables to .profile (or .bashrc possibly or .bash_profile, non-Ubuntu Linux) in your home directory. For example, suppose XAMPP is in /opt/lampp, the default as indicated on pg. 847. Check this by "ls /opt" to see lampp as a directory and then "ls /opt/lampp" to see what's in it. Then you  need to add /opt/lampp/mysql/bin and /opt/lampp/php to PATH.

Suppose the old PATH (reported by echo $PATH) is :/usr/local/bin:/bin:/usr/bin  Add this line to .profile:

   export PATH=$PATH:/opt/lampp/mysql/bin;/opt/lampp/php

Note the colons between directories on the PATH, vs. semicolons for the Windows PATH. This should be executed when you open a new shell window, but if that doesn't work, you can execute it explicitly by source .profile.

Test the environment variables by creating a new shell window and using the env command. Also the mysql and php commands.

For a MacOSX machine: See http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/ (Use the .bash_profile method. It isn't clear that paths.d is supported on all Mac versions.) Instead of "vi", the UNIX editor, use TextWrangler, to edit ~/.bash_profile. That's the file .bash_profile in your home directory, reachable by "cd" from any directory.

First check that XAMPP is at /Applications/XAMPP, by using "ls /Applications/X*" for example.

From the Terminal application, MacOSX works very much like Linux, except that .profile is called .bash_profile. Put the following line in .bash_profile in your home directory, creating a new file if necessary:

 export PATH=$PATH:/Applications/XAMPP/mysql/bin:/Applications/XAMPP/php

Change this as necessary to refer to wherever you found the mysql and php executables. Test the environment variables by logging out and in again and using the env command. Also try the mysql and php commands.

Possible Problem with mysql: The mysql of XAMPP uses the default mysql port number of 3306. It is possible that one of your earlier-installed applications is already using mysql with this port, causing a conflict that will prevent both from running at the same time. If mysql won't run, reboot your computer and then (before starting XAMPP) use  netstat -a|grep 3306 on Mac or Linux and netstat -a|find "3306" on Windows.  If you see a line like this (may show localhost:3306):

TCP    0.0.0.0:3306           computername:0                LISTENING

then you know that there is another mysql on your system.  Look in your startup apps area for possible culprits, that is, programs that need to keep track of data. Uninstall any that you can live without. If you really need the other app, you can change the port for XAMPP's mysql by editing its configuration file. You can find this file by using XAMPP's control panel and selecting mysql and clicking the Config or Configure button.