CentminMod là một trong những sự lựa chọn tốt nhất để cài đặt máy chủ LEMP Stack (Linux, Nginx, MySQL, PHP) hiện nay. Chỉ cần một dòng lệnh, CentminMod sẽ tự động cài đặt các thành phần cần thiết của bộ LEMP và cấu hình tối ưu bảo mật và hiệu suất tối ưu cho VPS.
Dưới đây là hướng dẫn cài đặt CentminMod cho các bạn mới làm quen với việc cấu hình, quản trị VPS:
1. Yêu cầu
Để cài đặt CentminMod, các bạn cần chuẩn bị sẵn VPS chạy hệ điều hành CentOS 6 hoặc CentOS 7. Yêu cầu VPS hoàn toàn sạch, chưa cài đặt bất kỳ chương trình hay mã nguồn nào.
Nếu VPS của bạn có 1GB RAM, hãy chọn CentOS 6. Nếu VPS có từ 2GB trở lên, hãy chọn CentOS 7.
2. Cài đặt CentminMod
Hướng dẫn cài đặt bằng tiếng Anh có thể tham khảo ở đây: CentminMod Install.
Có nhiều lựa chọn cài đặt: Stable Release hoặc Beta Release PHP 5.6, PHP 7.0, PHP 7.1, PHP 7.2
Mình lựa chọn bản Beta Release PHP 7.2 do đã sử dụng bản này từ rất lâu và không hề gặp bất kỳ vấn đề bảo mật hay sự cố nào cả
PHP 7.2.x default beta installer
yum -y update; curl -O https://centminmod.com/betainstaller72.sh && chmod 0700 betainstaller72.sh && bash betainstaller72.shThời gian cài đặt có thể kéo dài từ 10-30 phút tùy cấu hình VPS. Sau khi cài đặt thành công, bạn sẽ nhận được thông tin như dưới đây
---------------------------------------------------------------------------Total Curl Installer YUM or DNF Time: 222.9925 secondsTotal YUM Time: 16.552643709 secondsTotal YUM or DNF + Source Download Time: 62.9503Total Nginx First Time Install Time: 560.8699Total PHP First Time Install Time: 742.2163Download From Github Time: 13.2660Total Time Other eg. source compiles: 469.6744Total Centmin Mod Install Time: 1835.7109---------------------------------------------------------------------------Total Install Time (curl yum + cm install + zip download): 2071.9694 seconds---------------------------------------------------------------------------1 Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz1 1750.500---------------------------------------------------------------------------3. Kích hoạt acmetool
CentminMod Beta Release có kèm sẵn ứng dụng acmetool để thiết lập chứng chỉ bảo mật Let’s Encrypt SSL cho website, nhưng không được kích hoạt sẵn. Chúng ta cần kích hoạt acme để hệ thống tự động cài đặt Let’s Encrypt khi tạo vHost.
touch /etc/centminmod/custom_config.incecho "LETSENCRYPT_DETECT='y'" >> /etc/centminmod/custom_config.inc/usr/local/src/centminmod/addons/acmetool.sh acmeupdateChọn y và bấm Enter.
-------------------------------------------------acmetool.sh is in beta testing phaseplease read & provide bug reports &feedback for this tool via the forumshttps://centminmod.com/acmetool-------------------------------------------------
continue [y/n] ?Kích hoạt thành công acmetool
acme.sh updated4. Tạo vHost WordPress
Trước khi tạo vHost WordPress, bạn cần trỏ DNS tên miền về IP của VPS. Nếu không trỏ DNS trước, bạn sẽ gặp lỗi khi acmetool xác thực chứng chỉ Let’s Encrypt cho tên miền.
Để tạo vHost chạy WordPress mới, bạn cần mở menu điều khiển của CentminMod để thực thi. Gõ lệnh sau để truy cập menu: centmin
--------------------------------------------------------------------Setup Server Administration EmailEmails will be used for future notification alert features--------------------------------------------------------------------Hit Enter To Skip...Will be prompted everytime run centmin.sh if both emails not entered--------------------------------------------------------------------enter primary email:enter secondary email:-------------------------------------------------------------------Bạn có thể điền email vào mục Primary Email và Secondary Email như yêu cầu, hoặc bỏ trống, bấm Enter 2 lần để tiếp tục.
Ở lần chạy đầu tiên, CentminMod sẽ cấu hình vài thành phần nên sẽ mất khoảng 1-2 phút trước khi bạn có thể truy cập menu điều khiển.
-------------------------------------------------------- Centmin Mod Menu 123.09beta01 centminmod.com--------------------------------------------------------1). Centmin Install2). Add Nginx vhost domain3). NSD setup domain name DNS4). Nginx Upgrade / Downgrade5). PHP Upgrade / Downgrade6). XCache Re-install7). APC Cache Re-install8). XCache Install9). APC Cache Install10). Memcached Server Re-install11). MariaDB MySQL Upgrade & Management12). Zend OpCache Install/Re-install13). Install/Reinstall Redis PHP Extension14). SELinux disable15). Install/Reinstall ImagicK PHP Extension16). Change SSHD Port Number17). Multi-thread compression: pigz,pbzip2,lbzip2...18). Suhosin PHP Extension install19). Install FFMPEG and FFMPEG PHP Extension20). NSD Install/Re-Install21). Update - Nginx + PHP-FPM + Siege22). Add Wordpress Nginx vhost + Cache Plugin23). Update Centmin Mod Code Base24). Exit--------------------------------------------------------Enter option [ 1 - 24 ]Để tạo website WordPress mới, chọn mục 22) Add WordPress Nginx vhost + Cache Plugin, gõ y để xác nhận và bấm Enter.
Do you want to continue with Nginx vhost site creation ? [y/n]Điền tên miền bạn cần thiết lập (lưu ý không gõ
Enter vhost domain name you want to add (without www. prefix): thuanbui.meBước tiếp theo, bạn chọn n (No), y (Yes) và 4 (issue live cert with HTTPS default)
Create a self-signed SSL certificate Nginx vhost? [y/n]: nGet Letsencrypt SSL certificate Nginx vhost? [y/n]: y
You have 4 options:1. issue staging test cert with HTTP + HTTPS (untrusted)2. issue staging test cert with HTTPS default (untrusted)3. issue live cert with HTTP + HTTPS (trusted)4. issue live cert with HTTPS default (trusted)Enter option number 1-4: 4Tiếp theo, các bạn cần trả lời các câu hỏi liên quan đến thông số username / password và cấu hình bảo mật cho WordPress. Các trả lời y / n mình liệt kê ở trên là lựa chọn thông thường của mình.
Theme Setup:Install CyberChimps Responsive Theme (cyberchimps.com/responsive-theme/) [y/n]: n
Wordpress Setup:Set custom WP Admin Display Name ? [y/n]: yEnter Custom WP Admin Display Name: ThuanInstall Wordpress in subdirectory /blog ? [y/n]: nDisable Auto Generated WP Admin Username / Password ? [y/n]: yDisable wp-login.php password protection ? (less security) [y/n]: y--------------------------!! Security Note !!--------------------------Please choose a stronger Username/Password Combination
Enter desired WP Admin Username: thuanbuiEnter desired WP Admin Password: ********Enter email address for Admin User for Wordpress Installation: ********Tiếp tục, chọn lựa loại Cache bạn muốn sử dụng. Mình khuyến khích chọn 1). KeyCND Cache Enabler. Đây là loại cache được chính tác giả CentminMod khuyên dùng.
Default is to install KeyCDN WP Cache Enabler Pluginas it's more stable and reliable than WP Super Cache.Redis cache may have issues with caching due to long 6hr cache TTLYou can select which caching method to use below:
-------------------------------------------------------- Wordpress Caching--------------------------------------------------------1). KeyCDN Cache Enabler (default & recommended)2). Redis Nginx Level Caching (may have issues with some wp plugins)3). Wordpress Super Cache--------------------------------------------------------Enter option [ 1 - 3 ]Tiếp theo, chọn tên tài khoản FPT và mật khẩu.
Create FTP username for vhost domain (enter username): thuanbuiDo you want to auto generate FTP password (recommended) [y/n]: yCentminMod sẽ bắt đầu chạy các lệnh tạo key bảo mật, quá trình này có thể mất 2-10 phút tùy cấu hình VPS.
Tiếp theo, CentminMod sẽ hỏi bạn có muốn lưu cache cho mobile/tablet không? Chọn n (No) và Enter.
------------------------------------------------------------Setup Wordpress + Cache Enabler for sundayrunning.club------------------------------------------------------------
Using full static page caching may cause problems for mobile & tablet devicevisitors depending on your WP themes used so you may want to exclude those
Do you want to exclude mobile/tablet devices from Cache Enabler caching ? [y/n]: nChờ thêm 2-3 phút để hệ thống tải WordPress và cài đặt các plugins mặc định.
Acmetool sẽ kích hoạt để xác thực chứng chỉ Let’s Encrypt cho tên miền. Bạn cần phải trỏ DNS về IP của VPS trước khi tiếp tục ở bước này.
-------------------------------------------------acmetool.sh is in beta testing phaseplease read & provide bug reports &feedback for this tool via the forumshttps://centminmod.com/acmetool-------------------------------------------------
continue [y/n] ? yNếu cài đặt tất cả thành công, bạn sẽ nhận được thông báo dưới đây. Đồng thời hệ thống sẽ tự động quay lại menu điều khiển của CentminMod
-------------------------------------------------------------vhost for thuanbui.me wordpress setup successfullysundayrunning.club setup info log saved at:/root/centminlogs/centminmod_123.09beta01.b069_111118-034210_thuanbui.me_wordpress_addvhost.log-------------------------------------------------------------Vậy là xong. Các bạn có thể truy cập vào website theo địa chỉ: https://domain.ltd (thay thế domain.ltd bằng tên miền của bạn)
4. Các thư mục cấu hình của CentminMod
Các thư mục cấu hình quan trọng của CentminMod
Thư mục chứa website: /home/nginx/domains/
Thư mục chứa file cấu hình Nginx: /usr/local/nginx/conf
File cấu hình MySQL: /etc/my.cnf