Archive for April, 2009

Install Python/Numpy from source

command reference only, plz install from port
$ tar zxvf Python-2.6.2.tgz
$ sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev
$ cd python-2.6.2
$ ./configure
$ make
$ make install

$ sudo apt-get install python-setuptools

$ cd numpy
$ sudo python setup.py install

$ tar zxvf scipy-0.7.0.tar.gz
$ sudo python setup.py install

$ sudo apt-get build-dep matplotlib

$ cd matplotlib
$ sudo python setup.py install

Remove macports completely

% sudo rm -rf  the following folders
/opt/local 
/Applications/MacPorts 
/Library/Tcl/macports1.0 
/Library/LaunchDaemons/org.macports.* 
/Library/StartupItems/DarwinPortsStartup

Secured SSH

In client:
ssh-keygen -t rsa
In client:
$ ssh-keygen -t rsa
$ scp -P portNum id_rsa.pub username@ip:~/.ssh/authorized_keys
$ sftp -o PORT=portNum username@ip

Ubuntu configuration

First boot
$ sudo passwd root
$ sudo apt-get update


Common command
$ rm -r  folder_name #del a folder
$ mv -f  from_folder   to_folder #move a folder
$ wget -r ftp://name:pwd@ip/path/ # retrieve a folder

Install SSH Server
$ sudo apt-get install ssh
$ sudo nano /etc/ssh/sshd_config
change PermitRootLogin no
add AllowUsers  USERNAME
$ sudo /etc/init.d/ssh  restart
$ ssh  userName@IP  -p portNumber

Install Proftpd
$ sudo apt-get install proftpd
$ sudo nano /etc/proftpd/proftpd.conf
Change ServerName
change DefaultRoot ~
add the following tow lines after “ShowSymlinks off”
UseReverseDNS off 
IdentLookups off 
$ sudo /etc/init.d/proftpd restart 

Add a port (20/21) for proftpd
$ sudo iptables -A INPUT -i ppp0 -p tcp –dport 20 -j ACCEPT
$ sudo /etc/init.d/proftpd restart

Install Apache2, MySQL and PHP5
$ sudo  apt-get  install  apache2  apache2-mpm-prefork
$ sudo  apt-get  install  php5  libapache2-mod-php5  php5-cli  php5-dev  php5-gd  php5-imagick  php5-mcrypt  php5-xmlrpc
$ sudo  apt-get  install  mysql-server  libapache2-mod-auth-mysql  php5-mysql
Open personal website
$ sudo a2enmod userdir
$ sudo /etc/init.d/apache2 restart
# do not list your directory
$ sudo nano /etc/apache2/sites-available/default # Global
$ sudo nano /etc/apache2/mods-available/userdir.conf # local
remove Indexes from option (global and local)!! 

# add new error pages

sudo nano /etc/apache2/apache2.conf # ctrl+w 404

Install scipy and matplotlib
$ sudo apt-get install python-scipy python-matplotlib python-matplotlib-doc

Install ncftp
$ sudo apt-get install ncftp
$ ncftp -u username hostname -p #login
$ get -r foldername #download
$ ncftpput -u username hostname remotefoldername localfoldername #upload
$ rm -r foldername # del a folder
$ rename file (or folder name)

Install Latex and CJK
$ sudo apt-get install texlive texlive-doc-en texlive-doc-zh texlive-latex* latex-cjk-chinese*
$ sudo apt-get install latex-beamer
$ sudo apt-get install kile

Install SVN
$ sudo apt-get install subversion


Matplot installation and examples


Note:
After installation, you have to set the backend of matplot
First, change the permission by sudo chmod +w, and then edit the file by nano.
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/mpl-data/matplotlibrc
Finally, select the backend as TkAgg
Example:
import pylab as plt
a = plt.randn(10000)
plt.hist(a,100)

Change the bash prompt

$ nano .bash_profile
# set prompt: “username@hostname:/directory $ ”
PS1=”\u@\h:\w ” 
case `id -u` in
      0) PS1=”${PS1}# “;;
      *) PS1=”${PS1}$ “;;
esac
$ sudo scutil –set HostName mb

Install Python/Numpy/Django by Macports

Install MacPorts from http://www.macports.org/
$ sudo port -d selfupdate # update the macport list
$ sudo port install python26
$ sudo port install python_select  
$ sudo python_select python26

$ sudo port install py26-numpy py26-ipython py26-scipy py26-matplotlib
$ sudo port install py26-wxpython py26-setuptools py26-pyqt4 py26-pyobjc2 py26-psyco py26-numeric py26-nose py26-matplotlib-basemap
$ sudo port install fftw-3 libpng subversion subversion-python26bindings
$ sudo port install py26-django
$ sudo port upgrade installed # upgrade what you have if you want