Hướng dẫn cài đặt OpenLiteSpeed trên VPS sử dụng DirectAdmin

Như vậy là hôm qua ngày 25/5/2019 DirectAdmin đã cho ra mắt phiên bản 1.57.0 hỗ trợ OpenLiteSpeed. Bài viết này sẽ hướng dẫn các bạn cách cài đặt OpenLiteSpeed trên VPS sử dụng DirectAdmin.

Giới thiệu sơ qua thì OpenLiteSpeed ​​là phiên bản mã nguồn mở của LiteSpeed ​​Web Server Enterprise. OpenLiteSpeed ​​chứa tất cả các tính năng cần thiết có trong LiteSpeed ​​Enterprise, bao gồm LSCache (plugin cần thiết cho WordPress).

Để cài đặt OpenLiteSpeed trên VPS sử dụng DirectAdmin thì điều đầu tiên bạn cần kiểm tra đó chính là phiên bản DirectAdmin phải từ 1.57.0 trở lên và bạn phải đang sử dụng CustomBuild 2.0 (Xem thêm bài hướng dẫn nâng cấp CustomBuild 2.0)

Bước 1: Đăng nhập SSH

Bước 2: Chạy lệnh

cd /usr/local/directadmin/custombuild
./build set webserver openlitespeed
./build set php1_mode lsphp
./build openlitespeed
./build php n
./build rewrite_confs

Nếu bạn có nhiều hơn 1 phiên bản php, hãy thêm lệnh set php#_mode lsphp cho tất cả các phiên bản php khác. (trong đó # là 2, 3 hoặc 4)

Ví dụ mình đang chạy tổng cộng 4 phiên bản php thì mình sẽ chạy lệnh như sau:

cd /usr/local/directadmin/custombuild
./build set webserver openlitespeed
./build set php1_mode lsphp
./build set php2_mode lsphp
./build set php3_mode lsphp
./build set php4_mode lsphp
./build openlitespeed
./build php n
./build rewrite_confs

Lưu ý: trong quá trình chạy lệnh ./build openlitespeed nếu bạn gặp lỗi “Openlitespeed webserver configuration option is not compatible with lsphp or php-fastcgi PHP mode with mode_ruid2 enabled.” thì bạn chạy lệnh:

./build set mod_ruid2 no

Sau đó chạy lại lệnh ở Bước 2.

Bước 3: Khi website của bạn sử dụng .htaccess thì bạn cần tạo thêm cronjob có nội dung bên dưới để khi bạn thay đổi file .htaccess thì OpenLiteSpeed sẽ tự động reload lại.

*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi

*/3 có nghĩa là cứ 3 phút sẽ chạy cron 1 lần. Bạn có thể thay thế số 3 thành số khác theo ý bạn.

Chúc các bạn thành công.

Hướng dẫn cài đặt OpenLiteSpeed trên VPS sử dụng DirectAdmin

4.8 (96.3%) 27 votes