Отказоустойчивый сервер для хостинга сайтов
Инсталляция Apache
[root@server1 ~]# yum install -y httpd && ssh server2 yum install -y httpd
[root@server1 ~]# chkconfig --level 345 httpd on && ssh server2 chkconfig --level 345 httpd on
[root@server1 ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig && ssh server2 cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig
[root@server1 ~]# vi /etc/httpd/conf/httpd.conf
Добавляю в блок userdir:
UserDir disabled
UserDir enabled hoster
UserDir public_html
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
Order deny,allow
Deny from all
Разрешено использовать userdir только для пользователя hoster
[root@server1 ~]# scp /etc/httpd/conf/httpd.conf server2:/etc/httpd/conf/httpd.conf
[root@server1 ~]# service httpd restart && ssh server2 service httpd restart
Создание пользователя hoster на обоих узлах с uid 10001
[root@server1 ~]# useradd \
-d /home/hoster \
-m hoster \
-u 10001
[root@server1 ~]# passwd hoster
[root@server1 ~]# su - hoster
[hoster@server1 ~]$ mkdir public_html
[hoster@server1 ~]$ cd public_html/
[hoster@server1 ~]$ vi index.html
OK
http://192.168.1.21/~hoster/
ok
[root@server1 ~]# ssh server2
# useradd \
-d /home/hoster \
-m hoster \
-u 10001
Инсталляция ftp сервера
[root@server1 ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@server1 ~]# ssh server2 rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@server1 ~]# yum install -y proftpd && ssh server2 yum install -y proftpd
[root@server1 ~]# chkconfig --level 345 proftpd on && ssh server2 chkconfig --level 345 proftpd on
[root@server1 ~]# service proftpd restart && ssh server2 service proftpd restart
Инсталляция xinetd и rsync
[root@server1 ~]# yum install -y xinetd && ssh server2 yum install -y xinetd
[root@server1 ~]# chkconfig --level 345 xinetd on && ssh server2 chkconfig --level 345 xinetd on
[root@server1 ~]# yum install -y rsync && ssh server2 yum install -y rsync
[root@server1 ~]# vi /etc/xinetd.d/rsync
меняем
disable = yes
на
disable = no
[root@server1 ~]# scp /etc/xinetd.d/rsync server2:/etc/xinetd.d/rsync
[root@server1 ~]# service xinetd restart && ssh server2 service xinetd restart
Убеждаемся, что xinetd слушает rsync
[root@server1 ~]# netstat -lnpt | grep 873
[root@server1 ~]# ssh server2
[root@server2 ~]# vi /etc/rsyncd.conf
pid file = /var/run/rsyncd.pid
[home]
uid = root
use chroot = yes
path = /home
read only = no
hosts allow = server1.localdomain
CTRL + D
[root@server1 ~]# rsync server2::
home
[root@server1 ~]# rsync server2::home
drwxr-xr-x 4096 2014/01/31 23:40:39 .
drwx------ 4096 2014/01/31 23:42:19 hoster
drwxr-xr-x 4096 2013/03/10 05:11:09 projects
[root@server1 ~]# rsync -av --delete /home/ server2::home
http://192.168.1.22/~hoster/
OK