Tuesday, July 10, 2007

OpenBSD Tip: Installing MySQL Database Server

Installing the MySQL Database Server, in OpenBSD is needed for a number of different applications. Including Wordpress, which is what I have been playing with today.

Installing MySQL
First if you don't have PKG_PATH set then set this first, then install mysql-server. For a package server near you please see: FTP mirrors
# export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/
# pkg_add mysql-server

mysql-server-5.0.33:mysql-client-5.0.33: complete
mysql-server-5.0.33:p5-Net-Daemon-0.39: complete
mysql-server-5.0.33:p5-PlRPC-0.2018p0: complete
mysql-server-5.0.33:p5-DBI-1.53: complete
mysql-server-5.0.33:p5-DBD-mysql-3.0008: complete
mysql-server-5.0.33: complete


Configuring MySQL
The mysql-server package doesn't initialize a default database. The following command will create one:
# /usr/local/bin/mysql_install_db

Now we need to temporarily start mysql to set the root access password for the database. Changing 'new-password' to a password of your choosing.
# /usr/local/bin/mysqld_safe &
# /usr/local/bin/mysqladmin -u root password 'new-password'
# /usr/local/bin/mysqladmin -u root -p -h Your-server.name.tld password 'new-password'


Verify the server is running by using the 'fstat' in the following example:
# fstat | grep "*:" | grep mysql
_mysql mysqld 29321 15* internet stream tcp 0xd6121af4 *:3306

To start MySQL from boot, edit /etc/rc.conf.local:
# vi /etc/rc.conf.local
adding:
mysql=YES
Then edit: /etc/rc.local:
# vi /etc/rc.local
After the 'starting local daemons' and before the following echo '.' Insert the following into the /etc/rc.local file:

if [ X"${mysql}" == X"YES" -a -x /usr/local/bin/mysqld_safe ]; then

echo -n " mysqld"; /usr/local/bin/mysqld_safe --user=_mysql --log --open-files-limit=256 &

for i in 1 2 3 4 5 6; do
if [ -S /var/run/mysql/mysql.sock ]; then
break
else
sleep 1
echo -n "."
fi
done
#
# Apache chroot Settings

mkdir -p /var/www/var/run/mysql
sleep 2
ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock

#
# Postfix chroot Settings
if [ "X${postfix_flags}" != X"NO" ]; then
mkdir -p /var/spool/postfix/var/run/mysql
sleep 2
ln -f /var/run/mysql/mysql.sock /var/spool/postfix/var/run/mysql/mysql.sock
fi

fi

Now every time you restart; the machine will check to see whether you have enabled mysql in the rc.conf (rc.conf.local) file then start the mysql daemon. To disable mysql we can simply change mysql=YES to mysql=NO

After restarting verify the server is running again:
# fstat | grep "*:" | grep mysql
_mysql mysqld 29321 15* internet stream tcp 0xd6121af4 *:3306

Once the above startup script has worked you can change the mysqld_safe line to something like:
/usr/local/bin/mysqld_safe --user=_mysql --log --open-files-limit=1000 > /dev/null 3>&1 2>&1 &

For more information, and different configurations please see:

Using MySQL
MySQL security
Remove history
The MySQL history file ( /.mysql history), contains all executed SQL commands, even passwords, (which are stored as plain text). We can easily clear the contents of this file:
# cat /dev/null > /.mysql_history

Disable remote access
If you are only going to use MySQL on this server, (i.e. the database will be used only by locally installed applications) then you can disable remote access. MySQL listens on tcp port 3306, we can disable listening on the port by doing the following:

# vi /etc/my.cnf
add:
skip-networking

Improve local security
The next change is to disable the use of LOAD DATA LOCAL INFILE command, which will help to prevent against unauthorized reading from local files.
# vi /etc/my.cnf
add:
set-variable=local-infile=0

Change admin name
It is also recommended to change the default name of administrator’s account (root), to a different, and harder to guess one.

mysql> UPDATE USER SET user='dbadmin' WHERE user='root';
mysql> FLUSH PRIVILEGES;


Now you should have MySQL up and running on your OpenBSD server. Good luck, and have fun.

Sunday, July 08, 2007

OpenBSD Tip: Starting Apache

Apache is included in a basic install of OpenBSD. However it is not running by default. Starting Apache in OpenBSD is really easy. You can start the server manually or automatically.

Automatic: To start Apache every time the computer starts/restarts you need to do the following:

Edit /etc/rc.conf and change this line:
httpd_flags=NO
To read:
httpd_flags="" # note the use of two double-quotes
Then save the changes. When the computer is restarted, the Apache server (httpd) will automatically start.

Manual: To start Apache manually you need to run the following command:
# /usr/sbin/apachectl start
/usr/sbin/apachectl start: httpd started


Testing your Web Server: To test your webserver point your web browser to your servers IP address, or use lynx on the webserver like this:
# lynx localhost

[ lynx displays the following ...]
[OpenBSD]
Apache
It Worked!

If you can see this page, then the people who own this host have just
activated the Apache Web server software included with their OpenBSD
System. They now have to add content to this directory and replace this
placeholder page, or else point the server at their real content.
[ ... cut ... ]
The Document Root directory (the directory where all of the server's web pages are stored) is /var/www/htdocs. You can now place your web pages in this directory.

Virtualization using VirtualBox

For the past couple of days I have been playing around with VirtualBox.

VirtualBox is a family of powerful x86 virtualization products for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL).
VirtualBox
For more information please see: About VirtualBox.

VirtualBox 1.4.0 was realised on June 5, 2007 for Windows and Linux. It now contains support for 64bit Linux Hosts, as well as better networking and storage solutions, (for full details please see: Changelog.)

I have tried a earlier version of VirtualBox, but had limited success installing it. The new version installed perfectly.
I used Automatix in Ubuntu 7.04 ("Feisty Fawn") to install it. Yet there are many other binary versions, including a beta version for OS X, (Intel Macs only). For downloads please see: VirtualBox Downloads.

So far I'm very impressed with VirtualBox. In my opinion it's the best virtualization software I have tried to date. I've found it professional, and easy to use. I feel like the programmers have really thought about how to make this a good product from a user standpoint. Also it is OpenSource, what a wonderful bonus.

There are a number of problems, (to be expected with a new piece of software). Yet each time I have gone to write a bug report; the problem has either been fixed and is available in SVN (subversion) or it's currently being fixed. That impressed me.

Unfortunately there is a problem running OpenBSD, and NetBSD as vm's (virtual machines). Yet the issue has been solved in SVN.

I'm running a FreeBSD vm and it is beautiful. I thought I might have trouble as the machine I'm running it on only has 512MB of RAM, however it's been wonderful. I wouldn't recommend any less than 512MB though. When I close VirtualBox it cleans out the RAM amazingly well.

I will write more about it, when I can install some more virtual machines to play with. I'm intrigued to see if DragonflyBSD, and Slackware will work in it.

If you would like information on installing and using VirtualBox please see:You can download VirtualBox here: Downloading VirtualBox.

EDIT: As pointed out by one of my readers VirtualBox is actually released under two licences (dual licensing). There are two versions:
The Open Source Edition (OSE) is released under the GNU General Public License V2 and:
The full VirtualBox package, which is free of charge for personal use or evaluation purposes is released under the Personal Use and Evaluation License.
For more information please see: VirtualBox Licensing FAQ.

Friday, July 06, 2007

A fresh start

Now that I have realised that my lack of confidence isn't because of my own inadequacy, it's much easier to move on. I can't blame anyone else for my low self-esteem. For if I don't have confidence in myself no one else will.

I want to make a fresh start!

My partner and I are going to start our own business. We're heavily researching this topic. We want to go in with our eyes open. Having everything in place before jumping in. I'm so excited. I really think that this is going to be brilliant.

I didn't really want to have a job anyway. I was only after the experience in the industry. Yet after reading this article: 10 Reasons You Should Never Get a Job, I KNOW we can do this.

I have a new found drive to get on with my life. I'm sick of listening to the naysayers the critics. I'll never get anywhere if I keep allowing people to tell me I can't.

Pay no attention to what the critics say. A statue has never been erected in honour of a critic.
~Jean Sibelius
I'm only hurting myself! It will probably take me a while to not look at myself through others eyes. Yet if I don't start trying I will never get anywhere.

Thursday, July 05, 2007

Lack of confidence

I feel like I have had a massive wake-up call today. After reading the following article: Gender Differences: Recognizing and Developing Potential in Female Students. I realised many things about the way I have been feeling.

Before I went to TAFE Tasmania I knew what I knew. I was confident when it came to computing. I was actually proud of my abilities. If you know me; you'll know that's a pretty big deal.

After I started TAFE my confidence dropped. At times almost completely. I'm not even sure about something when I KNOW the answer. Pretty silly aye.

I feel like I was set-up to fail at TAFE. All the projects I was asked to do were impossible to pass. Even when I explained why they where impossible I was made to do them anyway.
What got me was the teachers were then shocked, and disappointed when I failed the tasks. In the end I was made to feel like I only graduated by the good graces of one of the teachers. I was shown over and over again that I couldn't compete in the IT industry, and that my skills where highly inadequate.

I don't know why they teach IT here in Tasmania, as there is NO IT industry, which kinda makes a Technical diploma mute. That probably makes my diplomas worthless. Yet I digress.

After reading this article I have realised that it's perhaps not my abilities at fault. Perhaps it is more that my confidence has taken a massive knock. Perhaps it is more the way that I learn, and how that has not been nourished.
I feel as though I have been letting all of this get to me so badly. At times I'm even worried to do things on my own network.

Also when I think back to my schooling, I might have let it get to me there as well. I am a very logical, and technically minded person. Yet I left college (Year 11 and 12 in Australia) thinking that I would be lucky if I was smart enough to even wash dishes.

Now I have a new outlook on all of this. I want to start believing in my abilities again. I want to find a way to build up my confidence. I know that it'll be hard. I probably need to achieve something small to help bring it back up.
Yet I am grateful that I have realised that it probably isn't my abilities, and knowledge. Maybe I can do this. I guess time will tell.

Wednesday, July 04, 2007

Ubuntu tip: Turning off tooltips

When you hover over anything in Ubuntu Yellow boxes pop-up (Tooltips) and give you information. Personally it bugs me really badly. If you are like me; turning them off is really simple.

Note: the quotation marks are not part of the names.

First right click on the "Applications" button in the top panel, then click "Edit Menus". e.g:


When the menu editor opens click "System Tools". In the right column you will see: "Configuration Editor" Tick the box next to it, and close the menu editor. e.g:

Now click on "Applications" then "System Tools" then "Configuration Editor". Once the configuration editor opens click the arrow next to "apps", then click the arrow next to "panel". This expands the menus. e.g:

Now select the "global" folder. and in the right column untick the box next to "tooltips_enabled". e.g:

There you have it. Annoying yellow boxes gone :)

Tuesday, July 03, 2007

Things you may not know about Wikipedia

I found this link today and I think it is worth sharing. I leaned a couple of things I didn't know. So perhaps it might help you as well! Nine Cool Things You Didn’t Know You Could Do With Wikipedia. The thing I am loving the most is: Wikiversity:

Wikiversity provides tutorials and worksheets on subjects ranging from AJAX programming to Philosophy. Wikiversity is currently woefully incomplete, but many subject have lengthy, well-written tutorials.
There is some awesome information here.