php 将 Git 与共享托管计划一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10333503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 21:56:57  来源:igfitidea点击:

Using Git with shared hosting plan

phpgitdeploymentftpshared-hosting

提问by Gladen

So I started using Git together with this workflowto make a personal website (mostly for testing and to learn Git) and I am developing it locally on my laptop using Xampp.

所以我开始使用 Git 和这个工作流程来制作个人网站(主要用于测试和学习 Git),我正在使用 Xampp 在我的笔记本电脑上本地开发它。

But now I would like to make this website public and upload it to my webserver. Problem is, I use a shared hosting plan which means I only have FTP access to my website directory. Can't use SSH or install Git or anything..

但现在我想公开这个网站并将其上传到我的网络服务器。问题是,我使用共享主机计划,这意味着我只能通过 FTP 访问我的网站目录。不能使用 SSH 或安装 Git 或任何东西..

I would like to deploy the website and any updates to that webserver, but I was wondering if that was possible with Git with only FTP access? And if not, what would be an advisable way to update my website? Manually drag an dropping files through Filezilla can get a bit tedious.

我想部署该网站以及对该网络服务器的任何更新,但我想知道仅通过 FTP 访问的 Git 是否可行?如果没有,更新我的网站的最佳方式是什么?通过 Filezilla 手动拖放文件可能会有点乏味。

回答by Simone Carletti

If you have no SSH access to the remote server and the hosting provider doesn't offer a git deploy feature, you won't be able to deploy directly using git.

如果您没有远程服务器的 SSH 访问权限,并且托管服务提供商不提供 git deploy 功能,您将无法直接使用 git 进行部署。

However, it's always a good idea to track your source code regardless the remote options.

但是,不管远程选项如何,跟踪源代码总是一个好主意。

In your case, a good alternative to automate the release process would be to create a simple deploy script in your favorite programming language (Ruby, Python, Bash...) that loads the list of changed files from your git repository and performs an upload via FTP of these files.

在您的情况下,自动化发布过程的一个很好的替代方法是使用您喜欢的编程语言(Ruby、Python、Bash...)创建一个简单的部署脚本,该脚本从您的 git 存储库加载已更改文件的列表并执行上传通过这些文件的 FTP。

A simple search for git-ftpreveals that there are already two projects that seems to do what I suggested:

git-ftp 的简单搜索显示已经有两个项目似乎按照我的建议执行:

回答by positron

If you are in a shared hosting plan, its not a good idea to host your own git server as you'll have both space and bandwidth limitations. You can look out for other options such as githubor if you want to have a private hosting, there is bitbucket

如果您采用共享托管计划,那么托管您自己的 git 服务器不是一个好主意,因为您将有空间和带宽限制。您可以寻找其他选项,例如github,或者如果您想拥有私人托管,则可以使用bitbucket

回答by Frank L?mmer

Maybe think about a different hosting set up?

也许考虑不同的托管设置?

  1. On a VPS you have more freedom but you need to set up everything yourself.
  2. On a cloud PaaS you will get great technology but pay a little more.
  3. As mentioned above: A private repo hoster with ftp deployment option might also work.
  1. 在 VPS 上你有更多的自由,但你需要自己设置一切。
  2. 在云 PaaS 上,您将获得出色的技术,但需要支付更多费用。
  3. 如上所述:具有 ftp 部署选项的私有存储库主机也可能工作。

For me, best productivity is most important. Compare costs of web hosting with costs for web development.

对我来说,最好的生产力是最重要的。比较网络托管成本与网络开发成本。

回答by Joachim Werner

If git is installed on the server (e.g <?php $last_line = system('git --version', $retval); ?>), but you don't have SSH access, perhaps try php-git-bundle.

如果 git 安装在服务器上(例如<?php $last_line = system('git --version', $retval); ?>),但您没有 SSH 访问权限,也许尝试php-git-bundle

回答by TooCooL

This question may be old but there is a shared web hosting which offers git deployment option and SSH access to git pull/push etc: githoster.com

这个问题可能很旧,但有一个共享的虚拟主机,它提供了 git 部署选项和对 git pull/push 等的 SSH 访问:githoster.com

Or there are some scripts you can search in google which will link your github account to your host with git hooks.

或者你可以在谷歌中搜索一些脚本,这些脚本会使用 git hooks 将你的 github 帐户链接到你的主机。

回答by govinda

I also have heard/read (but not yet tried) that git availability on shared hosts is resource-intensive and so the admins shy away from allowing...

我也听说/读过(但还没有尝试过)共享主机上的 git 可用性是资源密集型的,因此管理员回避允许......

But in case you do want to try...

但是,如果您确实想尝试...

http://joemaller.com/908/how-to-install-git-on-a-shared-host/#hosting

http://joemaller.com/908/how-to-install-git-on-a-shared-host/#hosting