Hướng dẫn cài đặt tối ưu Direct Admin

Trong các Control panel hiện nay thì Direct Admin là một sự lựa chọn rất tốt dùng để quản lý, tuy nhiên chúng ta cần phải bỏ tiền ra để mua nó. Còn sau đây là cách cài đặt tối ưu cho VPS chạy CentOS 7 của bạn.

Trước khi tiền hành cài đặt chúng ta cần tải các gói cần thiết cho Direct Admin(DA)

yum install wget gcc gcc-c++ flex bison make bind bind-libs bind-utils openssl openssl-devel perl quota libaio \
libcom_err-devel libcurl-devel gd zlib-devel zip unzip libcap-devel cronie bzip2 cyrus-sasl-devel perl-ExtUtils-Embed \
autoconf automake libtool which patch mailx bzip2-devel lsof glibc-headers kernel-devel expat-devel
yum install psmisc net-tools systemd-devel libdb-devel perl-DBI xfsprogs rsyslog logrotate crontabs file

Đợi cài xong ta tiền hành tải gói cài đặt DA về và cài:

wget http://www.directadmin.com/setup.sh && chmod 755 setup.sh 
./setup.sh

Tại đây DA sẽ hỏi bạn cài các gói cần thiết, tuy nhiên chúng ta đã cài sẵn ở trên trước rồi, nếu để cho chắc chắn bạn cứ chọn Y để kiểm tra lại xem đã cài đủ chưa, nếu đủ nó sẽ tự bỏ qua ko cài lại nữa.

* DirectAdmin requires certain packages, described here:
* http://help.directadmin.com/item.php?id=354
* Would you like to install these required pre-install packages? (y/n): y

Sau đó bạn điền key đã mua vào, tên miền bạn có thể chọn bất kỳ, gõ Y để  xác nhận các thông tin về IP của bạn rồi tiến hành cài đặt

Please enter your Client ID : 123456
Please enter your License ID : 12345
Please enter your hostname (server.domain.com)
It must be a Fully Qualified Domain Name
Do *not* use a domain you plan on using for the hostname:
eg. don't use domain.com. Use server.domain.com instead.
Do not enter http:// or www
Enter your hostname (FQDN) : DA.conglinh.com
Client ID: 123456
License ID: 12345
Hostname: DA.conglinh.com
Is this correct? (y,n) : y
Is eth0 your network adaptor with the license IP (103.81.84.50)? (y,n) : y
Your external IP: 103.81.84.50
The external IP should typically match your license IP.
Is 103.81.84.50 the IP in your license? (y,n) : y
DirectAdmin will now be installed on: Enterprise 7.4
Is this correct? (must match license) (y,n) : y

Sau đó chọn theo các tùy chọn như sau, ở lựa chọn cuối cùng các bạn đừng bấm Enter vội.

Would you like the default settings of apache 2.4 with mod_ruid2 and php 5.6 cli? (y/n): n
Would you like to backup the current options.conf? (yes/no): no
Please select webserver you would like to use (apache/nginx/nginx_apache/litespeed):nginx_apache
Please select FTP server you would like to use (proftpd/pureftpd/no):pureftpd
Please select default PHP version you would like to use (5.3/5.4/5.5/5.6/7.0/7.1):5.6
Please select default PHP mode you would like to use (php-fpm/fastcgi/suphp/lsphp/mod_php):fastcgi
Would you like to have a second instance of PHP installed? (yes/no): no
Please select if you would like to use ionCube (yes/no):yes
Please select if you would like to use Zend Guard Loader (yes/no):yes
Please select if you would like to use suhosin (yes/no):no
Please select if you would like CustomBuild to manage Exim installation (yes/no):yes
Please select if you would like CustomBuild to manage Dovecot installation (yes/no):yes
Please select if you would like CustomBuild to manage phpMyAdmin installation (yes/no):yes
Please select if you would like CustomBuild to manage SquirrelMail installation (yes/no):no
Please select if you would like CustomBuild to manage RoundCube installation (yes/no):yes
Would you like to search for the fastest download mirror? (y/n):n

Hãy mở 1 cửa sổ SSH khác vào VPS rồi gõ lệnh

vi /usr/local/directadmin/custombuild/options.conf

Tìm tới dòng có chứa đoạn như dưới, bấm chữ “i” rồi thay số 8 bằng số 14, vì 14 là server ở VN nên sẽ tải rất nhanh. Bấm ESC rồi gõ “:wq” rồi enter để lưu lại rồi quay sang cửa sổ đang cài đặt gõ enter để tiến hành cài đăt. Quá trình sẽ mất khoảng 15-30p tùy vào tốc độ VPS và internet.

