首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置.cpanel.yml文件以上传所有内容

设置.cpanel.yml文件以上传所有内容
EN

Stack Overflow用户
提问于 2018-12-08 05:08:18
回答 4查看 2K关注 0票数 2

刚刚开始学习如何使用cPanel在我的服务器上设置git存储库。它说我必须在根文件夹中有一个名为.cpanel.yml的文件,它才能工作。

它给了我这个文件示例:

代码语言:javascript
复制
    ---
deployment:
  tasks:
    - export DEPLOYPATH=/home/user/public_html/
    - /bin/cp index.html $DEPLOYPATH
    - /bin/cp style.css $DEPLOYPATH

什么是我有必要写在这里,而不是5-6行上传所有东西?如果应该上传到home/user/public_html文件夹,我认为第4行是正确的。

谢谢你的帮助。

EN

回答 4

Stack Overflow用户

发布于 2020-10-02 02:57:38

因为我发现它是一个挑战,而且没有好的文档,所以我把我用过的东西贴出来。将USERPROJECT替换为您自己的文件夹。

代码语言:javascript
复制
---
deployment:
  tasks:
    # NOTE: public_html on cPanel must not be removed or renamed.
    # This folder has owner USER:nobody, and the USER user does not have
    # access to change owner. So this folder must stay as-is to keep the nobody
    # group, which is critical to the site working. A new folder won't work.
    - export DEPLOYPATH=/home/USER/public_html
    - export REPOPATH=/home/USER/repositories/PROJECT
    # Remove previous old files, if any.
    - /bin/rm -Rf ${DEPLOYPATH}_old
    # Copy old site files to another directory.
    - /bin/cp -R ${DEPLOYPATH} ${DEPLOYPATH}_old
    # Sync repository files to the deploy target path, excluding .git folder.
    # --delete-after will remove deleted files and folders after syncing.
    - /bin/rsync -aP --exclude '.git' --exclude '.well-known' ${REPOPATH}/ ${DEPLOYPATH} --delete-after
    # Set correct permissions.
    - /bin/chmod 755 ${DEPLOYPATH}
    - /bin/find ${DEPLOYPATH} -type d -exec /bin/chmod 755 '{}' \;
    - /bin/find ${DEPLOYPATH} -type f -exec /bin/chmod 644 '{}' \;

可以使用cp,但这很麻烦,因为您不想复制.git文件夹,而且不能轻松排除文件夹。我使用了rsync

如果您的git存储库没有正确的文件/文件夹权限,则有必要设置权限。如果您从Windows签入代码,则经常会发生这种情况。

您可能需要更改部署过程以供自己使用。有关文件权限,请参阅此指南:https://www.a2hosting.com/kb/cpanel/cpanel-file-features/cpanel-file-manager/file-permissions

票数 2
EN

Stack Overflow用户

发布于 2019-01-02 13:34:38

代码

代码语言:javascript
复制
-export DEPLOYPATH=/home/user/public_html/
- cp index.html $DEPLOYPATH
- cp style.css $DEPLOYPATH 

是linux代码吗?

默认情况下,cp命令使用两个位置参数: source和destination。默认情况下,它只复制文件,而不复制目录。但是,可以向cp传递各种选项和参数来更改此行为。

要复制所有文件,包括子目录,您要使用的命令可能是

代码语言:javascript
复制
/bin/cp -R * $DEPLOYPATH.

这将递归地将所有文件和目录从存储库目录复制到部署路径。

票数 1
EN

Stack Overflow用户

发布于 2019-05-16 12:46:09

您只需要.cpanel.yml的这一部分:

代码语言:javascript
复制
    ---
deployment:
  tasks:

"tasks:“后面列出的部分是选项Linux Bash命令。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53676830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档