阅读量:267
1. 规划2. 安装和配置服务器软件3. 配置Web服务器
:80 >
ServerName mycluster.example.com
DocumentRoot /var/www/html
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
sudo a2ensite mycluster.conf
sudo systemctl reload apache2
配置Nginx:
server {
listen 80;
server_name mycluster.example.com;
location / {
root /var/www/html;
index index.html index.htm;
}
}
sudo ln -s /etc/nginx/sites-available/mycluster /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
4. 配置负载均衡器
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http_front
bind *:80
default_backend http_back
backend http_back
balance roundrobin
server web1 192.168.1.1:80 check
server web2 192.168.1.2:80 check
sudo systemctl start haproxy
sudo systemctl enable haproxy
5. 测试和监控6. 优化和扩展
通过以上步骤,你可以搭建一个基本的Linux HTTP服务器集群。根据具体需求,你可能还需要进行更多的配置和优化。