#CustomBuild Settings
custombuild=2.0
autover=no
bold=yes
clean=yes
cleanapache=yes
clean_old_tarballs=yes
clean_old_webapps=yes
downloadserver=files8.directadmin.com

Danh sách các server cho các bạn tùy chọn.

files1.directadmin.com  -USA          files2.directadmin.com  -USA
files3.directadmin.com  -USA          files6.directadmin.com  -Netherlands
files7.directadmin.com  -Netherlands  files8.directadmin.com  -Israel 
files9.directadmin.com  -USA          files10.directadmin.com -Thailand 
files11.directadmin.com -Italy        files12.directadmin.com -Hong Kong
files13.directadmin.com -Thailand     files14.directadmin.com -Vietnam 
files15.directadmin.com -Italy        files16.directadmin.com -Ukraine 
files17.directadmin.com -Singapore    files18.directadmin.com -Turkey 
files19.directadmin.com -Japan        files20.directadmin.com -Iran 
files22.directadmin.com -Netherlands  files23.directadmin.com -Iran 
files24.directadmin.com -Poland       files25.directadmin.com -Netherlands
files26.directadmin.com -Belgium      files27.directadmin.com -Iran

Sau khi cài đặt xong sẽ hiển thị tài khoản admin cũng như link đăng nhập. Tuy nhiên bạn cần cho cổng 2222 vào tường lửa trc đã vì Direct Admin dùng cổng 2222, sau đó khởi động lại tường lửa.

firewall-cmd --permanent --zone=public --add-port=2222/tcp
service firewalld restart

Tiếp theo ta tiến hành tùy chỉnh và cài đặt một số tiện ích hữu ích cho Direct Admin:

Cho phép upload 5GB qua directadmin File manager:

echo 'maxfilesize=5368709120' >> /usr/local/directadmin/conf/directadmin.conf && echo 'request_timeout=360' >> /usr/local/directadmin/conf/directadmin.conf

Cài đặt cURL:

cd /usr/local/directadmin/custombuild/ && ./build set curl yes && ./build curl

Cài đặt Let’s Encrypt: Cho phép cài đặt SSL miền phí

echo 'letsencrypt=1' >> /usr/local/directadmin/conf/directadmin.conf && echo 'enable_ssl_sni=1' >> 
/usr/local/directadmin/conf/directadmin.conf && echo 'letsencrypt_list=mail:ftp:pop:smtp' >> 
/usr/local/directadmin/conf/directadmin.conf && echo 'letsencrypt_list_selected=' >> 
/usr/local/directadmin/conf/directadmin.conf && service directadmin restart && cd /usr/local/directadmin/custombuild/ 
&& ./build update && ./build rewrite_confs && wget -O /usr/local/directadmin/scripts/letsencrypt.sh 
http://files.directadmin.com/services/all/letsencrypt.sh && ./build letsencrypt

Cài đặt Opcache cho PHP: Giúp tối ưu code PHP

cd /usr/local/directadmin/custombuild/ && ./build set sa_update daily && ./build 
set opcache yes && ./build opcache

Cài đặt Mariadb (Đổi từ Mysql sang Mariadb):MariaDB dùng tối ưu hơn MySQL

cd /usr/local/directadmin/custombuild/ && ./build opcache && ./build set 
mysql_inst mariadb && ./build mariadb

Cho phép download file .tar.gz từ directadmin

echo 'application/x-gzip gz tgz' >> /etc/mime.types && echo 'text/plain xml' >> /etc/mime.types

Mở file không bị lỗi font chữ tiếng Việt trong DirectAdmin File Manager:

echo 'LANG_ENCODING=UTF-8' >> /usr/local/directadmin/data/skins/enhanced/lang/en/lf_standard.html

Sau đó chạy lệnh để khởi động lại Direct Admin.

service directadmin restart

Quá trình đã hoàn tất bạn có thể truy cập vào Direct Admin thông qua trình duyệt với đường link http://IP VPS:2222

Đặng Đình Công

Mình là Đặng Đình Công. Công việc hiện tại của mình là quản trị viên hệ thống mạng máy tính. Hiện tại mình đang học, nghiên cứu và làm việc về mảng hệ thống và bảo mật Microsoft, Cisco, ảo hóa VMware,... Blog được lập ra với phương diện cá nhân nên chắc sẽ không tránh khỏi nhiều sai sót. Mong được sự góp ý của tất cả các bạn.

You may also like...