root帐号登录服务器
查看版本
cat /etc/issue
#CentOS release 5.2 (Final)
调整时区时间
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sudo /usr/sbin/ntpdate us.pool.ntp.org
很简单吧,解析一下,第一句是把当前时区调整为上海就是+8区,想改其他时区也可以去看看/usr/share/zoneinfo目录;然后第二句 是利用ntpdate同步标准时间.
没有ntpdate的可以yum一下: yum install -y ntpdate
新建用户
useradd app
passwd app
#Changing password for user app.
#New UNIX password:
#Retype new UNIX password:
#passwd: all authentication tokens updated successfully.
#add app to sudoer
vi /etc/sudoers
#add line
app ALL=(ALL)NOPASSWD:ALL
#test
su app
sudo ls -all
配置自动登录
su app
cd /home/app/
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
#回到本地机器
cd ~
#生成密钥对:
#ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh app@116.255.153.187 "cat - >> ~/.ssh/authorized_keys"
#test
ssh app@211.152.56.151
安装软件
iostat, sar等系统命令
sudo yum install sysstat
Git
sudo yum -y install zlib-devel
mkdir src
cd src
wget http://www.kernel.org/pub/software/scm/git/git-1.6.3.tar.gz
tar xf git-1.6.3.tar.gz
cd git-1.6.3
./configure --prefix=/usr/local/git <span class="Apple-style-span" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; color: rgb(0, 0, 0); font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; line-height: normal; white-space: normal; font-size: 13px; ">--without-tcltk </span>
make
sudo make install
cd /usr/bin/
sudo ln -ns /usr/local/git/bin/git
git --version
openssl(http://www.openssl.org/source)
cd
cd src
wget http://www.openssl.org/source/openssl-0.9.8i.tar.gz
tar zxvf openssl-0.9.8i.tar.gz
cd openssl-0.9.8i/
./config shared --prefix=/usr/local
make
sudo make install
cd ..
zlib(http://zlib.net/)
cd
cd src
wget http://www.zlib.net/zlib-1.2.5.tar.gz
tar zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
CFLAGS="-O3 -fPIC" ./configure
make
sudo make install
cd ..<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 16px; line-height: 25px; white-space: normal;"><b>
</b></span></font>
Redline(http://tiswww.case.edu/php/chet/readline/rltop.html)
cd
cd src
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar zxvf readline-5.2.tar.gz
cd readline-5.2
./configure
make
sudo make install
cd ..
sudo /sbin/ldconfig
MySQL
#安装依赖 for error :http://webhostingneeds.com/Configure:_error:_No_curses_termcap_library_found
sudo yum -y install ncurses-devel
sudo /usr/sbin/groupadd mysql
sudo /usr/sbin/useradd -g mysql mysql
#version 5.1.48
cd
cd src
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.48.tar.gz/from/http://mysql.llarian.net/
tar xzf mysql-5.1.48.tar.gz
cd mysql-5.1.48
./configure --prefix=/usr/local/mysql --with-plugins=innobase
make
sudo make install
sudo cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
sudo bin/mysql_install_db --user=mysql
sudo chown -R root /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &amp;amp;
cd /usr/bin
sudo ln -s /usr/local/mysql/bin/mysql
#等待几秒
/usr/bin/mysqladmin -u root password 'new-password'
Ruby Enterprise Edition
cd
cd src
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar zxvf ruby-enterprise-1.8.7-2010.02.tar.gz
sudo ./ruby-enterprise-1.8.7-2010.02/installer
# [/opt/ruby-enterprise-1.8.7-2010.02] : /usr/local/ruby<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 16px; line-height: 25px; white-space: normal;"></span></font>
<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 14px; font-weight: normal; line-height: 21px; white-space: normal;">cd
vi .bash_profile
#add below line
PATH=$PATH:$HOME/bin:/usr/local/ruby/bin
. .bash_profile
ruby -v
gem -v</span></font>
<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 14px; font-weight: normal; line-height: 21px; white-space: normal;">cd
cd src/ruby-enterprise-1.8.7-2010.02/source/ext/openssl
sudo ruby extconf.rb
make
sudo make install</span></font>
mysql gem
sudo gem install mysql -- --with-mysql-config='/usr/local/mysql/bin/mysql_config'
Openssl问题
sudo vi /etc/ld.so.conf
#加入下面一行
/usr/local/lib
#保存后
sudo /sbin/ldconfig
Nginx
sudo passenger-install-nginx-module
Please specify a prefix directory [/opt/nginx]: /usr/local/nginx<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 16px; line-height: 25px; white-space: normal;"><b>
</b></span></font>
设置 .gemrc
cd
vi .gemrc
---
:bulk_threshold: 1000
:benchmark: false
:verbose: true
:sources:
- http://gemcutter.org
- http://gems.github.com
- http://gems.rubyforge.org/
:update_sources: true
:backtrace: false
gem: --no-ri --no-rdoc
设置Alias
cd ~
vi .bash_profile
#add below
alias vb='vi ~/.bash_profile;. ~/.bash_profile'
#grep
alias psg='ps axu|grep'
alias llg='ll -h |grep'
alias ll='ls -all --color'
alias n='sudo nano -w'
alias startmysql='sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &'
alias sql='mysql -uroot -pcp2010 --default-character-set=utf8'
#alias for monitor
alias mt='cd /home/www/monitor'
alias spd='cd /home/www/monitor/lib/spider/'
alias rsg='ruby signal_sender.rb'
alias alljob='ruby runner.rb -app_name=Fetch_all_data start -- -j all'
alias stopall='ruby runner.rb stop_all'
alias trunner='t output/runner'
alias texception='t output/exception'
#rails
alias sc='script/console'
alias ss='script/server'
alias ssp='script/server -p'
alias sg='script/generate'
alias spi='script/plugin install'
alias rdb='RAILS_ENV=production rake db:migrate'
alias rt='rake test'
alias pss="RAILS_ENV=production script/server"
alias psc="RAILS_ENV=production script/console"
alias tr='touch tmp/restart.txt'
# alias gp='git push origin master'
alias irbg='irb -rubygems'
alias gb='git branch'
alias gs='git status'
alias gc='git checkout'
alias gac='git add .;git commit'
alias gm='git merge'
alias gp='git push'
alias gl='git pull'
alias gi='~/bin/git-info.sh'
alias gw='git-instaweb -d webrick -p 8888'
alias gws='gw --stop'
#tail
alias t='tail -f -n 200'
#god
alias gods='god status'
alias grun='god start'
alias gstop='god stop'
# User specific aliases and functions<font class="Apple-style-span" face="Corbel, Verdana, Arial, Helvetica, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 16px; line-height: 25px; white-space: normal;"><b>
</b></span></font>
增加git info功能
cd
mkdir bin
vi bin/git-info.sh
------
#!/bin/bash
# author: Duane Johnson
# email: duane.johnson@gmail.com
# date: 2008 Jun 12
# license: MIT
#
# Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496
pushd . >/dev/null
# Find base of git directory
while [ ! -d .git ] && [ ! `pwd` = "/" ]; do cd ..; done
# Show various information about this git directory
if [ -d .git ]; then
echo "== Remote URL: `git remote -v`"
echo "== Remote Branches: "
git branch -r
echo
echo "== Local Branches:"
git branch
echo
echo "== Configuration (.git/config)"
cat .git/config
echo
echo "== Most Recent Commit"
git log --max-count=1
echo
echo "Type 'git log' for more commits, or 'git show' for full commit details."
else
echo "Not a git repository."
fi
popd >/dev/null
-------
#make execute
chmod +x bin/git-info.sh
配置CentOS
最新推荐文章于 2024-01-03 21:05:30 发布