DevOps

Hướng dẫn cài đặt JFrog Artifactory trên Ubuntu

JFrog Artifactory là một ứng dụng quản lý kho lưu trữ mã nguồn mở có thể tích hợp với các công cụ tích hợp và phân phối liên tục. Đây là một công cụ đa nền tảng cho phép DevOps quản lý nhiều kho lưu trữ gói. Nó cung cấp tính khả dụng cao và sao chép nhiều trang web để tự động hóa đường ống của bạn và cho phép phát hành nhanh hơn.

Trong hướng dẫn này, chúng tôi sẽ chỉ cho bạn cách cài đặt JFrog Artifactory trên Ubuntu 20.04.Ezoic

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

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

Cài đặt JFrog Artifactory

Theo mặc định, JFrog Artifactory không có trong kho lưu trữ mặc định của Ubuntu 20.04. Vì vậy, bạn sẽ cần thêm kho lưu trữ JFrog Artifactory vào hệ thống của mình.

Đầu tiên, cài đặt gói Gnupg2 bằng lệnh sau:

apt-get install gnupg2 -y

Tiếp theo, tải xuống và thêm khóa GPG bằng lệnh sau:

wget -qO - https://api.bintray.com/orgs/jfrog/keys/gpg/public.key | apt-key add -

Tiếp theo, thêm kho lưu trữ JFrog Artifactory bằng lệnh sau:

echo "deb https://jfrog.bintray.com/artifactory-debs bionic main" | tee /etc/apt/sources.list.d/jfrog.list

Sau khi kho lưu trữ được thêm vào, hãy cập nhật kho lưu trữ và cài đặt JFrog Artifactory bằng lệnh sau:

apt-get update -y
apt-get install jfrog-artifactory-oss -y

Sau khi quá trình cài đặt hoàn tất thành công, bạn sẽ nhận được kết quả sau:

************ SUCCESS ****************
The Installation of Artifactory has completed successfully.

NOTE: It is highly recommended to use Artifactory with an external database (MySQL, Oracle, Microsoft SQL Server, PostgreSQL, MariaDB).
      For details about how to configure the database, refer to https://service.jfrog.org/installer/Configuring+the+Database

Start Artifactory with:
> systemctl start artifactory.service

Check Artifactory status with:
> systemctl status artifactory.service


Installation directory was set to /opt/jfrog/artifactory
You can find more information in the log directory /opt/jfrog/artifactory/var/log
System configuration templates can be found under /opt/jfrog/artifactory/var/etc
Copy any configuration you want to modify from the template to /opt/jfrog/artifactory/var/etc/system.yaml

Triggering migration script, this will migrate if needed ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3) ...

Tiếp theo, hãy khởi động dịch vụ Artifactory và cho phép nó khởi động khi khởi động lại hệ thống bằng lệnh sau:

systemctl start artifactory
systemctl enable artifactory

Tiếp theo, hãy xác minh trạng thái của dịch vụ Artifactory bằng lệnh sau:Ezoic

systemctl status artifactory

Bạn sẽ nhận được kết quả sau:

? artifactory.service - Artifactory service
     Loaded: loaded (/lib/systemd/system/artifactory.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-06-07 12:42:39 UTC; 40s ago
    Process: 15671 ExecStart=/opt/jfrog/artifactory/app/bin/artifactoryManage.sh start (code=exited, status=0/SUCCESS)
   Main PID: 17974 (java)
      Tasks: 0 (limit: 9522)
     Memory: 2.4M
     CGroup: /system.slice/artifactory.service
             ? 17974 /opt/jfrog/artifactory/app/third-party/java/bin/java -Djava.util.logging.config.file=/opt/jfrog/artifactory/app/artifacto>

Jun 07 12:42:38 ubuntu2004 su[18380]: (to artifactory) root on none
Jun 07 12:42:38 ubuntu2004 su[18380]: pam_unix(su:session): session opened for user artifactory by (uid=0)
Jun 07 12:42:38 ubuntu2004 su[18380]: pam_unix(su:session): session closed for user artifactory
Jun 07 12:42:38 ubuntu2004 su[18534]: (to artifactory) root on none
Jun 07 12:42:38 ubuntu2004 su[18534]: pam_unix(su:session): session opened for user artifactory by (uid=0)
Jun 07 12:42:39 ubuntu2004 su[18534]: pam_unix(su:session): session closed for user artifactory
Jun 07 12:42:39 ubuntu2004 su[18655]: (to artifactory) root on none
Jun 07 12:42:39 ubuntu2004 su[18655]: pam_unix(su:session): session opened for user artifactory by (uid=0)
Jun 07 12:42:39 ubuntu2004 su[18655]: pam_unix(su:session): session closed for user artifactory
Jun 07 12:42:39 ubuntu2004 systemd[1]: Started Artifactory service.

Tại thời điểm này, Artifactory đã được cài đặt và đang lắng nghe trên cổng 8082. Bây giờ bạn có thể tiến hành bước tiếp theo.

Cấu hình Nginx như một Proxy ngược

Tiếp theo, bạn sẽ cần cấu hình Nginx làm proxy ngược cho JFrog. Trước tiên, hãy cài đặt máy chủ web Nginx bằng lệnh sau:

apt-get install nginx -y

Sau khi cài đặt Nginx, hãy tạo tệp cấu hình máy chủ ảo Nginx mới bằng lệnh sau:

nano /etc/nginx/sites-available/jfrog.conf

Thêm các dòng sau:Ezoic

upstream jfrog {
  server 127.0.0.1:8082 weight=100 max_fails=5 fail_timeout=5;
}

server {
  listen          80;
  server_name     jfrog.congdonglinux.com;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://jfrog/;
  }
}

