Archive for the ‘system’ Category

Mac OS setup apache and php

Thursday, June 11th, 2009

here is the steps to setup apache and php in your Mac OS X.

  1. Apache and PHP already came with your OS. You just need to enable it.
  2. Go to the apple icon on the menu bar.  Select “System Preferences…” -> “Internet & Network” -> “Sharing”
  3. Enable “Web Sharing” by click on it
  4. You just enabled the web server. You can test it by go to: http://localhost/
  5. To enabled php, in a command window, edit /private/etc/apache2/httpd.conf
  6. remove the “#” character in front of this line: LoadModule php5_module        libexec/apache2/libphp5.so
  7. restart the apache server by: sudo apachectl restart
  8. now you have php enabled.
  9. add a file called: /private/etc/apache2/users/your_username>.conf
  10. put this in the file:
  11. #
    # Allow access to this user’s Sites directory for web clients.
    #
    <Directory “/Users/your_username/Sites/”>
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
  12. remember to replace “your_username” with your username.
  13. restart apache: sudo apachectl restart
  14. put a file in /Users/your_username/Sites/x.htm
  15. go to the browser: http://localhost/~your_username/x.htm
  16. and you will see the file.

How to use ftp in a shell script

Friday, March 20th, 2009

First way:

#!/bin/sh
HOST='ftp.users.qwest.net'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0

Second way:

#!/bin/sh
USER=userid
PASSWD=userpw
ftp -n f2dev <<SCRIPT
user $USER $PASSWD
binary
get some.file
quit
SCRIPT

HAProxy – a load balancing tool

Friday, March 20th, 2009

If you are worry about load balancing. The first thing you should tried is HAProxy.

http://haproxy.1wt.eu/

However, it is not a sure thing. Need some testing on it.

Install Linux From External USB hard drive

Friday, March 20th, 2009

After getting that new USB external hard drive case and installing that new hard drive, you need to get it installed and working with your Linux box. These instructions worked for me on Ubuntu and they should work for those with other distributions.

After putting the drive in the case, connecting it to power and plugging it into the back (or front) of your machine, the first thing you need to do is find out what device it is. USB hard drives usually show up as /dev/sdx (where x is a letter starting from a). If this is the only usb drive you have plugged in, it will most likely be /dev/sda.

To find out what it is look at the output of the command: tail /var/log/messages in your terminal. It will give you some irrelevant stuff, so look for a line that looks like this:

May 16 07:50:26 localhost kernel: Attached scsi disk sdb at scsi6, channel 0, id 0, lun 0

On my machine the drive shows up as /dev/sdb because I have an external DVD burner attached.

Now run fdisk as root and create a partition on the drive. On my Ubuntu box I did this by typing: sudo fdisk /dev/sdb into the terminal.

Once in fdisk press p to display a list of current partitions (there shouldn’t be any) and n to create a new partition. You want to create primary partition #1. fdisk will ask a few questions at this point, but since I was setting up an external drive, I didn’t want to create anything fancy so I just created one big partition for the entire drive, the default answers will do this. Once you get back to the fdisk prompt, press w to write the partition table. Now quit fdisk.

Now that you’ve got your partition set up, run the command mkfs.ext3 /dev/sdb1. I ran it as root (using sudo) on my box. This can take a long time, so if you want it to tell you what it’s doing, use the -v option.

Create a mount point

First create a directory you can use as a mount point. Mount point is a directory in the boot partition into which the drive is mounted. Usually the mount points are created under the /mnt/ -directory. Name the directory as you wish to call the new disk.

# mkdir /mnt/newdisk

You may want to issue the chmod go+x /mnt/newdisk command to grant other users access to the mountpoint. Now you may manually mount the drive by issuing command

# mount -t ext3 /dev/hdb1 /mnt/newdisk

Add hard disk to fstab

Mounting the hard drive manually every time is annoying. To mount the disk automatically, add it to fstab -file located in /etc/fstab. Depending on how you named the mount point, add the following lines to the end of /etc/fstab:

/dev/hdb1   /mnt/newdisk  ext3    defaults     0 0

The first set is the partition (1st partition of hdb), second describes the mount point and the third describes the filesystem type. ‘defaults’ tells the options. The first 0 is the ‘dump’. It tells the computer whether the drive should be backed up. a ’0′ means that it will not be backed up, a ’1′ enables backup. The last number determines the order in which the filesystems should be checked. If it’s zero, ‘fsck’ won’t check the filesystem.

Find all large files on a Linux machine

Friday, March 20th, 2009

Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Yum Hangs

Friday, March 20th, 2009

Sometime yum takes a long time to finish, it is because there is a lot of old temporary rpm database is created.

