Cách cài đặt SuiteCRM trên Ubuntu 20.04

theanh

Administrator
Nhân viên
SuiteCRM là hệ thống CRM miễn phí, mã nguồn mở và dành cho doanh nghiệp do SalesAgility phát triển. Đây là một nhánh của SugarCRM Community Edition. SuiteCRM đi kèm với tất cả các chức năng cần thiết để vận hành bất kỳ doanh nghiệp nào có nhu cầu CRM và ERP. SuiteCRM cung cấp nhiều tính năng bao gồm Tiếp thị qua email, Tích hợp phương tiện truyền thông xã hội, Tự động hóa tiếp thị, Tích hợp trò chuyện nội bộ, Lưu trữ tài liệu, Nhắc nhở, Quản lý tác vụ và nhiều tính năng khác. Bài đăng này sẽ chỉ cho bạn cách cài đặt SuiteCRM với Nginx và Let's Encrypt SSL trên Ubuntu 20.04.

Điều kiện tiên quyết​

  • Máy chủ chạy Ubuntu 20.04.
  • Tên miền hợp lệ được trỏ bằng IP máy chủ của bạn.
  • Mật khẩu gốc được cấu hình trên máy chủ.

Bắt đầu​

Trước khi bắt đầu, bạn sẽ cần cập nhật các gói hệ thống của mình lên phiên bản mới nhất. Bạn có thể cập nhật chúng bằng lệnh sau:
Mã:
apt-get update -y
Sau khi máy chủ của bạn được cập nhật, bạn có thể tiến hành bước tiếp theo.

Cài đặt Nginx, MariaDB và PHP​

Đầu tiên, bạn sẽ cần cài đặt máy chủ web Nginx, MariaDB, PHP và các tiện ích mở rộng PHP khác vào máy chủ của bạn. Bạn có thể cài đặt tất cả chúng bằng lệnh sau:
Mã:
apt-get install nginx mariadb-server php7.4 php7.4-fpm php7.4-gd php7.4-opcache php7.4-mbstring php7.4-xml php7.4-json php7.4-zip php7.4-curl php7.4-imap php-mysql unzip -y
Sau khi cài đặt tất cả các gói, hãy chỉnh sửa tệp php.ini và thay đổi các thiết lập được đề xuất:
Mã:
nano /etc/php/7.4/fpm/php.ini
Thay đổi các mục sau cài đặt:
Mã:
post_max_size = 60M
upload_max_filesize = 60M
memory_limit = 256M
max_input_time = 60
max_execution_time = 5000
date.timezone = Asia/Kolkata
Lưu và đóng tệp, sau đó khởi động lại dịch vụ PHP-FPM để áp dụng các thay đổi.
Mã:
systemctl restart php7.4-fpm
Lúc này, máy chủ LEMP đã được cài đặt trên máy chủ của bạn. Bây giờ bạn có thể tiến hành bước tiếp theo.

Tạo cơ sở dữ liệu cho SuiteCRM​

SuiteCRM yêu cầu một cơ sở dữ liệu để lưu trữ nội dung của chúng. Trước tiên, hãy đăng nhập vào shell MariaDB bằng lệnh sau:
Mã:
mysql
Sau khi đăng nhập, hãy tạo cơ sở dữ liệu và người dùng bằng lệnh sau:
Mã:
MariaDB [(none)]> CREATE DATABASE suitecrm;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON suitecrm.* TO 'suitecrm'@'localhost' IDENTIFIED BY 'password';
Tiếp theo, bạn sẽ cần xóa các đặc quyền để áp dụng thay đổi.
Mã:
MariaDB [(none)]> FLUSH PRIVILEGES;
Tiếp theo, thoát khỏi bảng điều khiển MariaDB bằng lệnh sau:
Mã:
MariaDB [(none)]> EXIT;
Bây giờ, bạn đã có cơ sở dữ liệu và người dùng đã sẵn sàng cho SuiteCRM. Bây giờ bạn có thể tiến hành bước tiếp theo.

Cài đặt SuiteCRM​

Trước tiên, hãy truy cập trang web chính thức của SuiteCRM và tải xuống phiên bản mới nhất của SuiteCRM bằng lệnh sau:
Mã:
wget https://sourceforge.net/projects/suitecrm/files/SuiteCRM-7.11.19.zip
Sau khi tải xuống hoàn tất, hãy giải nén tệp đã tải xuống bằng lệnh sau lệnh:
Mã:
unzip SuiteCRM-7.11.19.zip
Tiếp theo, di chuyển thư mục đã giải nén đến thư mục gốc Nginx bằng lệnh sau:
Mã:
mv SuiteCRM-7.11.19 /var/www/html/suitecrm
Tiếp theo, thiết lập quyền và quyền sở hữu thích hợp cho suitecrm thư mục:
Mã:
chown -R www-data:www-data /var/www/html/suitecrm/
chmod 755 -R /var/www/html/suitecrm/
Sau khi hoàn tất, bạn có thể tiến hành cấu hình Nginx.

Cấu hình Nginx để lưu trữ SuiteCRM​

