Archive for 2006

Installing MySQL, Apache and PHP in Solaris 10

Monday, December 11th, 2006

This is a quick guide to install PHP4, MySQL4 and Apache2 in Solaris 10. In order to facilitate the management and installation of packages we will use the pkg-get tool. pkg-get is a tool to automate download and installation of binary packages, for example from Blastwave an Open Source software repository for Solaris.

Our first task will be the installation of pkg-get. At Blastwave you’ll find a complete guide on how to undertake this task. Briefly:

cd /tmp
/usr/sfw/bin/wget http://www.blastwave.org/pkg_get.pkg
pkgadd -d pkg_get.pkg all
/usr/sfw/bin/wget http://www.blastwave.org/wget-i386.bin
chmod 755 wget-i386.bin

PATH=/tmp:/opt/csw/bin:/usr/sbin:/usr/bin:

/usr/dt/bin:/usr/openwin/bin:/usr/ccs/bin
export PATH

vi /opt/csw/etc/pkg-get.conf

Pick a mirror next to you. Then:

pkg-get -i wget

PATH=/opt/csw/bin:/usr/sbin:/usr/bin:/usr/dt/bin:

/usr/openwin/bin:/usr/ccs/bin
export PATH

And now you may install other packages. But let’s focus in our target.

As Solaris 10 comes with MySQL and Apache installed by default, first we are going to uninstall them. Take a look at your system:

pkginfo | grep -i apache

system SUNWaclg Apache Common Logging
system SUNWapch2d Apache Web Server V2 Documentation
system SUNWapch2r Apache Web Server V2 (root)
system SUNWapch2u Apache Web Server V2 (usr)
system SUNWapchd Apache Web Server Documentation
system SUNWapchr Apache Web Server (root)
system SUNWapchu Apache Web Server (usr)

pkginfo | grep -i mysql

system SUNWmysqlr mysql – MySQL Database Management System (root component)
system SUNWmysqlt mysql – MySQL Database Management System (test component)
system SUNWmysqlu mysql – MySQL Database Management System (usr component)

Next task would be to uninstall these packages. Proceed as follows:

pkgrm SUNWaclg SUNWapch2d SUNWapch2r SUNWapch2u SUNWapchd SUNWapchr SUNWapchu
pkgrm SUNWmysqlr SUNWmysqlt SUNWmysqlu

Finally, install Apache, MySQL and PHP from pkg-get:

pkg-get -i apache2 mysql4 php4 mod_php

That’s all. Now configure the software as usual. Note that packages installed with pkg-get reside in /opt/csw, so I recommed adding something like this to your /etc/profile:

PATH=/opt/csw/bin:/opt/csw/mysql4/bin:$PATH
export PATH

More info:

pkg-get installation howto
pkg-get users guide
Customizing Your Working Environment

Changing MAC address

Sunday, October 22nd, 2006

The acronym MAC stands for Media Access Control and it is a unique number that identifies your network interface. In an interconnected computer network a so called ARP table relates your IP address to your network interface card’s MAC.

Despite the fact that physical MAC addresses are permanent, it is possible to change this address. In Linux proceed as follows:

ifconfig eth0 down
ifconfig eth0 hw ether 01:01:02:02:03:03

Prevent non-root users from logging

Friday, August 25th, 2006

Imagine that for some reason (i.e. maintenance tasks) you want to prevent non-root users from logging into the system. The next tip is a very simple way to achieve this goal.

If a file called /etc/nologin exists login will disable the begin of a session in this system. If you put some text into the file, users will be shown this text and their login attempts will be refused.

vi /etc/nologin

Server under maintenance. No access allowed at this moment.

Sed basics

Thursday, August 3rd, 2006

According to sed’s man page…

Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.

Next, we are going to explore some of the basic usage of sed.

Substitute every occurrence of string1 with string2. The g stands for global, which means that all matching occurrences in the line would be replaced and the output would be directed to outputFile instead of the default standard output.

sed ’s/string1/string2/g’ inputFile > outputFile

