如何在CentOS 6.x/7.x上安装git及最新版

记录下远程登录 方法和解说

1
ssh -p 27304 root@104.194.94.204

远程登录 -p 端口 root 用户名 @ 后面是地址

方式一、yum安装

1
# yum install git

通过yum方式安装,版本比较旧,CentOS6.5上安装好是1.7.1版。如果想安装最新版或其他版本,需要使用源码编译安装的方式。

方式二、源码包安装

步骤1. 安装依赖包

1
2
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker

步骤2. 卸载旧的git版本(如果之前有安装rpm包)

1
2
# yum remove git

步骤3. 下载&解压

1
2
3
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz
# tar -zxvf git-2.5.0.tar.gz

或 # wget https://github.com/git/git/archive/v2.5.0.tar.gz 下载

步骤4. 编译安装

1
2
3
4
5
# cd git-2.5.0
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc

步骤5. 检查git版本

1
2
# git --version
git version 2.5.0

转载的
https://my.oschina.net/antsky/blog/514586
// 这个说的时git 使用配置自动部署hexo
http://www.swiftyper.com/2016/04/17/deploy-hexo-with-git-hook/

//配置git 后自动部署hexo
http://www.swiftyper.com/2016/04/17/deploy-hexo-with-git-hook/

// nginx 配置
https://gist.github.com/czboosj/cbbf6a44a8bc8a6802ebc7716ca29ec1

http://www.cnblogs.com/liscookie/p/4032928.html

安装完nginx服务器后发现nginx的根目录在/usr/share/nginx/html/下,但是对于部署文件来说,在该目录下是不太习惯的,我就尝试着更改nginx访问的根目录

1
# vi /etc/nginx/conf.d/default.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# The default server
#
server {
listen 80;
server_name localhost;
root /var/www; #修改新的目录为var下的www目录
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /var/www;
index index.html index.htm index.php index.phtml; #添加index.php和index.phtml
# example
#ModSecurityEnabled on;
#ModSecurityConfig /etc/nginx/modsecurity.conf;
}
error_page 404 /404.html;
location = /404.html {
root /var/www; #修改新的目录文件
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www; #修改新的目录文件
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www; #修改新的目录文件
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
参考:http://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-x-7-x
Author

陈昭

Posted on

2016-11-05

Updated on

2021-12-27

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Kommentare

You forgot to set the shortname for Disqus. Please set it in _config.yml.