Cách cài đặt WonderCMS trên Ubuntu 22.04

theanh

Administrator
Nhân viên
WonderCMS là một CMS mã nguồn mở và cực kỳ nhỏ dạng tệp phẳng, cung cấp một cách đơn giản và dễ dàng hơn để tạo và quản lý các trang web. Nó được viết bằng PHP và jQuery và không yêu cầu bất kỳ cấu hình nào. Nó cung cấp tất cả các tính năng cần thiết có sẵn trong CMS hiện đại. Nó nhanh, phản hồi và không yêu cầu bất kỳ cơ sở dữ liệu nào. Nó cung cấp giao diện người dùng web thân thiện với một menu thả xuống cơ bản duy nhất trong khi kích hoạt các điều khiển chỉnh sửa nội tuyến trên các trang của bạn.

Hướng dẫn này sẽ chỉ cho bạn cách cài đặt WonderCMS với Nginx và Let's Encrypt SSL trên Ubuntu 22.04.

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

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

Cài đặt Nginx và PHP​

Đầu tiên, bạn sẽ cần cài đặt máy chủ web Nginx, PHP và các phụ thuộc khác trên máy chủ của mình. Bạn có thể cài đặt tất cả chúng bằng cách chạy lệnh sau:
Mã:
apt-get install nginx php php-fpm php-mbstring php-curl php-zip -y
Sau khi tất cả các gói được cài đặt, hãy chỉnh sửa tệp cấu hình PHP và sửa đổi một số mặc định cài đặt:
Mã:
nano /etc/php/8.1/fpm/php.ini
Thay đổi các cài đặt sau:
Mã:
upload_max_filesize = 100MB
post_max_size = 100MB
max_execution_time = 300
max_input_vars = 5000
memory_limit = 256M
date.timezone = "UTC"
Lưu và đóng tệp sau đó khởi động lại dịch vụ PHP-FPM để áp dụng thay đổi:
Mã:
systemctl restart php8.1-fpm

Cài đặt WonderCMS Ubuntu 22.04​

Trước tiên, bạn sẽ cần tải xuống phiên bản mới nhất của WonderCMS từ GitHub bằng lệnh sau:
Mã:
wget https://github.com/robiso/wondercms/releases/download/3.3.4/wondercms-334.zip
Sau khi tải xuống hoàn tất, hãy giải nén tệp đã tải xuống vào thư mục gốc web Nginx bằng lệnh sau:
Mã:
unzip wondercms-334.zip -d /var/www/html
Tiếp theo, thay đổi quyền sở hữu và quyền của WonderCMS bằng lệnh sau:
Mã:
chown -R www-data:www-data /var/www/html/wondercms
chmod -R 775 /var/www/html/wondercms
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Cấu hình Nginx cho WonderCMS​

Tiếp theo, bạn sẽ cần tạo tệp cấu hình máy chủ ảo Nginx để lưu trữ WonderCMS bằng Nginx. Bạn có thể tạo tệp này bằng lệnh sau:
Mã:
nano /etc/nginx/conf.d/wondercms.conf
Thêm các dòng sau:
Mã:
server { listen 80; # adapt to your server name server_name wondercms.example.com; # adapt the path root /var/www/html/wondercms; index index.php; # prevent directory listing autoindex off; # rewrite url to make it pretty location / { try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.+)$ /index.php?page=$1 last; } # prevent access to database.js location ~ database.js { return 403; } location ~ cache.json { return 403; } # use php-fpm for dealing with php files
location ~ \.php$ { fastcgi_pass unix:/run/php/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; include snippets/fastcgi-php.conf; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_intercept_errors on; } }
Lưu và đóng tệp, sau đó xác minh Nginx xem có lỗi cú pháp nào không bằng cách sử dụng lệnh sau lệnh:
Mã:
nginx -t
Bạn sẽ nhận được kết quả sau:
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 thay đổi:
Mã:
systemctl restart nginx
Bạn cũng có thể kiểm tra trạng thái Nginx bằng lệnh sau:
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 2022-11-12 14:06:21 UTC; 7s ago Docs: man:nginx(8) Process: 18137 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 18139 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 18140 (nginx) Tasks: 3 (limit: 464122) Memory: 3.4M CGroup: /system.slice/nginx.service ??18140 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" ??18141 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ??18142 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Nov 12 14:06:21 ubuntu22041 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 12 14:06:21 ubuntu22041 systemd[1]: Started A high performance web server and a reverse proxy server.

Truy cập Giao diện Web WonderCMS​

Bây giờ, hãy mở trình duyệt web của bạn và truy cập giao diện web WonderCMS bằng URL Bạn sẽ thấy màn hình sau có chứa mật khẩu đăng nhập:


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


Nhấp vào NHẤP VÀO ĐÂY ĐỂ ĐĂNG NHẬP. Bạn sẽ thấy trang đăng nhập WonderCMS:


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


Cung cấp mật khẩu đăng nhập 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=%22345%22%3E%3C/svg%3E


Nhấp vào Cài đặt bảo mật để thay đổi URL đăng nhập như hiển thị bên dưới:


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


Bây giờ, hãy thay đổi URL đăng nhập và tùy chỉnh trang web của bạn theo yêu cầu của bạn.

Tiếp theo, truy cập WonderCMS bằng URL mới Bạn sẽ thấy trang sau:


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


Chèn bất kỳ nội dung nào bạn muốn viế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=%22349%22%3E%3C/svg%3E

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

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 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 của bạn:
Mã:
certbot --nginx -d wondercms.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 wondercms.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/wondercms.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 quá trình 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/wondercms.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://wondercms.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=wondercms.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/wondercms.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/wondercms.example.com/privkey.pem Your cert will expire on 2023-02-12. 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.

Kết luận​

Xin chúc mừng! Bạn đã cài đặt thành công WonderCMS với Nginx và Let's Encrypt SSL trên Ubuntu 22.04. Bây giờ bạn có thể khám phá WondoerCMS và bắt đầu tạo trang web của riêng bạn thông qua trình duyệt web. 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