当前位置:   article > 正文

Ubuntu系统安装 git及过程报错解决_ubuntu无法安装git

ubuntu无法安装git

一、下载安装包

  1. 下载Linux下的Git安装包,地址:

https://mirrors.edge.kernel.org/pub/software/scm/git/
  1. 将下载的压缩包上传至Linux服务器的/usr目录下面

  1. 进入到/usr目录下:cd /usr

  1. 解压压缩包:

tar -zxvf git-2.9.5.tar.gz

5.进入到解压后的文件夹:

cd git-2.9.5

6. 编译Git源码:

make prefix=/usr/local/git all

7.安装Git到/usr/local/git路径:

make prefix=/usr/local/git install

8. 配置环境变量:

sudo vi /etc/profile

9.在环境变量配置文件最后加上:

export PATH=$PATH:/usr/local/git/bin

10. 刷新环境变量:

source /etc/profile

11. 查看Git是否安装完成:

git --version

二、安装过程报错解决

  1. fatal error: openssl/ssl.h: No such file or directory

解决方法:

sudo apt-get install libssl-dev

提示界面如下:

问题现象:

在安装libssl-dev 的时候提示错误:

解决方法:

linux的版本依赖问题很令人纠结,不过我们可以通过使用aptitude软件包管理器来解决这个依赖问题,aptitude是可以选择合适的版本与匹配软件安装。

首先安装aptitude工具

sudo apt-get install aptitude

再利用aptitude来安装libssl-dev