From inputFile show me lines 5732 to 5797. Note the importance of the n switch and the p command to print only the range of lines specified. Without n sed will print the entire file:

sed -n ‘5732,5797p’ inputFile

Now I want sed to print everything but lines 5732 to 5797:

sed ‘5732,5797d’ inputFile

A kind of cat inputFile1 >> inputFile2:

sed r inputFile1 inputFile2

Show me a paragraph of inputFile that begins with the words “simple mail transport protocol” and ends with the word “postfix”:

sed -n ‘/simple mail transport protocol/,/postfix/p’ inputFile

Next trick will delete empty lines or lines that only contain space characters. Note that the caret denotes the begining of a line, de dollar symbol denotes end of line, the period a single character and asterisk matches zero or more occurrences of the previous character.

sed -e ‘/^ *$/d’ inputFile

Add blank lines to inputFile:

sed ‘G’ inputFile > outputFile

And now delete those blank lines:

sed ‘n;d’ outputFile

A kind of cat inputFile | wc -l:

sed -n ‘$=’ inputFile

Number each line of inputFile:

sed = inputFile | sed ‘N;s/n/t/’

References:

System Administrator Appreciation Day

Friday, July 28th, 2006

One year again today, July 28th, is the annual System Administrator Appreciation Day. And one year again Happy System Administrator Appreciation Day! I am open to receive any kind of gifts.

Solaris 10 Update

Saturday, July 1st, 2006

This week Sun announces the availability of the latest update of the Solaris 10 Operating System.

The enhancements include the so called Zettabyte File System (ZFS), PostgreSQL, networking improvements, predictive self healing, faster reboot and many more. The announcement and what’s new links.

Automatisation of telnet, ftp or ssh

Monday, June 12th, 2006

For ftp you have a quick and dirty trick :

$ ftp -n yourhost <<-here
> quote USER youruser
> quote PASS yourpassword
> ls
> quit
> here

(you can do a put, get, whatever you want instead of “ls”)

For telnet similar idea:

$ (echo -e “open yourhostr”; sleep 2;echo -e “youruserr”; sleep 1; echo -e “yourpassword”; sleep 1; echo -e “unamer”; sleep 1; echo -e “exit”) | telnet

That sound pretty good but … it does not work on solaris (ok on Linux), and no way for ssh :(

So if this shoddy doesn’t meet your expectations…

Expect is what you are looking for. Available for GNU-linux, solaris… MSwindows… at http://expect.nist.gov/
For debian do it cool:

apt-get install expect

I do it with 2 scripts. I’m sure that you can do better, but that’s work ;-)

– script to call the expect and to make things good looking:
host=$1
psswd=$2
cmd=$3
os=$( ./expectaTion.tcl $host $psswd $cmd| awk “/$cmd/ “‘{getline; print}’|tr -d ‘

OpenSolaris/Solaris 10 primer

Saturday, June 10th, 2006

The next link will show you a set of wonderful features of the OpenSolaris and Solaris operating systems. This has been written by the Open Solaris Community: OpenSolaris Primer. Many thanks to them.

Linux: skip or force fsck on reboot

Tuesday, April 11th, 2006

shutdown is the typical way to bring your system down in a Unix environment. It takes care of notifying logged in users that the system is going down, takes care of sending SIGTERM to processes and more.

One interesting feature of shutdown is the ability to force or skip the check and repair of the filesystem after a reboot. This is done by two flags that could be passed to the command. According to the man pages:

The -f flag means 'reboot fast'. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.

The -F flag means 'force fsck'. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special 'force' flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.

OpenSSH and OpenBSD’s financial troubles

Saturday, April 1st, 2006

The OpenBSD project is requesting help to surpass its financial difficulties. As you probably know, the development team of OpenBSD is also in charge of the development of OpenSSH. Could these economic problems put in danger the continuity of OpenSSH, an essential tool for Sysadmins like you? While all this happens, the big companies (Cisco, IBM, RedHat, etc etc etc) that take advantage of the work done in OpenSSH for free are in silence. And what about you? What will you do without OpenSSH?