• linux非root用户下安装软件,搭建生产环境


    之前的用实验室的服务器,因为某些原因,使用的用户没有root权限。linux的非root用户很多软件无法安装,非常的不方便。我的方法是使用brew来代替系统的包管理工具。brew是最先用在mac上的包管理工具,可以将所有的包托管在user本地的环境内。下面的文档中运行的时候记得将用户名改成自己的。

    1. 安装anaconda

    下载官方anaconda python安装包(minicondo也行),将conda加入~/.bashrc的系统变量中(在安装中会提示你运行 conda init,点yes就会直接复制到~/.bashrc中了)。这一步的目的是去安装curl, curl是下载安装brew必备的工具,此时curl会安装在/home/username/anaconda3/bin中

    conda install curl --use-local
    

    建议这里装完再装一个vim,方便文本编辑

    2. 安装brew

    使用curl命令下载安装brew,中间有一些错误不用管他,结束后输入brew有返回就说明安装成功

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
    

    之后将一下brew加入~/.bashrc中

    export HOMEBREW_PREFIX="/home/username/.linuxbrew";
    export HOMEBREW_CELLAR="/home/username/.linuxbrew/Cellar";
    export HOMEBREW_REPOSITORY="/home/username/.linuxbrew/Homebrew";
    export PATH="/home/username/.linuxbrew/bin:/home/username/.linuxbrew/sbin:$PATH";
    export MANPATH="/home/username/.linuxbrew/share/man:$MANPATH";
    export INFOPATH="/home/username/.linuxbrew/share/info:$INFOPATH";
    

    此时保证brew已经是一个可以在终端被调用, 接下来是关键的一步

    在/home/username/.linuxbrew/Homebrew/Library/Homebrew/brew.sh#L200上进行加上一行

    if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
          -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
             "$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null
    then
      HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl"
    elif [[ -n "$HOMEBREW_DEVELOPER" && -x "$HOMEBREW_CURL_PATH" ]]
    then
      HOMEBREW_CURL="$HOMEBREW_CURL_PATH"
    else
      HOMEBREW_CURL="curl"
    fi
    HOMEBREW_CURL="/home/username/anaconda/bin/curl" # 加上这一行!
    

    然后输入 brew install curl

    装完之后brew.sh会自动抹去自己之前的修改 : ),然后brew就正式能用了

    比如 brew install tmux, brew install htop,只有brew有的包都可以装(参考包列表https://formulae.brew.sh/formula/)

    3. 手动编译安装软件包

    如果brew里面没有某个包,需要自己编译的话,一般的linux软件包都是make编译的,一般修改下configure然后再make && make install 就好了,如下三行命令:

    ./configure --prefix=/home/username/.local
    make
    make install
    # 如果要卸载 运行 make uninstall
    

    最后分享下我的~/.bashrc ,其中 ~/.local/bin~/.local/lib加到PATH里面是为了自己编译安装用的。

    export PATH=~/.local/bin:$PATH
    export C_INCLUDE_PATH=$C_INCLUDE_PATH:~/.local/include
    export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:~/.local/include
    export LD_LIBRARY_PATH=~/.local/lib:$LD_LIBRARY_PATH
    
    
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/home/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/home/username/anaconda3/etc/profile.d/conda.sh" ]; then
            . "/home/username/anaconda3/etc/profile.d/conda.sh"
        else
            export PATH="/home/username/anaconda3/bin:$PATH"
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<
    
    export HOMEBREW_PREFIX="/home/username/.linuxbrew";
    export HOMEBREW_CELLAR="/home/username/.linuxbrew/Cellar";
    export HOMEBREW_REPOSITORY="/home/username/.linuxbrew/Homebrew";
    export PATH="/home/username/.linuxbrew/bin:/home/username/.linuxbrew/sbin:$PATH";
    export MANPATH="/home/username/.linuxbrew/share/man:$MANPATH";
    export INFOPATH="/home/username/.linuxbrew/share/info:$INFOPATH";
    
  • 相关阅读:
    OSGi系列 Apache Felix初体检
    OSGi系列 我理解的OSGi
    OSGi系列 开发服务端Web应用之一:Servlet实现
    10 Productivity Tips
    在DotNetNuke中通过修改ascx文件源码自定义界面
    DNN4.3.3的版本开发的模块.没登陆DNN的情况下,按钮的事件有时候执行,有时候怎么点都不执行
    DotNetNuke(DNN)网站发布、部署、迁移和重建
    使用3dmax 9.0导入Illustrator 文件时提示"Line in file exceeds 255 characters"
    ”A page can have only one serverside Form tag“错误
    DotNetNuke出错:“Runat 属性必须具有值 Server(The Runat attribute must have the value Server Error)"
  • 原文地址:https://www.cnblogs.com/Basasuya/p/11535055.html
Copyright © 2020-2023  润新知