sudo aptitude install libssl-dev
  1. sqtu@ubuntu:/usr/git-2.9.5$ sudo aptitude install libssl-dev
  2. The following NEW packages will be installed:
  3. libssl-dev{b}
  4. 0 packages upgraded, 1 newly installed, 0 to remove and 36 not upgraded.
  5. Need to get 1,372 kB of archives. After unpacking 6,863 kB will be used.
  6. The following packages have unmet dependencies:
  7. libssl-dev : Depends: libssl1.1 (= 1.1.0g-2ubuntu4) but 1.1.1-1ubuntu2.1~18.04.6 is installed
  8. The following actions will resolve these dependencies:
  9. Keep the following packages at their current version:
  10. 1) libssl-dev [Not Installed]
  11. Accept this solution? [Y/n/q/?] n
  12. The following actions will resolve these dependencies:
  13. Upgrade the following packages:
  14. 1) libmysqlclient20 [5.7.30-0ubuntu0.18.04.1 (now) -> 5.7.33-0ubuntu0.16.04.
  15. Downgrade the following packages:
  16. 2) libpython2.7 [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)]
  17. 3) libpython2.7-minimal [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic
  18. 4) libpython2.7-stdlib [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)
  19. 5) libssl1.1 [1.1.1-1ubuntu2.1~18.04.6 (now) -> 1.1.0g-2ubuntu4 (bionic)]
  20. 6) python2.7 [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)]
  21. 7) python2.7-minimal [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)]
  22. Accept this solution? [Y/n/q/?] y
  23. The following packages will be DOWNGRADED:
  24. libpython2.7 libpython2.7-minimal libpython2.7-stdlib libssl1.1 python2.7
  25. python2.7-minimal
  26. The following NEW packages will be installed:
  27. libssl-dev
  28. The following packages will be upgraded:
  29. libmysqlclient20
  30. 1 packages upgraded, 1 newly installed, 6 downgraded, 0 to remove and 35 not upgraded.
  31. Need to get 8,010 kB of archives. After unpacking 6,265 kB will be used.
  32. Do you want to continue? [Y/n/?] y
  33. Get: 1 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libmysqlclient20 amd64 5.7.33-0ubuntu0.16.04.1 [684 kB]
  34. Get: 2 http://archive.ubuntu.com/ubuntu bionic/main amd64 python2.7 amd64 2.7.15~rc1-1 [238 kB]
  35. Get: 3 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpython2.7 amd64 2.7.15~rc1-1 [1,053 kB]
  36. Get: 4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpython2.7-stdlib amd64 2.7.15~rc1-1 [1,910 kB]
  37. Get: 5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libssl1.1 amd64 1.1.0g-2ubuntu4 [1,128 kB]
  38. Get: 6 http://archive.ubuntu.com/ubuntu bionic/main amd64 python2.7-minimal amd64 2.7.15~rc1-1 [1,292 kB]
  39. Get: 7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpython2.7-minimal amd64 2.7.15~rc1-1 [334 kB]
  40. Get: 8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libssl-dev amd64 1.1.0g-2ubuntu4 [1,372 kB]
  41. Fetched 8,010 kB in 8s (1,045 kB/s)
  42. Preconfiguring packages ...
  43. dpkg: warning: downgrading python2.7 from 2.7.17-1~18.04ubuntu1 to 2.7.15~rc1-1
  44. (Reading database ... 142514 files and directories currently installed.)
  45. Preparing to unpack .../0-python2.7_2.7.15~rc1-1_amd64.deb ...
  46. Unpacking python2.7 (2.7.15~rc1-1) over (2.7.17-1~18.04ubuntu1) ...
  47. dpkg: warning: downgrading libpython2.7:amd64 from 2.7.17-1~18.04ubuntu1 to 2.7.15~rc1-1
  48. Preparing to unpack .../1-libpython2.7_2.7.15~rc1-1_amd64.deb ...
  49. Unpacking libpython2.7:amd64 (2.7.15~rc1-1) over (2.7.17-1~18.04ubuntu1) ...
  50. Preparing to unpack .../2-libmysqlclient20_5.7.33-0ubuntu0.16.04.1_amd64.deb ...
  51. Unpacking libmysqlclient20:amd64 (5.7.33-0ubuntu0.16.04.1) over (5.7.30-0ubuntu0.18.04.1) ...
  52. dpkg: warning: downgrading libpython2.7-stdlib:amd64 from 2.7.17-1~18.04ubuntu1 to 2.7.15~rc1-1
  53. Preparing to unpack .../3-libpython2.7-stdlib_2.7.15~rc1-1_amd64.deb ...
  54. Unpacking libpython2.7-stdlib:amd64 (2.7.15~rc1-1) over (2.7.17-1~18.04ubuntu1) ...
  55. dpkg: warning: downgrading libssl1.1:amd64 from 1.1.1-1ubuntu2.1~18.04.6 to 1.1.0g-2ubuntu4
  56. Preparing to unpack .../4-libssl1.1_1.1.0g-2ubuntu4_amd64.deb ...
  57. Unpacking libssl1.1:amd64 (1.1.0g-2ubuntu4) over (1.1.1-1ubuntu2.1~18.04.6) ...
  58. dpkg: warning: downgrading python2.7-minimal from 2.7.17-1~18.04ubuntu1 to 2.7.15~rc1-1
  59. Preparing to unpack .../5-python2.7-minimal_2.7.15~rc1-1_amd64.deb ...
  60. Unpacking python2.7-minimal (2.7.15~rc1-1) over (2.7.17-1~18.04ubuntu1) ...
  61. dpkg: warning: downgrading libpython2.7-minimal:amd64 from 2.7.17-1~18.04ubuntu1 to 2.7.15~rc1-1
  62. Preparing to unpack .../6-libpython2.7-minimal_2.7.15~rc1-1_amd64.deb ...
  63. Unpacking libpython2.7-minimal:amd64 (2.7.15~rc1-1) over (2.7.17-1~18.04ubuntu1) ...
  64. Selecting previously unselected package libssl-dev:amd64.
  65. Preparing to unpack .../7-libssl-dev_1.1.0g-2ubuntu4_amd64.deb ...
  66. Unpacking libssl-dev:amd64 (1.1.0g-2ubuntu4) ...
  67. Processing triggers for mime-support (3.60ubuntu1) ...
  68. Processing triggers for desktop-file-utils (0.23-1ubuntu3) ...
  69. Processing triggers for libc-bin (2.27-3ubuntu1) ...
  70. Setting up libssl1.1:amd64 (1.1.0g-2ubuntu4) ...
  71. Processing triggers for man-db (2.8.3-2) ...
  72. Setting up libmysqlclient20:amd64 (5.7.33-0ubuntu0.16.04.1) ...
  73. Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
  74. Setting up libpython2.7-minimal:amd64 (2.7.15~rc1-1) ...
  75. Setting up libpython2.7-stdlib:amd64 (2.7.15~rc1-1) ...
  76. Setting up python2.7-minimal (2.7.15~rc1-1) ...
  77. Setting up libssl-dev:amd64 (1.1.0g-2ubuntu4) ...
  78. Setting up python2.7 (2.7.15~rc1-1) ...
  79. Setting up libpython2.7:amd64 (2.7.15~rc1-1) ...
  80. Processing triggers for libc-bin (2.27-3ubuntu1) ...
  81. Current status: 35 (-1) upgradable.

至此,问题解决,以后遇到版本不对导致依赖不对应的问题也可以采用上述的方法进行解决。

  1. fatal error: zlib.h: No such file or directory

解决方法:

sudo apt-get install zlib1g-dev

  1. fatal error: curl/curl.h: No such file or directory

解决方法:

sudo apt-get install libcurl4-openssl-dev

  1. fatal error: expat.h: No such file or directory

解决方法:

sudo apt-get install libexpat1-dev

  1. MSGFMT po/pt_pt.msg Makefile:254: recipe for target 'po/pt_pt.msg' failed

make[1]: *** [po/pt_pt.msg] Error 127

Makefile:2159: recipe for target 'all' failed

make: *** [all] Error 2

解决方法:

sudo apt install gettext

  1. cc: not found

解决方法:

sudo apt install gcc

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/814842
推荐阅读
相关标签
  

闽ICP备14008679号