Setting up C Programming in Linux for Ubuntu Linux 12.04 LTS

  • Download and Install Ubuntu 12.04 LTS
  • Install basic LAMP (Linux, Apache, MySQL, PHP) Web server
    • install tasksel sudo apt-get install tasksel
    • in a terminal type sudo tasksel to start the server installation utility
    • use space bar to select LAMP server
    • tab to Ok and hit return
    • when asked for mysql passwords do not enter anything, leave blank
    • type sudo apt-get install build-essential libgd2-xpm libgd2-xpm-dev apache2-prefork-dev libmysqlclient-dev
  • To configure Apache
    • make sure you have a public_html folder in your home area, if not, create one
    • create a cgi-bin folder inside this
    • in a terminal type sudo a2enmod userdir
    • edit apache config file: sudo gedit /etc/apache2/sites-available/default
    • change the ScriptAlias /cgi-bin/ entry to /home/your-user-name/public_html/cgi-bin/
    • change Directory to "/home/your-user-name/public_html/cgi-bin" my version loks like this:
      	ScriptAlias /cgi-bin/ /home/david/public_html/cgi-bin/
      	<Directory "/home/david/public_html/cgi-bin">
      		AllowOverride None
      		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      		Order allow,deny
      		Allow from all
      	</Directory>
      

      If the browser wants to download and save as files programs you want to run, check that the apache user configuration file ~/home/.htaccess does not contain any overriding options.

      If this isn't it ry adding an AddHandler and making sure all your cgi programs end with '.cgi'

      	ScriptAlias /cgi-bin/ /home/david/public_html/cgi-bin/
      	<Directory "/home/david/public_html/cgi-bin">
      		AllowOverride None
      		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      		AddHandler cgi-script .cgi
      		Order allow,deny
      		Allow from all
      	</Directory>
      

      In your Makefile mv hello3 ~/public_html/cgi-bin would become mv hello3 ~/public_html/cgi-bin/hello3.cgi

    • type sudo /etc/init.d/apache2 restart to restart the server
    • in a browser check that http://localhost is working
    • http://localhost/~yourubuntuusername is your home directory for web content
  • To configure MySQL
    • MySQL root user has NOTHING to do with the the system root user you become when you use "sudo.."
    • if you have no MySQL root password set, in a terminal type "mysql -u root mysql" to enter the MySQL system prompt
    • with a password set, type "mysql -u root-p mysql" and enter the password.
    • now you can configure the mysql configuration database itself
    • type: create database test;and hit return
    • type: grant all privileges on test.* to ' '@'localhost'; and hit return
    • type: flush privileges; and hit return
    • type: quit; and hit return
    • note that mysql commands end with a semi-colon ;
    • 	
      
      MySQL root user has NOTHING to do with the the system root user you become when you use "sudo.."