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

We will use pe07.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. Most development work for this course will be done on your own system.

Using PHP on pe07.cs.umb.edu:
 On pe07, 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:

pe07$ which php
/usr/bin/php
pe07$ #To check its version, use php -v
pe07$ php -v
PHP 7.0.33 ...
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 PC/Macs, and then test the systems on Linux.  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 of M&H

Configure it with the "XAMPP Shell" (command prompt). Open the shell from the XAMPP control panel and execute this command:mysqladmin -u root password secretThis sets the root password to 'secret', which is good enough for our purposes. Also put this string in the file phpMyAdmin/config.inc.php like this, to make the button on the control panel work:

$cfg['Servers'][$i]['password'] = 'secret';

XAMPP for Mac:  The obvious downloads for Mac XAMPP will install a VM for it that complicates development. To get a "native" XAMPP that works as described in the book, download xampp-osx-7.4.9-0-installer.dmg from here. I believe you can have both the VM version and the native version running on your system if you want, since they operate web servers on different effective systems.

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 pe07's mysql. 

Note: to enable command-line mysql and php access, add xampp's mysql/bin directory to your Path and xampp's bin directory, as discussed below under System Search Path.

Linux home 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 pe07 by setting lower_case_names = 1 in /etc/mysql/mysql.conf.d/mysqld.cnf. If you have a Linux development system, add this line to mysql/bin/my.ini.

IDE: Netbeans 8.2+ The Murach appendices are out of date on this install. If you already have Netbeans 8.2, you don't need to reinstall. If not, Google "netbeans install" and follow the download link to Apache NetBeans, choose the appropriate installer and follow its instructions.

System Search Path

We would like to be able to use mysql and php on the command line on development systems. 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.

PATH for a Windows machine: Find the environment variables by typing "env" in the search bar next to the start button and choose "Edit environment variables for your account".  Edit the Path environment variable to include \xampp\mysql\bin and \xampp\php. Test the environment variables by creating a new command window (type "cmd" in that same search bar) and using the "set" command. Right-click the icon of the cmd window and pin it to the taskbar for convenience in later use.

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:  Use "vi", the UNIX editor, already there, or use BBEdit (see above, needs download), 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 this 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.