Web hosting is vital for many businesses and individuals today. However, without server optimization, performance issues and security vulnerabilities are inevitable. In this article, we will discuss server optimization using cPanel or Plesk on AlmaLinux step by step.
1. Server Updates
First, ensure your server is up to date. Use the following commands to check for updates:
sudo dnf update -y
2. Firewall Settings
Configuring the firewall is crucial for enhancing your server's security. You can use the following commands to allow SSH, HTTP, and HTTPS traffic:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
3. Web Server Optimization
For web server optimization, you should review the Apache or Nginx configurations. If you are using Apache, modify the httpd.conf file as follows:
MaxRequestWorkers 150
KeepAlive On
KeepAliveTimeout 5
For Nginx
If you are using Nginx, configure the nginx.conf file like this:
worker_processes auto;
worker_connections 1024;
4. MySQL Optimization
To enhance database performance, make some changes in the my.cnf file:
[mysqld]
innodb_buffer_pool_size=1G
max_connections=200
5. DDoS Protection
Provides protection against DDoS attacks. You can use a service like Cloudflare to protect your traffic. Additionally, you can install Fail2Ban with the following commands:
sudo dnf install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
6. SSL Certificate Installation
To ensure secure connections, you should install an SSL certificate. To obtain a certificate using Let's Encrypt:
By following the above steps, you can enhance the security and performance of your web hosting server. Always strive to stay updated and take security precautions.