cyrus 发表于 2018-1-12 12:26:20

git用法

  git常用用法
  原文来自:http://learn.linlizhu.com/
  一、git使用:http://blog.jobbole.com/78960/
  1.生成秘钥
  (1)设置Git的user name和email:
  $ git config --global user.name "xuhaiyan"
  $ git config --global user.email "haiyan.xu.vip@gmail.com"
  (2)$ ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com”
  $ cat ~/.ssh/id_rsa.pub
  2.git服务器搭建
  (1)安装插件和git
  yum install -y git
  (2)创建git用户及设定权限
  adduser git passwd git
  (3)初始化仓库
  git init --bare learngit.git
  3.git本地生成多个key
  (1)为github配置新的key ,取名为github
  (2)生成秘钥:ssh-keygen -t rsa -C "xxx@gmail.com" -f ~/.ssh/github
  (3)配置conf文件支持:vi ~/.ssh/config(没有则创建)
  (4)配置参数: Host github.com
  HostName github.com
  User linlizhu
  Port 22
  IdentityFile ~/.ssh/github
  (5)获取公钥添加到github远程:cat ~/.ssh/github.pub
  二、Composer使用
  1.http://www.phpcomposer.com/
  2.http://pkg.phpcomposer.com/
  3.https://packagist.org/packages/
  三、在CenTos 7上开启关闭防火墙
  查询防火墙状态:firewall-cmd --state
  关闭防火墙:systemctl stop firewalld.service
  开启防火墙: systemctl start firewalld.service
  禁止firewall开机启动:systemctl disable firewalld.service
  四、redis安装
  1.下载安装编译:
  # wget http://download.redis.io/releases/redis-2.8.17.tar.gz
  # tar xzf redis-2.8.17.tar.gz
  # cd redis-2.8.17
  # make
  # make install2.设置配置文件路径:
  (1)创建redis文件:mkdir -p /etc/redis
  (2)把配置文件复制到创建的文件:cp redis.conf /etc/redis
  3.修改配置文件:
  # vim /etc/redis/redis.conf
  修改为: daemonize yes
  4.操作:
  启动Redis: /usr/local/bin/redis-server /etc/redis/redis.conf
  关闭:redis-cli shutdown 或 shutdown
  清除缓存:redis-cli flushall
  查看状态 :ss -nlp|grep redis 或 ps -ef | grep redis
  5.PHP7添加redis插件
  (1)wget -c https://github.com/phpredis/phpredis/archive/php7.zip
  (2)unzip php7.zip
  (3)cd phpredis-php7
  (4)/usr/local/php7/bin/phpize
  (5)./configure --with-php-config=/usr/local/php7/bin/php-config
  (6)make/make install
  (7)/usr/local/php7/etc/php.ini 中加入extension="redis.so"
  6.编译安装php7的swoole
  (1)wget -c https://github.com/swoole/swoole-src/archive/swoole-1.7.21-stable.tar.gz
  (2)tar zxvf swoole-1.7.21-stable.tar.gz
  (3)cd swoole-src-swoole-1.7.21-stable/
  (4)/usr/local/php7/bin/phpize
  (5)./configure --with-php-config=/usr/local/php7/bin/php-config
  (6)make make install
  (7)/usr/local/php7/etc/php.ini 中加入extension="swoole.so"
  7.资料
  (1)本地环境安装redis
  http://www.cnblogs.com/yun007/p/3705353.html
  (2)it资料学习
  http://www.jikexueyuan.com/course/
  http://www.runoob.com/
  (3)gitlab服务器仓库
  https://about.gitlab.com/downloads/
  (3.1)配置仓库/etc/gitlab/gitlab.rb 改为服务器ip或域名
  (3.2)gitlab-ctl reconfigure命令编译
  (3.3)配置管理员邮箱:开/etc/gitlab/gitlab.rb,将# gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'换成自己的邮箱
  (4).远程连接数据库

  (4.1)给定权限:GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip'>  flush privileges;
  (4.2)关闭服务器防火墙:
  启动:# systemctl start firewalld
  查看状态:# systemctl status firewalld 或者 firewall-cmd --state
  停止:# systemctl disable firewalld
  禁用:# systemctl stop firewalld
  8.gitlab安装
  https://about.gitlab.com/downloads/#centos7
  (1)yum install curl openssh-server openssh-clients postfix cronie
  service postfix start
  chkconfig postfix on
  lokkit -s http -s ssh
  (2)curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  yum install gitlab-ce
  (3)curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/6/gitlab-ce-XXX.rpm/download
  rpm -i gitlab-ce-XXX.rpm
  如果报错则使用以下:
  curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  yum install gitlab-ce-8.14.10-ce.0.el6.x86_64
  (4)gitlab-ctl reconfigure
  (5)初始化:http://ip地址
  9.服务器上生成多key使用linux
  (1)生成key跟本地一样步骤
  (2)配置config

  host ip地址或域名 user git hostname ip地址或域名 port 22>  laravel教程文档:https://laravel-china.org/laravel-tutorial/5.1/about
  10.walle安装配置文档地址:https://walle-web.io/docs/
  11.nginx
  11.1nginx启动:nginx -c /usr/local/nginx/conf/nginx.conf
  测试配置文件:nginx -t
  从容停止Nginx:kill -QUIT 主进程号
  快速停止Nginx:kill -TERM 主进程号
  强制停止Nginx:pkill -9 主进程号

  平滑重启:kill -HUP 住进称号或进程号文件路径 或 /usr/nginx/sbin/nginx -s>  12.composer使用
  12.1初始化composer
  (1)在根目录下新建composer.json文件并编辑:{"require":{}}------安装composer前提
  (2)使用root以外的用户输入命令:composer update即可生成vender 文件。
  12.2:composer使用小技巧:http://www.phpcomposer.com/5-features-to-know-about-composer-php/
  13.yii2.0权威指南:http://yii2.techbrood.com/guide-index.html
  14.git服务器搭建
  1.创建git用户,切换到git用户,在根目录新建.ssh文件夹,进入.ssh文件夹新建authorized_keys
  2.在git用户根目录新建word工作文件,在word下新建xxx.git仓库
  3.进入xxx.git仓库使用命令git --bare init初始化一个仓库
  4.在开发者端生成key,把公钥添加到git根目录下.ssh/authorized_keys里面,即可完成
  13.资源跨域配置
  13.1 1.根目录配置crossdomain.xml
  2.服务器配置
  添加以下配置
  add_header Access-Control-Allow-Origin *;
  add_header Access-Control-Allow-Headers X-Requested-With;
  add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  使用国内镜像:composer config -g repo.packagist composer https://packagist.phpcomposer.com
  14php fileinfo扩展安装
  检查环境是否支持php -i|grep fileinfo
  下载对应版本扩展wget -O php-5.6.9.tar.gz http://cn2.php.net/get/php-5.6.9.tar.gz/from/this/mirror
  解压tar -zxvf php-5.6.9.tar.gz
  进入对应php版本扩展目录:php-5.6.9/ext/fileinfo
  编译&&安装/usr/local/php/bin/phpize
  ./configure -with-php-config=/usr/local/php/bin/php-config
  make && make install
  vim /usr/local/php/etc/php.ini
  加入:extension=fileinfo.so
页: [1]
查看完整版本: git用法