Tiếp theo, bạn sẽ cần tạo tệp cấu hình máy chủ ảo Nginx để lưu trữ SuiteCRM trên internet. Bạn có thể tạo nó bằng lệnh sau:
Mã:
nano /etc/nginx/conf.d/suitecrm.conf
Thêm các dòng sau:
Mã:
server { listen 80; server_name suitecrm.example.com; root /var/www/html/suitecrm; error_log /var/log/nginx/suitecrm.error; access_log /var/log/nginx/suitecrm.access; client_max_body_size 20M; index index.php index.html index.htm index.nginx-debian.html; location / { # try to serve file directly, fallback to app.php try_files $uri /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } location ~* ^/index.php { # try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } # Don't log favicon location = /favicon.ico { log_not_found off; access_log off; } # Don't log robots location = /robots.txt { access_log off; log_not_found off; } # 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; } # A long browser cache lifetime can speed up repeat visits to your page location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { access_log off; log_not_found off; expires 360d; }
}
Lưu và đóng tệp khi bạn hoàn tất, sau đó xác minh Nginx xem có lỗi cú pháp nào không bằng lệnh sau:
Mã:
nginx -t
Bạn sẽ nhận được thông báo sau đầu ra:
Mã:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Tiếp theo, khởi động lại dịch vụ Nginx để áp dụng các thay đổi:
Mã:
systemctl restart nginx
Để kiểm tra trạng thái của dịch vụ Nginx, hãy chạy lệnh sau lệnh:
Mã:
systemctl status nginx
Bạn sẽ nhận được kết quả đầu ra sau:
Mã:
? nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-05-22 10:16:45 UTC; 4s ago Docs: man:nginx(8) Process: 18988 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 19000 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 19001 (nginx) Tasks: 2 (limit: 2353) Memory: 2.7M CGroup: /system.slice/nginx.service ??19001 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; ??19002 nginx: worker process
May 22 10:16:45 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 22 10:16:45 ubuntu2004 systemd[1]: Started A high performance web server and a reverse proxy server.
Tại thời điểm này, Nginx được cấu hình để phục vụ SuiteCRM. Bây giờ bạn có thể tiếp tục truy cập SuiteCRM.

Truy cập SuiteCRM​

Bây giờ, hãy mở trình duyệt web của bạn và truy cập SuiteCRM bằng URL . Bạn sẽ thấy trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22355%22%3E%3C/svg%3E


Chấp nhận thỏa thuận cấp phép và nhấp vào nút Tiếp theo. Bạn sẽ thấy trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22372%22%3E%3C/svg%3E


Hãy đảm bảo rằng tất cả các điều kiện tiên quyết đã được cài đặt, sau đó nhấp vào nút Tiếp theo. Bạn sẽ thấy trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22330%22%3E%3C/svg%3E



data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22308%22%3E%3C/svg%3E


Cung cấp tên cơ sở dữ liệu, người dùng, mật khẩu, tên người dùng quản trị, mật khẩu, URL SuiteCRM, địa chỉ email, sau đó nhấp vào nút Tiếp theo. Sau khi quá trình cài đặt hoàn tất, bạn sẽ thấy trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22377%22%3E%3C/svg%3E




Bây giờ, hãy nhấp vào nút Tiếp theo. Bạn sẽ thấy trang đăng nhập SuiteCRM:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22388%22%3E%3C/svg%3E


Cung cấp tên người dùng quản trị, mật khẩu và nhấp vào nút ĐĂNG NHẬP. Bạn sẽ thấy bảng điều khiển SuiteCRM trên trang sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22393%22%3E%3C/svg%3E

Bảo mật SuiteCRM với Let's Encrypt​

Tiếp theo, bạn sẽ cần cài đặt gói máy khách Certbot để cài đặt và quản lý Let's Encrypt SSL.

Trước tiên, hãy cài đặt Certbot bằng lệnh sau:
Mã:
apt-get install certbot python3-certbot-nginx -y
Sau khi cài đặt hoàn tất, hãy chạy lệnh sau để cài đặt Let's Encrypt SSL trên trang web:
Mã:
certbot --nginx -d suitecrm.example.com
Bạn sẽ được yêu cầu cung cấp địa chỉ email hợp lệ và chấp nhận điều khoản dịch vụ như hiển thị bên dưới:
Mã:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [emailprotected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for suitecrm.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/suitecrm.conf
Tiếp theo, chọn có chuyển hướng lưu lượng HTTP sang HTTPS hay không như hiển thị bên dưới:
Mã:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Nhập 2 và nhấn Enter để hoàn tất cài đặt. Bạn sẽ thấy kết quả sau:
Mã:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/suitecrm.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://suitecrm.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=suitecrm.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/suitecrm.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/suitecrm.example.com/privkey.pem Your cert will expire on 2021-10-30. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le - We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
Bây giờ, SuiteCRM của bạn được bảo mật bằng Let's Encrypt SSL. Bạn có thể truy cập an toàn bằng URL

Kết luận​

Vậy là xong. Bạn đã cài đặt thành công SuiteCRM với Nginx và Let's Encrypt SSL trên Ubuntu 20.04. Bây giờ bạn có thể triển khai SuiteCRM trong tổ chức của mình. Để biết thêm thông tin, hãy truy cập SuiteCRM hướng dẫn sử dụng.
 
Back
Bên trên