Lưu và đóng file sau đó kích hoạt máy chủ ảo Nginx bằng lệnh sau:

ln -s /etc/nginx/sites-available/jfrog.conf /etc/nginx/sites-enabled/

Tiếp theo, hãy kiểm tra xem Nginx có lỗi cú pháp nào không bằng lệnh sau:

nginx -t

Bạn sẽ thấy kết quả sau:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Cuối cùng, khởi động lại dịch vụ Nginx để thực hiện các thay đổi:

systemctl restart nginx

Tại thời điểm này, Nginx được cấu hình để phục vụ trang web JFrog. Bây giờ bạn có thể tiến hành bước tiếp theo.

Bảo mật JFrog với Let’s Encrypt SSL

Bạn nên bảo mật JFrog bằng Let’s Encrypt SSL. Trước tiên, hãy thêm kho lưu trữ Certbot bằng lệnh sau:

apt-get install software-properties-common -y
add-apt-repository ppa:ahasenack/certbot-tlssni01-1875471

Tiếp theo, hãy cập nhật kho lưu trữ và cài đặt ứng dụng khách Certbot bằng lệnh sau:

apt-get update -y
apt-get install certbot python3-certbot-nginx -y

Sau khi cài đặt xong ứng dụng Certbot, hãy chạy lệnh sau để tải xuống và cài đặt Let’s Encrypt SSL cho trang web của bạn:

certbot --nginx -d jfrog.congdonglinux.com

Bạn sẽ được yêu cầu cung cấp email hợp lệ và chấp nhận các điều khoản dịch vụ như hiển thị bên dưới:

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): hitjethva@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 jfrog.congdonglinux.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/jfrog.conf

Tiếp theo, chọn có chuyển hướng lưu lượng HTTP sang HTTPS hay không:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 để bắt đầu quá trình. Sau khi chứng chỉ được cài đặt, bạn sẽ thấy kết quả sau:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/jfrog.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://jfrog.congdonglinux.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=jfrog.congdonglinux.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/jfrog.congdonglinux.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/jfrog.congdonglinux.com/privkey.pem
   Your cert will expire on 2020-09-07. 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.

Truy cập Giao diện người dùng web Artifactory

Bây giờ, hãy mở trình duyệt web của bạn và nhập URL  https://jfrog.congdonglinux.com . Bạn sẽ được chuyển hướng đến trang sau:

Cung cấp tên người dùng mặc định là “admin” và mật khẩu là “password”, và nhấp vào  nút Login  . Bạn sẽ thấy trang sau:

Bây giờ, hãy nhấp vào  nút Bắt  đầu  . Bạn sẽ thấy màn hình đặt lại mật khẩu:

Đặt mật khẩu quản trị viên mới và nhấp vào  nút Tiếp theo  . Bạn sẽ thấy màn hình sau:

Đặt URL cơ sở của bạn và nhấp vào  nút Tiếp theo  . Bạn sẽ thấy màn hình sau:

Chọn kho lưu trữ mong muốn của bạn và nhấp vào  nút Tiếp theo  . Bạn sẽ thấy trang sau:

Bây giờ, hãy nhấp vào nút Finish. Bạn sẽ thấy bảng điều khiển Artifactory trong màn hình sau:

Phần kết luận

Trong hướng dẫn trên, chúng ta đã học cách cài đặt JFrog Artifactory trên Ubuntu 20.04. Chúng ta cũng đã học cách bảo mật JFrog bằng Let’s Encrypt SSL. Tôi hy vọng bây giờ bạn có thể dễ dàng cài đặt JFrog trong môi trường sản xuất. Hãy thoải mái hỏi tôi nếu bạn có bất kỳ câu hỏi nào.

Đọc thêm:

https://congdonglinux.com/siglens-la-gi/

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Tags

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !