简体   繁体   English

如何在Linux服务器上不使用sudo安装git

[英]how to install git without sudo on linux server

I tried the following to install git without sudo permissions 我尝试以下安装没有sudo权限的git

wget https://github.com/git/git/archive/v2.1.2.tar.gz -O git.tar.gz
tar -zxf git.tar.gz

cd git-2.1.2/

make configure
./configure --prefix=/usr/local

make install

Can anyone help me how to install git with out sudo? 谁能帮助我如何在不使用sudo的情况下安装git?

As with most autoconf -ed software, you could decide to configure it with --prefix=$HOME/soft/ (or some other prefix belonging to you) 与大多数的autoconf -ed软件,你可以决定configure与它--prefix=$HOME/soft/ (或属于你一些其他的前缀)

Then, since $HOME/soft/ is a directory belonging to you, you won't need any sudo for installation 然后,由于$HOME/soft/是属于您的目录,因此不需要任何sudo进行安装

Of course you'll want to add $HOME/soft/bin/ to your $PATH 当然,您需要将$HOME/soft/bin/$PATH

You may also want to pass --sysconfdir=$HOME/etc and you might pass --program-suffix=-mine (to later run git-mine instead of git ) 您可能还希望传递--sysconfdir=$HOME/etc并且可能传递--program-suffix=-mine (以便稍后运行git-mine而不是git

I strongly recommend to run configure with --help at first, and to read the INSTALL file of your particular software (before compilation time), eg this for git 我强烈建议运行configure--help在第一和阅读INSTALL您的特定软件(编译时间之前)的文件,如git

You may also need to deal with dependencies (be aware of the dependency hell ), so you might need to install other libraries (and perhaps even adjust your $LD_LIBRARY_PATH to add $HOME/soft/lib/ to it, etc). 您可能还需要处理依赖关系 (要注意依赖关系hell ),因此您可能需要安装其他库(甚至可能需要调整$LD_LIBRARY_PATH以向其中添加$HOME/soft/lib/等)。

See also GNU stow 另请参见GNU存放

Read the Installing GIT chapter (notably Installing from Source ) 阅读“ 安装GIT”一章(特别是从源代码安装

In some cases having a discussion with your sysadmin could be easier. 在某些情况下,与系统管理员进行讨论可能会更容易。

Simply choose a prefix that you have permission on, eg a folder inside your user's home: 只需选择一个您有权使用的prefix ,例如用户家中的文件夹:

./configure --prefix=$HOME/opt/
make install

Then you will have to add $HOME/opt/bin/ into your PATH env-var. 然后,您必须将$HOME/opt/bin/PATH env-var中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM