Cách cài đặt Flatpress CMS với Let's Encrypt SSL trên Ubuntu 22.04

theanh

Administrator
Nhân viên
FlatPress là một hệ thống quản lý nội dung miễn phí, mã nguồn mở và nhanh nhất. Nó được viết bằng ngôn ngữ PHP và là một công cụ tuyệt vời cho bất kỳ ai không có quyền truy cập cơ sở dữ liệu. Đây là một công cụ viết blog nhẹ, dễ thiết lập và tuyệt vời trong danh mục truyền thông & mạng xã hội. Nó hỗ trợ nhiều ngôn ngữ, plugin, chủ đề, tiện ích và nhiều hơn nữa.

Trong hướng dẫn này, tôi sẽ giải thích cách cài đặt FlatPress trên máy chủ Ubuntu 22.04.

Yêu cầu​

  • Một máy chủ chạy Ubuntu 22.04.
  • Một người dùng không phải root có quyền sudo.

Cài đặt Apache và PHP​

Theo mặc định, PHP 8.1 là phiên bản PHP mặc định trong Ubuntu 22.04. Nhưng FlatPress chỉ hỗ trợ phiên bản PHP 8.0. Vì vậy, bạn sẽ cần thêm kho lưu trữ PHP vào hệ thống của mình. Bạn có thể thêm nó bằng lệnh sau:
Mã:
apt install software-properties-common -y
add-apt-repository ppa:ondrej/php
Sau khi kho lưu trữ được thêm vào, hãy cài đặt Apache, PHP và tất cả các tiện ích mở rộng PHP cần thiết bằng cách chạy lệnh sau lệnh:
Mã:
apt-get install apache2 php8.0 php8.0-mysql php8.0-curl php8.0-cgi libapache2-mod-php8.0 php8.0-mcrypt php8.0-xmlrpc php8.0-gd php8.0-mbstring php8.0 php8.0-common php8.0-xmlrpc php8.0-soap php8.0-xml php8.0-intl php8.0-cli php8.0-ldap php8.0-zip php8.0-readline php8.0-imap php8.0-tidy php8.0-sql php8.0-intl wget unzip -y
Sau khi cài đặt tất cả các gói, hãy khởi động dịch vụ Apache và cho phép nó khởi động khi khởi động bằng lệnh sau:
Mã:
systemctl start apache2
systemctl enable apache2
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Cài đặt FlatPress​

Đầu tiên, hãy truy cập kho lưu trữ FlatPress Git và tải xuống phiên bản mới nhất với lệnh sau:
Mã:
wget https://github.com/flatpressblog/flatpress/archive/1.2.1.zip
Tiếp theo, giải nén tệp đã tải xuống bằng lệnh sau:
Mã:
unzip 1.2.1.zip
Tiếp theo, sao chép thư mục đã giải nén vào thư mục gốc Apache và cấp quyền thích hợp bằng lệnh sau lệnh:
Mã:
cp -r flatpress-1.2.1 /var/www/html/flatpress
Mã:
chown -R www-data.www-data /var/www/html/flatpress
chmod -R 775 /var/www/html/flatpress

Cấu hình Apache cho FlatPress​

Tiếp theo, bạn sẽ cần tạo tệp máy chủ ảo Apache cho Flatpress. Bạn có thể tạo nó bằng lệnh sau:
Mã:
nano /etc/apache2/sites-available/flatpress.conf
Thêm các dòng sau:
Mã:
 ServerAdmin [emailprotected] DocumentRoot /var/www/html/flatpress ServerName flatpress.example.com  AllowOverride All Require all granted  ErrorLog ${APACHE_LOG_DIR}/flatpress_error.log CustomLog ${APACHE_LOG_DIR}/flatpress_access.log combined
Lưu và đóng tệp. Sau đó, kích hoạt máy chủ ảo bằng lệnh sau:
Mã:
a2ensite flatpress
Tiếp theo, kích hoạt mô-đun ghi đè Apache và tải lại dịch vụ Apache bằng lệnh sau:
Mã:
a2enmod rewrite
systemctl restart apache2
Bạn cũng có thể kiểm tra trạng thái Apache bằng lệnh sau lệnh:
Mã:
systemctl status apache2
Bạn sẽ thấy kết quả sau:
Mã:
? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-11-20 11:37:30 UTC; 6s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 100768 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 100772 (apache2) Tasks: 6 (limit: 2242) Memory: 14.3M CPU: 85ms CGroup: /system.slice/apache2.service ??100772 /usr/sbin/apache2 -k start ??100773 /usr/sbin/apache2 -k start ??100774 /usr/sbin/apache2 -k start ??100775 /usr/sbin/apache2 -k start ??100776 /usr/sbin/apache2 -k start ??100777 /usr/sbin/apache2 -k start
Nov 20 11:37:30 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Bảo mật FlatPress bằng Let's Encrypt SSL​

Đó là một ý tưởng hay để bảo mật trang web FlatPress của bạn bằng chứng chỉ SSL Let's Encrypt. Để làm như vậy, bạn sẽ cần cài đặt ứng dụng khách Certbot trong hệ thống của mình. Certbot là một gói ứng dụng khách giúp bạn tải xuống và quản lý chứng chỉ SSL trên trang web của mình.

Bạn có thể cài đặt Certbot bằng lệnh sau:
Mã:
apt-get install certbot python3-certbot-apache -y
Sau khi cài đặt thành công ứng dụng khách Certbot, hãy chạy lệnh sau để cài đặt Let's Encrypt SSL cho trang web của bạn:
Mã:
certbot --apache -d flatpress.example.com
Bạn sẽ được yêu cầu cung cấp 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 apache, Installer apache
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 flatpress.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flatpress-le-ssl.conf
Tiếp theo, hãy chọn có chuyển hướng lưu lượng HTTP sang HTTPS hay không hoặc cấu hình Nginx để chuyển hướng tất cả lưu lượng đến Truy cập HTTPS như được hiển thị trong đầu ra sau:
Mã:
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 cài đặt hoàn tất, bạn sẽ nhận được đầu ra sau:
Mã:
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/flatpress.conf to ssl vhost in /etc/apache2/sites-available/flatpress-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://flatpress.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=flatpress.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/flatpress.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/flatpress.example.com/privkey.pem Your cert will expire on 2023-02-20. 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" - 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
Tại thời điểm này, trang web FlatPress của bạn được bảo mật bằng Let's Encrypt SSL. Bây giờ bạn có thể truy cập trang web của mình một cách an toàn bằng giao thức HTTPS.

Truy cập FlatPress CMS​

Bây giờ, hãy mở trình duyệt web của bạn và nhập URL Bạn sẽ được chuyển hướng đến trang cài đặt FlatPress:'


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22310%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 tạo người dùng Quản trị:


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


Tại đây, hãy cung cấp tên người dùng, mật khẩu, email quản trị viên của bạn 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=%22406%22%3E%3C/svg%3E


Nhấp vào nút Đăng nhập ngay. Bạn sẽ thấy trang sau:


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


Cung cấp tên người dùng, mật khẩu quản trị viên và nhấp vào nút Đăng nhập. Bạn sẽ thấy 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

Kết luận​

Bài hướng dẫn này giải thích cách cài đặt FlatPress với Apache và Let's Encrypt SSL trên Ubuntu 22.04. Bây giờ bạn có thể tạo một trang web và blog đơn giản và nhanh chóng bằng FlatPress CMS. Hãy thoải mái hỏi tôi nếu bạn có bất kỳ câu hỏi nào.
 
Back
Bên trên