Tag: VPS

  • VPS杂记

    入手VPS好久了,用的是LNMP架构,在Evernote中压了一些笔记,一一贴出来示众~

    安装lnmp
    注:版本可能有更新,0.7为截至2011/06/03的最新版
    [shell]
    wget http://soft.vpser.net/lnmp/lnmp0.7.tar.gz
    tar zxvf lnmp0.7.tar.gz
    cd lnmp0.7/
    ./ubuntu.sh
    [/shell]

    创建虚拟主机
    [shell]
    /root/vhost.sh
    [/shell]

    root账户的使用
    平时使用普通账户登录,需要使用root权限的时候用su命令,然后再输入root命令,使用完root权限之后可以用ctrl+D退出权限,继续使用普通账户权限,这样可以防止权限的混乱

    安装OpenVPN
    [shell]
    wget http://vpsnoc.com/scripts/debian-openvpn.sh
    chmod +x debian-openvpn.sh
    ./debian-openvpn.sh
    [/shell]
    按照提示安装完成后下载keys.tgz,将其解压到OpenVPN安装目录下的config子目录,然后启动OpenVPN就可以使用了

    wordpress的rewrite问题
    默认的规则有点小问题,替换为以下的即可:
    [shell]
    if (!-e $request_filename)
    {
    rewrite (.*) /index.php;
    }
    [/shell]

    WordPress文件权限
    [shell]
    chown -R www.www /blog
    [/shell]

  • Shell 自动补全

    1) /etc/passwd

    It shows like this
    [shell]huxuan:x:1002:1002::/home/huxuan:/bin/bash[/shell]
    in format of
    [shell]Username:Password:User ID (UID):Group ID (GID):User ID Info:Home directory:Command/shell[/shell]

    Make sure the Command/shell is the “/bin/bash” and not the “/bin/sh” which may be the default value.

    2) $HOME$/.bashrc or /etc/bash.bashrc
    Make sure the code blew is not commented out.

    [shell]if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi[/shell]

    3) Reference
    http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/

  • 使用密钥自动登录SSH(更新ssh-copy-id)

    【更新】
    lyxint提醒,发现了ssh-copy-id命令,第二步可以更简单的实现
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname
    其中username为用户名,hostname为服务器VPS的IP地址

    1)在本机生成公钥密钥
    ssh-keygen -t rsa
    一路回车,选择默认路径即可,默认路径为~/.ssh/

    2)将本地公钥上传至服务器
    cat ~/.ssh/id_rsa.pub|ssh username@hostname ‘sh -c “cat – >>~/.ssh/authorized_keys”‘
    其中username为用户名,hostname为服务器VPS的IP地址

    3)ssh设置文件的几点说明(一般是默认即可)
    路径:/etc/ssh/sshd_config
    相关行:
    PubkeyAuthentication yes #开启公钥验证
    #AuthorizedKeysFile %h/.ssh/authorized_keys #公钥的位置,建议使用默认路径