刚刚开始学习如何使用cPanel在我的服务器上设置git存储库。它说我必须在根文件夹中有一个名为.cpanel.yml的文件,它才能工作。
它给了我这个文件示例:
---
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行是正确的。
谢谢你的帮助。
发布于 2020-10-02 02:57:38
因为我发现它是一个挑战,而且没有好的文档,所以我把我用过的东西贴出来。将USER和PROJECT替换为您自己的文件夹。
---
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
发布于 2019-01-02 13:34:38
代码
-export DEPLOYPATH=/home/user/public_html/
- cp index.html $DEPLOYPATH
- cp style.css $DEPLOYPATH 是linux代码吗?
默认情况下,cp命令使用两个位置参数: source和destination。默认情况下,它只复制文件,而不复制目录。但是,可以向cp传递各种选项和参数来更改此行为。
要复制所有文件,包括子目录,您要使用的命令可能是
/bin/cp -R * $DEPLOYPATH.这将递归地将所有文件和目录从存储库目录复制到部署路径。
发布于 2019-05-16 12:46:09
您只需要.cpanel.yml的这一部分:
---
deployment:
tasks:"tasks:“后面列出的部分是选项Linux Bash命令。
https://stackoverflow.com/questions/53676830
复制相似问题