To fix the problem, just do the following:

rm -f /var/lib/rpm/__db.*

Adding a second IP address to Fedora Linux

Tuesday, January 6th, 2009

http://www.oclc.org/support/documentation/ezproxy/technote/2l.htm

These are the steps to add the second IP address to your existing network adapter under non-SUSE distributions of Linux.

  1. Become root on your system, either by logging into that account or using the su command.
  2. Change your current directory to the /etc/sysconfig/network-scripts directory with the command:
    
    cd /etc/sysconfig/network-scripts
    
  3. Check for existing network adapters with the command:
     ls ifcfg-* 

    In most instances, you will see the files ifcfg-eth0 and ifcfg-lo.

  4. Edit /etc/hosts and add a line for your new address and name such as:
    24.249.162.195 www.xyz.org
  5. To create the new interface, you will copy ifcfg-eth0 to ifcfg-eth0:0 with the command:
    cp ifcfg-eth0 ifcfg-eth0:0 

    Next, edit icfg-eth0:0 and change the DEVICE line to be similar to:

    DEVICE=eth0:0 

    and change the IPADDR line to be similiar to:

    IPADDR=24.249.162.195 
  6. To activate the new IP address, issue a command similar to:
    ./ifup eth0:0 

sendmail 451 Name server timeout

Friday, October 17th, 2008

This is something related to sendmail IPv6 support.

  1. cd /etc/mail
  2. sendmail.mc and add the following at the end of the file:
  3. define(`confBIND_OPTS’, `WorkAroundBrokenAAAA’)dnl
  4. type make
  5. restart sendmail

hadoop hbase ec2 installation

Saturday, October 11th, 2008

Here is the steps by steps hbase ec2 installation.

  1. start elasticfox
    1. create a “keypairs”
    2. on your “security groups” default group, add port 50000-51000 (for hadoop) and port 60000-61000 (for hbase)
    3. search for hbase AMI (ami-4de30724)
    4. launch the install with the newly create keypair and default group permission
  2. on you desktop linux/window machine do: ssh -i <keypair.pem> root@<your new instance IP>
    1. replace the <keypair.pem> with the newly create keypairs pem file
    2. replace <your new instance IP> to your newly create instance IP address
  3. step 2  will login your ec2 machine. Then do the following:
    1. type: ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa
    2. type: cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
    3. type: ssh localhost
    4. If it does not ask you for the password, you are okay.
    5. type: exit
    6. vi /usr/local/hadoop-0.17.1/conf/hadoop-site.xml
      1. replace: <value>hdfs://:50001</value>  to <value>hdfs://INSTANCE IP ADDRESS:50001</value>
      2. replace: <value>:50002</value> to <value>INSTANCE IP ADDRESS:50002</value>
    7. type: /usr/local/hadoop-0.17.1/bin/hadoop dfs namenode -format
    8. type: /usr/local/hadoop-0.17.1/bin/start-all.sh
    9. check /mnt/hadoop/logs/hadoop-root-namenode-<….>.log and make sure that your hadoop is starting correctly.
    10. vi /usr/local/hbase-0.2.0/conf/hbase-site.xml
    11. replace:  <value>:60000</value> to  <value>INSTANCE IP ADDRESS:60000</value>
    12. replace:  <value>hdfs://:50001/hbase</value> to <value>hdfs://INSTANCE IP ADDRESS:50001/hbase</value>
    13. type: /usr/local/hbase-0.2.0/bin/start-hbase.sh
    14. check /mnt/hbase/logs/* to make sure your hbase is start correctly.
  4. if everything is okay, you can point your browser to: http://INSTANCE IP ADDRESS:60010/ and see the hbase information.

file /etc/avahi/avahi-autoipd.action from install of avahi-autoipd-0.6.22-10.fc9.i386 conflicts with file from package avahi-0.6.17-1.fc7.i386

Tuesday, September 30th, 2008

Today, try to do a “yum update”.

It complains about:

Transaction Check Error:
file /etc/avahi/avahi-autoipd.action from install of avahi-autoipd-0.6.22-10.f
c9.i386 conflicts with file from package avahi-0.6.17-1.fc7.i386
file /usr/sbin/avahi-autoipd from install of avahi-autoipd-0.6.22-10.fc9.i386
conflicts with file from package avahi-0.6.17-1.fc7.i386
file /usr/share/man/man8/avahi-autoipd.8.gz from install of avahi-autoipd-0.6.
22-10.fc9.i386 conflicts with file from package avahi-0.6.17-1.fc7.i386

To fix it, do the following:

su
rpm -e –noscripts avahi-0.6.17-1.fc7.i386
yum update