基于IP地址的虚拟主机配置
Listen 80
DocumentRoot /www/jb51
ServerName www.
DocumentRoot /www/jb512
ServerName www.jb512.org
基于IP和多端口的虚拟主机配置
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
DocumentRoot /www/jb51-80
ServerName www.
DocumentRoot /www/jb51-8080
ServerName www.
DocumentRoot /www/example2-80
ServerName www.jb51.org
DocumentRoot /www/example2-8080
ServerName www.example2.org
单个IP地址的服务器上基于域名的虚拟主机配置:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
DocumentRoot /www/jb51
ServerName www.
ServerAlias . *.
# Other directives here
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
在多个IP地址的服务器上配置基于域名的虚拟主机:
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
DocumentRoot /www/jb51
ServerName www.
# Other directives here …
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here …
在不同的端口上运行不同的站点:
基于多端口的服务器上配置基于域名的虚拟主机。
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
ServerName www.
DocumentRoot /www/domain-80
ServerName www.
DocumentRoot /www/domain-8080
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
基于域名和基于IP的混合虚拟主机的配置:
Listen 80
NameVirtualHost 172.20.30.40
DocumentRoot /www/jb51
ServerName www.
DocumentRoot /www/example2
ServerName www.example2.org
DocumentRoot /www/example3
ServerName www.example3.net
网站泛域名解析
添加一个虚拟主机配置(如下):
DocumentRoot d:/web/jb51 # 网站根目录的绝对路径
ServerName www. # 网站域名
ServerAlias *. # 网站泛域名
APACHE泛域名配置参考
NameVirtualHost 192.168.0.110
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/workplace/"
ServerName www.workplace.com
<Directory "E:/InterRoot/workplace/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/busymouse_test/"
ServerName www.test.com
<Directory "E:/InterRoot/busymouse_test/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/auth"
ServerName auth.billing.com
ServerAlias auth.billing.com *.auth.billing.com
#泛域名解析
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/auth">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/api"
ServerName voiz.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/api">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/user"
ServerName user.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/user">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/center"
ServerName center.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/center">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/img"
ServerName img.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/img">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/log"
ServerName log.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/log">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.0.110:80>
DocumentRoot "E:\InterRoot\billing_new\front"
ServerName admin.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:\InterRoot\billing_new\front">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
废话少说,步入整体。
流程笔记:
1.打开终端,输入“sudo apt-get install apache2”,回车;(安装apache2.0)
2.如有密码请再输入管理员密码,回车
3.输入“Y”,回车
4.apache2.0安装完成
5.验证apache2.0安装是否完成,在浏览器中打开http://localhost/或者http://127.0.0.1。如果出现It works!那证明成功;
6.打开终端,输入“sudo apt-get install php5”,回车;(此为安装PHP)
7.输入“Y”,回车;
8.下图为安装过程,需要一定等待时间
9.输入“sudo apt-get install libapache2-mod-php5”,回车;(此为配置APACHE+PHP)
10.输入“sudo /etc/init.d/apache2 restart”,回车;(此为重启APACHE)
11.看到如下图的界面后说明PHP已经安装完成;
12.输入“gksudo gedit /var/www/testphp.php”,回车;(此为测试PHP的安装结果)
13.然后随意输入点东西(我输入的是http://www./)再保存。
14.在浏览器中输入http://127.0.0.1/testphp.php或者http://localhost/testphp.php,如果显示出你输入的东西即为成功;
15.在终端输入“sudo apt-get install mysql-server”,回车;(此为安装MYSQL)
16.输入“Y”,回车;
17.设置root密码;
18.在终端中输入“sudo apt-get install libapache2-mod-auth-mysql”,回车;(此为让apache、php支持 mysql)
19.在终端输入“sudo apt-get install php5-mysql”,回车;
20.在终端输入“sudo /etc/init.d/apache2 restart”,回车;
至此apache2+php 5+mysql5的环境就配置成功了。
作者:pwxtom
本文地址:http://www.cnblogs.com/LiteraturePan/archive/2012/03/02/2377097.html
repcached是日本人开发的实现memcached复制功能,它是一个单 master单 slave的方案,但它的 master/slave都是可读写的,而且可以相互同步,如果 master坏掉, slave侦测到连接断了,它会自动 listen而成为 master;而如果 slave坏掉, master也会侦测到连接断,它就会重新 listen等待新的 slave加入
2、安装
在两台服务器上分别安装memcached服务,另注本文libevent的版本为:libevent-1.4.13,下载地址: http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
repcached有两种方式:
方式一、下载对应的repcached版本
#wget http://downloads.sourceforge.net/repcached/memcached-1.2.8-repcached-2.2.tar.gz
#tar zxf memcached-1.2.8-repcached-2.2.tar.gz
#cd memcached-1.2.8-repcached-2.2
【方式二、下载对应patch版本
#wget http://downloads.sourceforge.net/repcached/repcached-2.2-1.2.8.patch.gz
#gzip -cd ../repcached-2.2-1.2.8.patch.gz | patch -p1】
#./configure –enable-replication
# make
# make install
3、启动:
启动master
#/usr/local/bin/memcached -v -l 192.168.0.160 -p 11211 -uroot
replication: listen (master监听)
启动salve
#/usr/local/bin/memcached -v -l 192.168.0.163 -p 11213 -uroot -x 192.168.0.160 -X 11212
replication: connect (peer=192.168.0.160:11212)
replication: marugoto copying
replication: start
启动正常后,master将accept。
4、测试:
操作master
#telnet 192.168.0.160 11211
#set key1 0 0 3
blog.5sail.com
查看slave
#telnet 192.168.0.163 11213
#get key1
如果正常显示blog.5sail.com,则表示repcached配置成功
5、应用:
可以实现cache冗余,避免因cache服务器down掉而导致数据丢失。
注意:如果master down机,slave接管并成为master,这时down机的master只能启用slave,他们之间互换角色,才能保持复制功能。换句话说,master没有抢占功能。