zoukankan      html  css  js  c++  java
  • 网站更新部署20110210,新站部署全过程记录

     

    sudo adduser <用户名>


    按提示输入

    更改初始root账户密码


    ubuntu修改初始root密码
    2007-01-24 20:33

    $ sudo passwd root

    就是这么简单

    前提是你进行更改的这个账户是管理员账户

     

    将新加用户加入suoder组

    sudo adduser mlzboy admin

     备份源

    sudo cp sources.list sources.list.bak.20110210

    查看ubuntu版本号及别名

    sudo lsb_release -a
    Distributor ID:	Ubuntu
    Description:	Ubuntu 10.04.1 LTS
    Release:	10.04
    Codename:	lucid
    

     使用国内源参考

    http://www.vcbeta.net/read.php/455.htm

    编辑vi ./source.list

      deb http://mirrors.163.com/ubuntu/ lucid main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse

      deb http://mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ lucid main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse

      deb-src http://mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse


    sudo apt-get update

    部署rails前置库,参考

    http://www.cnblogs.com/lexus/archive/2010/12/10/1902646.html(主要)

    http://www.cnblogs.com/lexus/archive/2010/12/10/1902047.html


    安装rvm时注意

    最后手工配置的部分

    mlzboy@ubuntu:/etc/apt$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                     Dload  Upload   Total   Spent    Left  Speed

    109   986  109   986    0     0    509      0  0:00:01  0:00:01 --:--:--  1117

    Initialized empty Git repository in /home/mlzboy/.rvm/src/rvm/.git/

    remote: Counting objects: 17167, done.

    remote: Compressing objects: 100% (4603/4603), done.

    remote: Total 17167 (delta 11567), reused 16582 (delta 11100)

    Receiving objects: 100% (17167/17167), 3.01 MiB | 1.03 MiB/s, done.

    Resolving deltas: 100% (11567/11567), done.


      RVM:  Shell scripts enabling management of multiple ruby environments.

      RTFM: http://rvm.beginrescueend.com/

      HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)


    Installing RVM to /home/mlzboy/.rvm/

        Correct permissions for base binaries in /home/mlzboy/.rvm/bin...

        Copying manpages into place.



    Notes for Linux ( DISTRIB_ID=Ubuntu

    DISTRIB_RELEASE=10.04

    DISTRIB_CODENAME=lucid

    DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS" )


    NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)

                 This is the *original* / standard Ruby Language Interpreter

          'ree'  represents Ruby Enterprise Edition

          'rbx'  represents Rubinius


    bash >= 3.2 is required

    curl is required

    git is required (>= 1.7 recommended)

    patch is required (for ree and some ruby-head's).


    If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),

    then you must install and use rvm 1.8.7 first.


    If you wish to have the 'pretty colors' again,

      set 'export rvm_pretty_print_flag=1' in ~/.rvmrc.


    dependencies:

    # For RVM

      rvm: bash curl git


    # For Ruby (MRI & ree)  you should install the following OS dependencies:

      ruby: /usr/bin/aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev


    # For JRuby (if you wish to use it) you will need:

      jruby: /usr/bin/aptitude install curl g++ openjdk-6-jre-headless

      jruby-head: /usr/bin/aptitude install ant openjdk-6-jdk


    # In addition to ruby: dependencies,

      ruby-head: subversion


    # For IronRuby (if you wish to use it) you will need:

      ironruby: /usr/bin/aptitude install curl mono-2.0-devel



      You must now complete the install by loading RVM in new shells.


      1) Place the folowing line at the end of your shell's loading files

         (.bashrc or .bash_profile for bash and .zshrc for zsh),

         after all PATH/variable settings:


         [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.


         You only need to add this line the first time you install rvm.


      2) Ensure that there is no 'return' from inside the ~/.bashrc file,

         otherwise rvm may be prevented from working properly.


         

      This means that if you see something like:


        '[ -z "$PS1" ] && return'


      then you change this line to:


      if [[ -n "$PS1" ]] ; then


        # ... original content that was below the '&& return' line ...


      fi # <= be sure to close the if at the end of the .bashrc.


      # This is a good place to source rvm v v v

      [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.


    EOF - This marks the end of the .bashrc file


         Be absolutely *sure* to REMOVE the '&& return'.


         If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.


         Placing all non-interactive (non login) items in the .bashrc,

         including the 'source' line above and any environment settings.


      3) CLOSE THIS SHELL and open a new one in order to use rvm.

      


      WARNING:  you have a 'return' statement in your ~/.bashrc

                  This could cause some features of RVM to not work.


      

      This means that if you see something like:


        '[ -z "$PS1" ] && return'


      then you change this line to:


      if [[ -n "$PS1" ]] ; then


        # ... original content that was below the '&& return' line ...


      fi # <= be sure to close the if at the end of the .bashrc.


      # This is a good place to source rvm v v v

      [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.


    EOF - This marks the end of the .bashrc file


      Even if you are using zsh you should still adjust the ~/.bashrc

      If you have any questions about this please visit

        #rvm on irc.freenode.net.

      


    Installation of RVM to /home/mlzboy/.rvm/ is complete.



    mlzboy,


    Thank you very much for using RVM! I sincerely hope that RVM helps to

    make your work both easier and more enjoyable.


    If you have any questions, issues and/or ideas for improvement please

    join#rvm on irc.freenode.net and let me know, note you must register

    (http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to

    talk, this prevents spambots from ruining our day.


    My irc nickname is 'wayneeseguin' and I hang out in #rvm typically


      ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT


    If I do not respond right away, please hang around after asking your

    question, I will respond as soon as I am back.  It is best to talk in

    #rvm itself as then other users can help out should I be offline.


    Be sure to get head often as rvm development happens fast,

    you can do this by running 'rvm get head' followed by 'rvm reload'

    or opening a new shell


      w⦿‿⦿t


        ~ Wayne

    注意在原链接中用红色标记的部分为要改动的部分

    另外执行完后使用source ~/.bashrc来重新加载变更

    之后执行rvm notes来确认是否安装成功

    在使用rvm install 1.9.2时出现一个问题

    效果是一个带进度条的下载ruby的界面效果,如果长时间未动,说明是有问题了,要重新来过,参看下图的效果

    使用上方面的方法还是不过关,原因是ruby官方的ftp到本国实在是太慢了到86%再也没速度了,于是我先在linode下将ruby-1.9.2-p136.tar.bz2下载好,

    再将该文章用scp传到~/.rvm/archives/下

    http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p136.tar.bz2

    http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/

    之后再运行rvm install 1.9.2就直接开始进行配置和编译了

    这个过程还是很慢,一个cpu占用100%,难道是新的云主机cpu太弱了,据说是xen5620,我没看到实物,原先在linode的时候,好像不需要这样,在本机也没有这样的情况发生啊

    设置1.9.2为默认,虽然只有一个版本

    tmlzboy@ubuntu:~$ rvm list

    rvm rubies

       ruby-1.9.2-p136 [ i386 ]

    mlzboy@ubuntu:~$ rvm use 1.9.2 --default

    Using /home/mlzboy/.rvm/gems/ruby-1.9.2-p136

    mlzboy@ubuntu:~$ rvm list

    rvm rubies

    => ruby-1.9.2-p136 [ i386 ]

    mlzboy@ubuntu:~$ 

    在安装完rvm之后,可以使用cap deploy:setup来建立初始的目录了

    这里由于之前linode中使用的是p0版本的ruby,这里使用的是p136版本的,因此在deploy.rb中需要进行一下变更

    接下来安装passenger
    gem install passenger
    由于现在是在国内,你得容忍一下速度
    再接下来独立安装nginx稳定版本(由于之前在linode时为15-1688提前安装好的)这里为了统一,也使用独立安装稳定版本的nginx而不是使用passenger整合版本
    wget http://nginx.org/download/nginx-0.7.68.tar.gz
    tar -zxvf ./nginx-0.7.68.tar.gz
    今天先到这
    先开启rsync
    cd ~/b2c2/shared/
    rsync -avr --progress mlzboy@boy38girl.com:/home/mlzboy/b2c2/shared/system .
    安装nginx 和passenger
     rvmsudo passenger-install-nginx-module
    回车,选择2. No: I want to customize my Nginx installation. (for advanced users)
    填写nginx的source 路径 :/home/mlzboy/nginx-0.7.68
    填写nginx的安装路径:/usr/local/nginx
    填写额外的nginx参数:--with-http_flv_module --with-http_gzip_static_module
    The Nginx configure script will be run as follows:

      sh ./configure --prefix='/usr/local/nginx' --with-http_ssl_module --add-module='/home/mlzboy/.rvm/gems/ruby-1.9.2-p136/gems/passenger-3.0.2/ext/nginx' --with-http_flv_module --with-http_gzip_static_module

    Is this what you want? (yes/no) [default=yes]: 
    填yes

    进入

    cd /usr/local/nginx/conf

    给conf目录以权限

    sudo chmod -R 777 ./conf

    备份nginx.conf

    cp ./nginx.conf ./nginx.conf.bak.20110211

    从linode下载原来的nginx.conf

    scp mlzboy@boy38girl.com:/usr/local/nginx/conf/nginx.conf ./

    由于ruby的版本从p0改为p136,因此要修改一下nginx.conf中的设置,改为

        passenger_root /home/mlzboy/.rvm/gems/ruby-1.9.2-p136/gems/passenger-3.0.2;

        passenger_ruby /home/mlzboy/.rvm/wrappers/ruby-1.9.2-p136/ruby;

    安装完mysql后

    备份配置文件

    cd /etc/mysql

    sudo cp my.cnf ./my.cnf.bak.20110211

    sudo rm my.cnf

    从linode拷贝my.cnf过来

    sudo scp mlzboy@boy38girl.com:/etc/mysql/my.cnf .

    重启服务


    sudo service mysql restart
    调整时区和同步时间和格式
    最后效果应该是这样
    mlzboy@ubuntu:/etc/mysql$ date
    2011年 02月 11日 星期五 10:16:21 CST
    修改mysql数据库的远程访问权限
    二、Mysql数据库的修改
    注意后面得show databases;
    use mysql;
    1) [root@etc etc]# mysql -u  root  -p
    Enter password:
    2)mysql> 
    3)mysql> select host,user,password from user;
    4)grant all privileges on *.* to  root@192.168.1.100  identified by 'password'
     grant all on *.* to root@'%' identified by '密码'
     注意: (1)192.168.15.101是欲连接到此Mysql数据库的客户端的IP地址,而不是Mysql数据库所在数据库服务器的IP地址,切记
                  (2)password就是Mysql数据库root用户的password,根据实际情况需要修改
    安装memcached
    sudo apt-get install libevent-dev wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz tar -zxvf ./memcached-1.4.5.tar.gz cd ./memcached-1.4.5  
    1. ./configure  
    2. make && make test  
    3. sudo make install
      启动memcached命令 memcached -d -l localhost 克隆远程仓库 mkdir git cd ~/git git clone --bare boy38girl.com:/home/mlzboy/git/b2c2.git 然后可以在本地找一个地方进行测试 git clone 115.236.18.xx:/home/mlzboy/git/b2c2.git
    以上关于git的这一块参考了
    进入本地cd ~/my/b2c2
    git remote add netbank mlzboy@115.236.18.xxx:/home/mlzboy/git/b2c2.git
    查看现有的远程仓库列表
    git remote -v
     mlzboy@mlzboy-MacBook ~/my/b2c2 $ git push netbank master
    Everything up-to-date
    下面这部分主要参考了
    使用cap:deploy进行部署
    进入到cd ~/b2c2/shared
    mkdir config
    cd config
    scp mlzboy@boy38girl.com:/home/mlzboy/b2c2/shared/config/database.yml .
    scp mlzboy@boy38girl.com:/home/mlzboy/b2c2/shared/config/smtp_gmail.yml .
    以下部分参考
    show databases;
    create database b2c2_production;
    上传本地备份数据库
    cap sync:up

    进入到/home/mlzboy/b2c2/current下执行

    这条命令似乎不能在byobu中执行,不知道是不是错觉

    ar_sendmail_rails3 -d -e production --delay 2

    以下部分参考

    http://www.cnblogs.com/lexus/archive/2010/12/15/1907212.html

    1.首先是要添加locale的支持

    sudo locale-gen zh_CN.GBK
    sudo locale-gen zh_CN.GB2312
    sudo locale-gen zh_CN.GB18030
    

    2.更新一下locale:

    sudo dpkg-reconfigure locales


  • 相关阅读:
    【C++日常】C++动态命名变量名
    两个整数相除
    Jsp页面跳转 接收时的乱码问题
    Reverse a singly linked list
    Java处理excel文件
    Navicat for mysql 破解
    EasyUi 分页 和 表格数据加载
    Spring 框架下Controller 返回结果在EasyUI显示
    svn ubuntu command(转载)
    Shiro Security
  • 原文地址:https://www.cnblogs.com/lexus/p/1950943.html
Copyright © 2011-2022 走看看