服务器上部署GIT上线命令

来源:互联网 发布:沈阳seo那家好 编辑:程序博客网 时间:2024/06/02 05:17

服务器上部署GIT上线命令

结构:
服务器+本地环境

1.在服务器git上建立一个裸仓库

# 服务器上$ mkdir project.git$ cd project.git$ git --bare init

2.将你本地的代码上传到服务器

# 在你的电脑上$ cd myproject$ git init$ git add .$ git commit -m 'initial commit'$ git remote add origin git@gitserver:project.git$ git push origin master

3.在服务器的web工作目录下克隆该项目

# 服务器的web工作目录$ git clone git@gitserver:project.git project$ git clone user@IP:repositories/project.git project

4.新建虚拟主机文件
在/usr/local/etc/nginx/site-avaliable目录下复制原配置文件为myproject,修改server_name和root项就可以了。为了便于分析管理,最好也将access_log和error_log项修改为你定义的域名的名字。

server {    listen       80;    server_name  myproject.com;    root         /var/www/myproject/frontend/web/;    index        index.php;    access_log  /usr/local/var/logs/nginx/myproject.access.log  main;    error_log   /usr/local/var/logs/nginx/myproject.error.log;    location / {        index  index.html index.htm index.php;        autoindex   on;        include     /usr/local/etc/nginx/conf.d/php-fpm;     try_files $uri $uri/ /index.php?$args;    }    location = /info {        allow   127.0.0.1;        deny    all;        rewrite (.*) /.info.php;    }    #error_page  404     /404.html;    #error_page  403     /403.html;}

5.建立软连接到/usr/local/etc/nginx/site-enabled/myproject

ln -s /usr/local/etc/nginx/site-avaliable/myproject   /usr/local/etc/nginx/site-enabled/myproject

6.如果你是在本地测试,需要修改/etc/hosts文件

### Host Database## localhost is used to configure the loopback interface# when the system is booting.  Do not change this entry.##127.0.0.1   localhost255.255.255.255 broadcasthost::1             localhost127.0.0.1   myprooject.com

7.如果你的代码已经部署到线上,而你在域名映射方面有点问题,你又想测试你线上的代码是否有问题。你可以在线上配置好虚拟域名,然后在你本地hosts上做映射来测试。就在本地实现了通过域名访问线上代码。

### Host Database## localhost is used to configure the loopback interface# when the system is booting.  Do not change this entry.##127.0.0.1   localhost255.255.255.255 broadcasthost::1             localhost192.110.110.110 myprooject.com #192.110.110.110是指你线上的IP,这里只是举一个例子,无实际意义。
0 0