A Database-Driven Web Application in 18 Lines of Code
Maypole interacts directly with Apache through mod_perl. To work with Apache 2, a development library called libapreq2 needs to be fetched from the CPAN repository and installed into Perl. I downloaded libapreq2-2.04_03-dev.tar.gz from CPAN. Prior to installing the library, I upgraded the ExtUtils::XSBuilder module that ships with Perl. A single command, issued as root, suffices:
perl -MCPAN -e "install ExtUtils::XSBuilder"
If this is the first time the CPAN shell has executed, you'll be prompted to configure the local CPAN module. Be sure to select follow when asked about fetching prerequisite modules. With the module upgraded, I installed the libapreq2 library with the usual set of Perl module installation commands:
tar zxvf libapreq2-2.04_03-dev.tar.gz cd libapreq2-2.04-dev/ perl Makefile.PL make make test su make install <Ctrl-D>
The actual installation of Maypole starts by invoking the CPAN shell as root:
perl -MCPAN -e "shell"
As Maypole depends on a large collection of prerequisite CPAN modules, installation can take a while. Prior to actually asking the CPAN shell to install Maypole for you, issue the following commands to ensure that some of the more troublesome modules are dealt with:
cpan> install CGI::Untaint::date cpan> force install Class::DBI::mysql
I had to force the installation of Class::DBI::mysql as a number of tests failed, effectively aborting the automatic installation. By forcing the install, the broken tests are ignored, allowing the install to proceed. With the prerequisites dealt with, install Maypole with this CPAN command:
cpan> install Maypole
A series of automated interactions with the CPAN repository begin after this step. Keep an eye on what's going on, because at certain points, you have to respond to some self-explanatory prompts. When all was done and dusted, the most recent release of Maypole—2.04 at the time of this writing—was installed on my machine.
Returning to MySQL, I logged in as administrator and issued these commands to remove any default accounts:
mysql -u root -p mysql> use mysql; mysql> delete from user where User = ''; mysql> flush privileges;
I then created a new database, together with a user to act as owner of the data:
mysql> create database CLUB; mysql> grant all on CLUB.* to manager identified by 'passwordhere'; mysql> quit
These commands create the database, called CLUB, and add a user, called manager, to the database system. For the purposes of this article, this simple application manages data about an under-age soccer club. In addition to storing personal details about each player, the system maintains data on which players are in which squads, as well as any medical conditions players may have.
Here are the SQL files that I used to define the tables used within the CLUB database. The first file, create_player.sql, creates the player table:
create table player ( id int not null auto_increment primary key, name varchar (64) not null, date_of_birth date, address varchar (255), contact_tel_no varchar (64), squad int, medical_condition int );
The second file, create_squad.sql, creates the initial list of squads:
create table squad ( id int not null auto_increment primary key, name varchar (32) not null ); insert into squad (name) values ('--'); insert into squad (name) values ('Under 8'); insert into squad (name) values ('Under 9'); insert into squad (name) values ('Under 10'); insert into squad (name) values ('Under 11'); insert into squad (name) values ('Under 12');
The squad table is initialized to a reasonable set of default values. The third and final file, create_condition.sql, creates a list of possible medical conditions:
create table condition ( id int not null auto_increment primary key, name varchar (64) not null ); insert into condition (name) values ('--'); insert into condition (name) values ('Asthma'); insert into condition (name) values ('Epilepsy');
As with the squad table, the condition table is initialized with some default data. The data item in the squad and condition tables is called name. The significance of this point will be returned to later in this article.
Use the SQL files to create the tables within the database:
mysql -u manager -p CLUB < create_player.sql mysql -u manager -p CLUB < create_squad.sql mysql -u manager -p CLUB < create_condition.sql
As can be guessed, the CLUB database maintains data on players. Players belong to a squad and may have a medical condition.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- Stunnel Security for Oracle
- The Firebird Project's Firebird Relational Database
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- SUSE LLC's SUSE Manager
- Managing Linux Using Puppet
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Google's SwiftShader Released
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide