SuiteCRM 线上代码用 git 管理

更新日期: 2024-03-21 阅读次数: 476 字数: 743 分类: 管理

先吐个槽,我发现让销售用上 CRM 真是一件难事。昨天忍不住爆了粗口,感觉没必要。 大家都在装糊涂,或者为自己那点利益使唤别人,就由着他们吧。少说话,多干活。经验是自己的。

言归正传,我发现 SuiteCRM 中新建了模块,或者修改了内置模块之后。SuiteCRM 的代码也会随之更改,即生成了新的 model 类型。(不得不说,PHP 确实是世界上最好的语言)

所以,除了对线上数据库做好备份之外,还需要对线上的代码做个备份。

git 代码管理的必要性

  • 我发现在变更了大量默认配置之后,线上日志中,出现了大量的报错日志。基本都是跟新增的模块对应的 SQL 查询相关。我非常害怕哪天这个系统崩溃了,最后成了我的责任。关键瞎搞的人也不是我。。。
  • 在增加自定义逻辑时,需要用到 logic hook 功能,即,开发自定义逻辑的 PHP 代码,需要放到 SuiteCRM 的指定目录下。此时,新代码就很有必要做管理跟踪。

.gitignore 文件模板

我从 SuiteCRM 的 github 仓库中找了个 .gitignore 模板。

SuiteCRM/.gitignore at master · salesagility/SuiteCRM (github.com)

在此基础上做了调整。因为很多 SuiteCRM 忽略的文件,例如,custom 中的文件,事件上是我比较关心的,因为涉及到自定义逻辑,及模块 model。

## First part from https://github.com/github/gitignore/blob/master/SugarCRM.gitignore
# Ignore custom .htaccess stuff.
/.htaccess
# Ignore large parts of the annoying cache directory without breaking things.
cache/*
upload/*
!upload/index.html

# Ignore AOD indexes
modules/AOD_Index/Index/*
install/status.json
# Ignore PDF Fonts
modules/AOS_PDF_Templates/PDF_Lib/ttfontdata/

# Connector configuration should also be ignored.
custom/modules/Connectors/connectors/sources/ext/*/*/config.php
# Logs files can safely be ignored.
*.log
## IDE specific items
# Eclipse
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
.elc
auto-save-list
tramp
# IntelliJ Idea
*.iml
*.ipr
*.iws
.idea/
.phpstorm.meta.php
# NetBeans
nbproject/
# Vim
.*.sw[a-z]
*.un~
Session.vim
tags
# Windows
Thumbs.db
Desktop.ini
.DS_Store
.DS_Store?
# Microsoft Visual Studio
*.sln
*.suo
*.phpproj
# Microsoft Visual Studio Code
.vscode
# Disytel
lang_cmp.php
.kdev4/
SuiteCRM.kdev4

#Ignore composer vendor folder
vendor/
public/

.php_cs.cache


#Ignore bower_components
bower_components/
node_modules/


#Ignore Sass Generated files in SuiteP
themes/SuiteP/css/*.map
themes/SuiteP/css/*/*.map
themes/SuiteP/css/*/color-palette.css
themes/SuiteP/css/*/variables.css
tests/_output/*


#Ignore browserstack
BrowserStackLocal
browserstack.err
cache/
custom/**/
.sass-cache/

# Ignore testing environment
build/tmp/

# IMAP testing
fakeImapResource
include/Imap/ImapTestSettings.txt

# Ignore php-cs-fixer cache
.php_cs.cache

# Ignore custom codeception environments so they won't be committed.
tests/_envs/custom.yml
codeception.yml

权限问题

由于我的 SuiteCRM 部署在 /var/www 目录下,目录属于 www-data 用户,所以首先需要将当前登录的账号添加到 www-data 组下,然后给 suitecrm 所在目录添加上组的写权限。 这样才能添加 .gitignore 文件,否则无法保存。

sudo chmod g+w suitecrm

nginx 配置安全问题

Nginx 上将 .git 目录禁止访问,更彻底的方法,最好将所有的隐藏目录都禁用掉。

# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
}

tags: CRM

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式