百科问答小站 logo
百科问答小站 font logo



阿里云服务器 怎么用git部署代码


user avatar   网友的相关建议: 
      使用阿里云Ubuntu 12.0.4 64位操作系统做git服务器。
首先git服务器有两种访问方式可以选择:http方式和ssh的方式,http方式更容易使用。
1、http方式的git服务器搭建以及使用git命令行访问:
On the Server
1) Install Ubuntu Server, this is the base of our git server obviously
2) Now we need to install a couple of packages, these being ‘git-core’ and ‘apache2′, we do this like so:-
apt-get update
apt-get install apache2 git-core
3) Now we need to create a new folder for your new repository and set some inital permissons, we do this like so:-
cd /var/www
mkdir test-repo.git
cd test-repo.git
git --bare init
git update-server-info
chown -R www-data.www-data .
4) We now need to enable WebDAV on Apache2 of which we will use to serve the repository:-
a2enmod dav_fs
5) We now need to configure the access restrictions to our repository by creating the following file:-
/etc/apache2/conf.d/git.conf
Then fill it in with the following content:-
<Location /test-repo.git>
DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /etc/apache2/passwd.git
Require valid-user
</Location>
Then save and close the file, lets move on to the next bit..
6) Next we need to create a user account of which you will need to use to browse of commit to the repository..
htpasswd -c /etc/apache2/passwd.git <user>
You could then be prompted to enter the password for the user too and confirm it!
7) Ok that’s it for the server side configuration… we just need to restart Apache2 like so and then we should be ready to move on to the client side stuff!
/etc/init.d/apache2 restart
…you can now move on to the client side stuff!
On the client side
Ok so now we need to create a local (on your desktop machine) repository and then we’ll initiate the new remote repository… So, if your using Linux/MacOSX bring up the terminal and type the following commands:-
mkdir ~/Desktop/test-project
cd ~/Desktop/test-project
git init
git remote add origin http://<user>@<server name or IP address>/test-project.git
touch README
git add .
git commit -a -m “Initial import”
git push origin master
Done! – Your intiial file named ‘README’ which currently is just blank has now been committed and you’ve pushed your code to your new git server which has now completed the Git reposity creation process, now in future you can ‘clone’ your resposity like so:-
git clone <user>@<server name or IP address>/test-project.git

注意上面连接http://<user>@<server name or IP address>/test-project.git中的user就是你htpasswd -c /etc/apache2/passwd.git <user>输入的用户名。
另外新建仓库的时候,只需执行:
cd /var/www
mkdir 项目名
cd 项目名
git --bare init
git update-server-info
chown -R www-data.www-data .
然后在/etc/apache2/conf.d/git.conf中对应添加上面类似段即可。
其中:
AuthUserFile 密码文件名
后面的文件就是你指定的密码文件,你可以
htpasswd -c 密码文件名 <user>
对应指定该项目的用户名和密码即可。添加用户是不要-c参数:
htpasswd 密码文件名 <user>



相关阿里云话题

阿里云服务器linux账号怎么看
阿里云服务器怎么部署多个nodejs
阿里云服务器,win后缀域名
阿里云服务器怎样设置crontab
如何查看阿里云服务器用户名和密码,是不是所有用户都是root?我死活登不上Xftp
只知道阿里云服务器登录名和密码能登录到阿里云服务器吗?怎么弄?
阿里云ECS服务器配置好环境了为什么公网IP不能访问
阿里云服务器怎么开启ssh服务器配置
阿里云服务器ECSMySQL数据库忘记密码怎么办
阿里云服务器Linux系统如何安装主机宝控制面板
阿里云服务器怎样建立多个网站并分别绑定域名
我的阿里云服务器大概能承受多少人同时在线
公司给了我阿里云服务器的账户、密码、IP地址,请问我要怎么使用?
我买了一台阿里云的服务器,但是域名备案没有下来,我想通过ip+不同端口实现外网访问加数据,如何设置?
阿里云服务器ECS上面能否安装Sqlserver2008企业版
买了阿里云服务器,没有域名,怎样上传h5游戏?怎样可以把H5游戏给用户玩?
使用阿里云服务器遇到出网到达最高点,导致服务器登录不上,后来重启阿里云服务器才解决
阿里云服务器垃圾么
阿里云服务器美国节点WINDOWS端如何架设VPN?
香港阿里云服务器 域名需要备案吗



前一个讨论
如何在阿里云服务器上部署SVN服务
下一个讨论
阿里云服务器linux账号怎么看





© 2024-06-27 - tinynew.org. All Rights Reserved.
© 2024-06-27 - tinynew.org. 保留所有权利