Việc build lại apache, php dẫn tới việc truy cập web sẽ bị downtime (tạm ngưng) nên cân nhắc kỹ trước khi thực hiện
1, Nâng cấp version openssl.
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz
tar -xvf openssl-1.1.1l.tar.gz
cd openssl-1.1.1l
./config --prefix=/usr/local/lib_http2 no-ssl2 no-ssl3 zlib-dynamic -fPIC
make depend
make install
2, Cài đặt nghttp2 ( cần thiết để HTTP/2 hoạt động)
cd /usr/local/directadmin/custombuild
./build update
./build nghttp2
3, Cấu hình HTTP/2 in Apache
mkdir -p /usr/local/directadmin/custombuild/custom/ap2 cp -p /usr/local/directadmin/custombuild/configure/ap2/configure.apache /usr/local/directadmin/custombuild/custom/ap2/configure.apache THay đổi lại nội dung của file /usr/local/directadmin/custombuild/custom/ap2/configure.apache tìm dòng
"--with-ssl=/usr" \ và thay bằng
"--enable-http2" \
"--enable-ssl-staticlib-deps" \
"--with-ssl=/usr/local/lib_http2" \
Lưu ý không có khoảng trắng sau dấu \
Sau khi chỉnh sửa và lưu lại , tiến hành build lại apache bằng lệnh
./build apache
4, Cấu hình thêm cho apache
Thêm vào file /etc/httpd/conf/extra/httpd-includes.conf với nội dung
ProtocolsHonorOrder On
Protocols h2 h2c http/1.1
sau đó thực hiện lệnh
cd /usr/local/directadmin/custombuild
./build rewrite_confs
5, Khắc phục lỗi phát sinh
/usr/sbin/httpd: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
Để fix lỗi này cần thực hiên 2 lệnh sau
ln -s /usr/local/lib_http2/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib_http2/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
sau đó restart lại apache
Để kiểm tra http/2 đã hoạt động hay chưa, bạn có thể truy cập web trên chrome + nhấn phím F12 để kiểm tra Protocol
Nếu Protocol hiển thị h2 thì hệ thống đã kích hoạt thành công http/2