Wednesday, August 16, 2006

Apache and MySQL at system startup


Here is what I had to do to get MySQL and Apache to startup automatically on a Ubuntu 6.06 Linux system...

MySQL
-----------------------------------------
References Used
-----------------------------------------
http://www.adobe.com/devnet/dreamweaver/articles/lamp.html
http://dev.mysql.com/doc/refman/5.0/en/automatic-start.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-server.html
http://www.debian-administration.org/articles/28

-----------------------------------------
Changed in /etc/my.cnf (From MySQL site)
-----------------------------------------
[mysqld]
user=mysql

-----------------------------------------
Set startup item (From Dreamweaver site)
-----------------------------------------
# sudo cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
# sudo update-rc.d mysql defaults

Results of the update-rc.d command were as follows:
Adding system startup for /etc/init.d/mysql ...
/etc/rc0.d/K20mysql -> ../init.d/mysql
/etc/rc1.d/K20mysql -> ../init.d/mysql
/etc/rc6.d/K20mysql -> ../init.d/mysql
/etc/rc2.d/S20mysql -> ../init.d/mysql
/etc/rc3.d/S20mysql -> ../init.d/mysql
/etc/rc4.d/S20mysql -> ../init.d/mysql
/etc/rc5.d/S20mysql -> ../init.d/mysql


Apache
-----------------------------------------
References Used
-----------------------------------------
http://www.adobe.com/devnet/dreamweaver/articles/lamp.html

-----------------------------------------
From Dreamweaver site
-----------------------------------------
# sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apache
# sudo update-rc.d apache defaults

Results of the update-rc.d command were as follows:
Adding system startup for /etc/init.d/apache ...
/etc/rc0.d/K20apache -> ../init.d/apache
/etc/rc1.d/K20apache -> ../init.d/apache
/etc/rc6.d/K20apache -> ../init.d/apache
/etc/rc2.d/S20apache -> ../init.d/apache
/etc/rc3.d/S20apache -> ../init.d/apache
/etc/rc4.d/S20apache -> ../init.d/apache
/etc/rc5.d/S20apache -> ../init.d/apache

Saturday, August 05, 2006

Perl - Issues

Problems encountered on 2006-07-31:

1. Today, for some reason, we are seeing the variables being passed via GET in URLs. This actually sounds more normal, I guess the question is why it wasn't happening before??!!

Solution
- Started calling CGI scripts using:
exec ( "perl my.cgi @sendArgs" );
instead of:
print "Location:my.cgi?arg1=$val1\n\n";


2. IE during file upload
my $uploadFile = param( 'uploadFile' );
sends the entire path, not just the file name.
C:\path\dreaming.zip

Firefox just sends the filename.

Must support both situations.

Solution
Here is the file spec, which varies from IE to Firefox.
my $uploadFile = param( 'uploadFile' );

So I extract the file name
my @pathArr = split( /\\/, $uploadFile );
my $pathEltCnt = scalar( @pathArr );
my $fileName = $pathArr[$pathEltCnt-1];

Some functions need the file spec as provided by the browser, in whatever form.
my $uploadInfo = uploadInfo( $uploadFile );
my $uploadType = $uploadInfo -> { 'Content-Type' };

Note that for opening I use $fileName, but for actual reading I use the original file spec.
open ( UPFILE, "> $dirName/$fileName" ) || die("Cannot open($fileName): $!");
binmode( UPFILE );
my ( $data, $chunk );
my $fileSize = 0;
while ( $chunk = read ( $uploadFile, $data, 1024 ) ) {
print UPFILE $data;
$fileSize += $chunk;
}
close ( UPFILE ) || die("Cannot close($fileName): $!");