gitphp
vimhtml
nginxmysql
mongodblinux
redisnginx
memcachedc++
mysqlgit
rvm || rbenvgithub
rubyredis
系統庫(Centos: yum, mac: brew, ubuntu: apt-get)本文檔主要是:Centos環境的搭建sql
varnish
安裝CentOS 6.2 64bit 最小化系統
配置網卡
vim /etc/sysconfig/network-scripts/ifcfg-eth0
EVICE="eth0" BOOTPROTO="dhcp" HWADDR="08:00:27:86:A1:4A" NM_CONTROLLED="yes" ONBOOT="yes"
重啓網卡: service network restart
注:是否須要配置成靜態ip, 相關配置:
EVICE="eth0" BOOTPROTO="static" IPADDR="192.168.10.1" # ip地址 NETMASK="255.255.255.0" # 子網掩碼 GATWAY="192.168.10.1" # 網關 HWADDR="08:00:27:86:A1:4A" NM_CONTROLLED="yes" ONBOOT="yes"
rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel yum install -y openssl-devel make bzip2 autoconf automake libtool bison iconv-devel git-core ImageMagick yum install -y libxml libxml-devel libxslt libxslt-devel wget yum install -y pcre-devel openssl openssl-devel yum install -y tcl yum install -y libaio-devel yum install -y ntpdate
/usr/sbin/ntpdate 0.centos.pool.ntp.org;/sbin/hwclock -w crontab -e * */12 * * * /usr/sbin/ntpdate 0.centos.pool.ntp.org;/sbin/hwclock -w
參考:http://blog.58share.com/?p=289
做爲編輯神器:vim我就不用多介紹了,基本上初始化安裝CentOS都會帶vi vim的不少插件,可是管理不是很方便,這裏我使用的是Vundle進行插件的管理。
具體可參考:http://blog.58share.com/?p=203
vim配置文件:https://github.com/huhongda/scripts/blob/master/vimrc
yum install -y vim
yum install -y git
git config --global user.name "jerry" # 或者 vim ~/.gitconfig [user] name = jerry email = your_email [color] #配置git爲色彩 branch = auto diff = auto interactive = auto status = auto [core] editor = /usr/bin/vim
git clone https://github.com/huhongda/scripts.git git add . || git add direct_file git commit -m 'you commit' git push origin your_branch # 提交你的分支到遠程分支 git push origin :your_branch # 刪除你的遠程分支 git push origin master -f 強行提交本地分支到遠程 git pull origin your_branch git checkout your_first_branch git merge your_branch git remote update -p # 更新遠程分支 git remote -v # 查看git庫地址 git remote add origin https://github.com/huhongda/scripts.git # 添加git庫提交地址 git remote rm origin # 刪除git庫提交地址 git log # 查看git提交 git log --graph git log -p app/xxxx.rb 查看歷史版本記錄(包括代碼) git diff commitA commitB # 查看版本之間的不一樣 git blame file # 查看文件的修改狀況 git clean -df 刪除untrack的文件 git stash 將修改文件存入緩存中 git stash pop 從緩存中釋放出修改文件 git branch -a # 顯示全部的分支(包括遠程分支) git branch -d your_branch # 刪除本地分支 git status # 查看分支狀態 git checkout -b new_branch # 根據當前分支建立一個新的分支
簡介:http://danielkummer.github.io/git-flow-cheatsheet/index.zh_CN.html
wget https://raw.github.com/huhongda/scripts/master/gitflow-installer.sh /bin/bash gitflow-installer.sh # 執行完成以後 git flow init # 按照提示配置,不輸入按照默認的配置
## for developer git checkout develop git pull origin develop git flow feature start new_branch ..develop.. git add . git commit -m 'modify your branch' git push origin new_branch ## base current branch git checkout old_branch git pull origin old_branch git checkout -b new_branch .. ## for other git flow feature publish new_branch git remote update -p git flow feature track new_branch ## for production git flow feature track new_branch git flow feature finish new_branch git push origin :new_branch ### for release git flow release start Version_1.02 git flow release publish Version_1.02 # 追蹤release分支 git flow release track Version_1.02 # 完成release #更新master (release finish完會自動切換到master分支) git flow release finish -F -p Version_1.02 git push origin master # hotfix流程 git remote update -p git checkout master git pull origin master git checkout develop git pull origin develop git flow hotfix start xxoo 改啊改 git add .............. git commit -m "xxoo" git remote update -p git flow hotfix finish xxoo git remote update -p git checkout master git pull origin master git push origin master git checkout develop git pull origin develop git push origin develop
cd /tmp wget -c http://nginx.org/download/nginx-1.4.4.tar.gz tar -zxf nginx-1.4.4.tar.gz cd nginx-1.4.4 ./configure --user=www --group=www --prefix=/usr/local/nginx \ --with-http_ssl_module --with-http_realip_module --with-http_addition_module \ --with-http_sub_module --with-http_gzip_static_module --with-http_realip_module \ --with-http_gunzip_module --with-http_stub_status_module --with-pcre \ --with-ipv6 --with-mail --with-mail_ssl_module --with-http_random_index_module make make test make install
建立www用戶,用戶組以及Nginx日誌目錄
/usr/sbin/groupadd www /usr/sbin/useradd -g www www mkdir -p /data/pids/nginx/ mkdir -p /data/logs/nginx/ chmod +w /data/logs/nginx/ chmod +w /data/pids/nginx/ chown -R www:www /data/logs/nginx/ chown -R www:www /data/pids/nginx/
建立Nginx配置文件
參考:https://github.com/huhongda/scripts/blob/master/nginx.conf
wget https://raw.github.com/huhongda/scripts/master/nginx.conf
啓動nginx
ulimit -SHn 65535 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
配置開機啓動nginx vim /etc/rc.local
ulimit -SHn 65535 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -t # 檢測配置文件是否正確 /usr/local/nginx/sbin/nginx -s reload # 平滑重啓Nginx /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf # 啓動nginx
更多請參考:http://blog.58share.com/?p=158#more-158 以及nginx官網文檔
wget https://memcached.googlecode.com/files/memcached-1.4.15.tar.gz #memcached依賴包 wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz tar -zxf libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-stable ./configure make && make install ln -sv /usr/local/lib/libevent-2.0.so.5 /usr/lib/ ln -sv /usr/local/lib/libevent-2.0.so.5 /usr/lib64/ cd ../ tar -zxf memcached-1.4.15.tar.gz cd memcached-1.4.15/ ./configure --prefix=/usr/local/memcached --with-libevent=/usr make && make install ln -sv /usr/local/memcached/bin/memcached /usr/bin/ source ~/.bashrc /usr/sbin/useradd -g memcached memcached # 啓動 memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid #加入啓動項 vim /etc/rc.local memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
rails,php版本客戶端使用 參考:http://blog.58share.com/?p=176
下載系統對應的版本:
#查看系統位數(32位或者64位) uname -m | sed -e 's/i.86/32/' # 64bit 版本 wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz # 32bit 版本 wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15-linux-glibc2.5-i686.tar.gz
安裝:
groupadd mysql useradd -r -g mysql mysql tar -zxf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.15-linux-glibc2.5-x86_64 /usr/local/mysql cd /usr/local chown -R mysql:mysql mysql
添加PATH路徑:
vim /etc/profile # 添加下面文件 MYSQL_HOME=/usr/local/mysql PATH=$PATH:$MYSQL_HOME/bin source /etc/profile
建立數據庫存儲目錄:
mkdir -p /data/data/mysql mkdir -p /data/logs/mysql chown -R mysql:mysql /data/data/mysql chown -R mysql:mysql /data/logs/mysql chmod -R go-rwx /data/data/mysql chmod -R go-rwx /data/logs/mysql
配置數據信息:
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/data/mysql/ --explicit_defaults_for_timestamp cp support-files/mysql.server /etc/init.d/mysql #將mysql啓動文件拷貝到啓動項 /usr/local/mysql/bin/mysqladmin -u root password 'new-password' # 設置root密碼 # 編輯啓動文件 vim /etc/init.d/mysql basedir=/usr/local/mysql datadir=/data/data/mysql
建立mysql配置文件:
cp support-files/my-default.cnf /etc/my.cnf
修改配置文件: vim /etc/my.cnf
[client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /data/data/mysql pid-file = /data/data/mysql/mysql.pid log-error = /data/logs/mysql/error.log long_query_time = 0.5 #慢查詢超時時間 slow_query_log = 1 slow_query_log_file = /data/logs/mysql/slowquery.log #打開慢查詢日誌功能 min_examined_row_limit = 10000 skip-external-locking key_buffer_size = 384M max_allowed_packet = 1M table_open_cache = 512 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size = 32M thread_concurrency = 8 log-bin=mysql-bin server-id = 1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout
參考:http://blog.58share.com/?p=141
# 加入啓動項 vim /etc/rc.local /etc/init.d/mysql start
安裝以及基本使用參考:http://blog.58share.com/?p=192
wget -c http://download.redis.io/releases/redis-2.8.4.tar.gz tar xzf redis-2.8.4.tar.gz cd redis-2.8.4 make cp redis-server /usr/local/bin/ cp redis-cli /usr/local/bin/ mkdir /var/redis mkdir /etc/redis mkdir /var/redis/6379 cp utils/redis_init_script /etc/init.d/redis cp redis.conf /etc/redis/6379.conf
配置參考:http://redis.io/topics/quickstart
/etc/init.d/redis start # 開機啓動 vim /etc/rc.local /etc/init.d/redis start
Varnish是一款高性能、開源的反向代理服務器和緩存服務器
yum install -y varnish
2.
wget http://repo.varnish-cache.org/source/varnish-3.0.4.tar.gz tar zxf varnish-3.0.4.tar.gz cd varnish-3.0.4 ./configure make make check (檢測是否有錯) make install
# 下載配置文件 cd /usr/local/etc/varnish/ wget https://raw.github.com/huhongda/scripts/master/varnish_default.vcl mkdir -p /data/data/varnish varnishd -f /usr/local/etc/varnish/varnish_default.vcl -a 0.0.0.0:80 -s file,/data/data/varnish/varnish_cache.data,128m -T 127.0.0.1:3500 # -T 是管理地址 -a 就是綁定地址 # 注:同端口只能存在一個! # 能夠經過nginx轉發
瞭解更多參考:
http://www.programmer.com.cn/14315/
通常咱們經過rbenv或者rvm來管理ruby的多個版本
rvm 的安裝使用參考: http://ruby-china.org/wiki/rvm-guide
通常咱們使用rbenv來管理ruby版本
具體參考:http://ruby-china.org/wiki/rbenv-guide
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv # 用來編譯安裝 ruby git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # 用來管理 gemset, 可選, 由於有 bundler 也沒什麼必要 git clone git://github.com/jamis/rbenv-gemset.git ~/.rbenv/plugins/rbenv-gemset # 經過 gem 命令安裝完 gem 後無需手動輸入 rbenv rehash 命令, 推薦 git clone git://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash # 經過 rbenv update 命令來更新 rbenv 以及全部插件, 推薦 git clone https://github.com/rkh/rbenv-update.git ~/.rbenv/plugins/rbenv-update
而後把下面的代碼放到 ~/.bash_profile
裏
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"
執行: source ~/.bash_profile
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
https://github.com/fesplugas/rbenv-installer
rbenv install --list # 列出全部 ruby 版本 rbenv install 1.9.3-p484 # 安裝 1.9.3-p392 rbenv versions # 列出安裝的版本 rbenv version # 列出正在使用的版本 rbenv global 1.9.3-p484 # 默認使用 1.9.3-p392 rbenv shell 1.9.3-p484 # 當前的 shell 使用 1.9.3-p392, 會設置一個 `RBENV_VERSION` 環境變量 benv local 1.9.3-p484 # 當前目錄使用 jruby-1.7.3, 會生成一個 `.rbenv-version` 文件 rbenv rehash # 每當切換 ruby 版本和執行 bundle install 以後必須執行這個命令 rbenv which irb # 列出 irb 這個命令的完整路徑 rbenv whence irb # 列出包含 irb 這個命令的版本
gem install bundler 經過bundle來管理gem包