Sunday , 2 April 2023
Home » Thủ thuật » Tối ưu LEMP server trên CentOS

Tối ưu LEMP server trên CentOS

vps-thu thuat

Sau khi cài đặt xong LEMP trên CentOS, bạn sẽ cần thực hiện một số tùy chỉnh để đảm bảo hệ thống hoạt động nhanh hơn, tăng tốc website. Bên dưới là một số thao tác mình thực hiện mỗi khi cài đặt server.

1. Kích hoạt Gzip Compression

Mở file cài đặt nginx

sudo nano /etc/nginx/nginx.conf

Chỉnh phần cài đặt gzip

...
http {
...

# enable gzip compression
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# end gzip configuration
}
...

Reload nginx

sudo /etc/init.d/nginx reload

2. Make Browsers Cache Static Files On nginx

Mở file virtual host mặc định hoặc file custom của bạn

sudo nano /etc/nginx/conf.d/default.conf

Thay đổi cài đặt như bên dưới.

[...]
server {
        [...]
        location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$  {
              expires 365d;
        }
        [...]
}
[...]

Reload nginx

sudo /etc/init.d/nginx reload

Lượt xem (652)

About Uzumaki Naruto

Uzumaki Naruto
Sống để nuôi hy vọng . . .

Xem thêm

Cách update firmware mới nhất cho MiBand

Sau một thời gian dùng Mi Band sẽ có nhiều bạn thấy chán, nhưng Xiaomi …

Để lại bình luận:

Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *