1. 官方推荐最简方式安装Varnish
1 |
<pre class="wrap:true lang:default decode:true "> |
rpm –nosignature -i http://repo.varnish-cache.org/redhat/el5/noarch/varnish-release-2.1-2.noarch.rpm
1 |
<pre class="wrap:true lang:default decode:true "> |
yum install varnish
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
启动varnish
1 |
<pre class="wrap:true lang:default decode:true "> |
service varnish restart
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
配置文件路径
1 |
<pre class="wrap:true lang:default decode:true "> |
配置1:/etc/varnish/default.vcl
1 |
<pre class="wrap:true lang:default decode:true "> |
配置2:/etc/sysconfig/varnish
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
2. 编译安装lighttpd
1 |
<pre class="wrap:true lang:default decode:true "> |
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.28.tar.gz
1 |
<pre class="wrap:true lang:default decode:true "> |
tar xvzf lighttpd-1.4.28.tar.gz
1 |
<pre class="wrap:true lang:default decode:true "> |
cd lighttpd-1.4.28
1 |
<pre class="wrap:true lang:default decode:true "> |
./configure -prefix=/usr/local/lighttpd
1 |
<pre class="wrap:true lang:default decode:true "> |
make && make install
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
把lighttpd-1.4.28/doc/config拷贝到/usr/local/lighttpd/config
把lighttpd-1.4.28/doc/initscripts/rc.lighttpd.redhat 拷贝到/etc/init.d/lighttpd
nano lighttpd 把对应的lighttpd目录和配置文件目录修改成对应的目录
chkconfig lighttpd on
service lighttpd restart
3. 安装php
添加yum repo php5.2.x
vi /etc/yum.repos.d/CentOS-Testing.repo
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
priority=1
注:这个是centos官方的test源,里面有php5.2.10
yum install php
4. lighttpd fastcgi方式整合php
1 |
<pre class="wrap:true lang:default decode:true "> |
wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
1 |
<pre class="wrap:true lang:default decode:true "> |
tar xvzf spawn-fcgi-1.6.3.tar.gz
1 |
<pre class="wrap:true lang:default decode:true "> |
cd spawn-fcgi-1.6.3
1 |
<pre class="wrap:true lang:default decode:true "> |
./configure –prefix=/usr/local/spawn-fcgi
1 |
<pre class="wrap:true lang:default decode:true "> |
make && make install
1 |
<pre class="wrap:true lang:default decode:true "> |
/usr/local/spawn-fcgi/bin/spawn-fcgi -f /usr/bin/php-cgi -p 2000 -a 127.0.0.1 -C 8
1 |
<pre class="wrap:true lang:default decode:true "> |
nano /usr/local/lighttpd/config/modules.conf 去掉include “conf.d/fastcgi.conf”前面的#号
1 |
<pre class="wrap:true lang:default decode:true "> |
nano /usr/local/lighttpd/config/conf.d/fastcgi.conf
1 |
<pre class="wrap:true lang:default decode:true "> |
追加如下配置内容
1 |
<pre class="wrap:true lang:default decode:true "> |
fastcgi.server = (
1 |
<pre class="wrap:true lang:default decode:true "> |
“.php” => ((
1 |
<pre class="wrap:true lang:default decode:true "> |
“host” => “127.0.0.1″,
1 |
<pre class="wrap:true lang:default decode:true "> |
“port” => “2000″,
1 |
<pre class="wrap:true lang:default decode:true "> |
“docroot” => “/home/www/”
1 |
<pre class="wrap:true lang:default decode:true "> |
)))
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
service lighttpd restart
5. RPM方式安装mysql
1 |
<pre class="wrap:true lang:default decode:true "> |
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.9-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/
1 |
<pre class="wrap:true lang:default decode:true "> |
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.9-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/
1 |
<pre class="wrap:true lang:default decode:true "> |
rpm -ivh MySQL-client-5.5.9-1.rhel4.i386.rpm
1 |
<pre class="wrap:true lang:default decode:true "> |
rpm -ivh MySQL-server-5.5.9-1.rhel4.i386.rpm
1 |
<pre class="wrap:true lang:default decode:true "> |
service mysql start
1 |
<pre class="wrap:true lang:default decode:true "> |
mysqladmin -u root password ’123456′
1 |
<pre class="wrap:true lang:default decode:true "> |
mysql -u root -p 输入密码登录
1 |
<pre class="wrap:true lang:default decode:true "> |
mysql>use mysql;
1 |
<pre class="wrap:true lang:default decode:true "> |
mysql>update user set host = ‘%’ where user = ‘root’;
1 |
<pre class="wrap:true lang:default decode:true "> |
mysql>UPDATE user SET Password=PASSWORD(’123456′) where USER=’root’;
1 |
<pre class="wrap:true lang:default decode:true "> |
mysql>FLUSH PRIVILEGES;
1 |
<pre class="wrap:true lang:default decode:true "> |
mysq>exit;
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
这样就开启了远程管理权限,可以用客户端GUI工具进行远程管理。
最后不要忘记挑选一个配置文件拷贝到/etc/my.cnf
1 |
<pre class="wrap:true lang:default decode:true "> |
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
6. MySQL主从配置
注意:关闭防火墙 service iptables stop .默认centos5.5开启iptables。否则不能访问80端口
修改Master所在服务器的my.cnf文件里[mysqld]配置项追加配置如下
1 |
<pre class="wrap:true lang:default decode:true "> |
#不同步的数据库
1 |
<pre class="wrap:true lang:default decode:true "> |
#binlog_ignore_db = mysql
1 |
<pre class="wrap:true lang:default decode:true "> |
#需要同步的数据库
1 |
<pre class="wrap:true lang:default decode:true "> |
binlog_do_db = ad
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
继续修改slave所在服务器的my.cnf文件中[mysqld]配置项追加如下配置:
1 |
<pre class="wrap:true lang:default decode:true "> |
server-id = 2
1 |
<pre class="wrap:true lang:default decode:true "> |
#需要同步的数据库
1 |
<pre class="wrap:true lang:default decode:true "> |
replicate-do-db = ad
1 |
<pre class="wrap:true lang:default decode:true "> |
# The replication master for this slave – required
1 |
<pre class="wrap:true lang:default decode:true "> |
master-host = 192.168.1.2
1 |
<pre class="wrap:true lang:default decode:true "> |
# The username the slave will use for authentication when connecting
1 |
<pre class="wrap:true lang:default decode:true "> |
# to the master – required
1 |
<pre class="wrap:true lang:default decode:true "> |
master-user = master_user
1 |
<pre class="wrap:true lang:default decode:true "> |
# The password the slave will authenticate with when connecting to
1 |
<pre class="wrap:true lang:default decode:true "> |
# the master – required
1 |
<pre class="wrap:true lang:default decode:true "> |
master-password = master_user_password
1 |
<pre class="wrap:true lang:default decode:true "> |
# The port the master is listening on.
1 |
<pre class="wrap:true lang:default decode:true "> |
# optional – defaults to 3306
1 |
<pre class="wrap:true lang:default decode:true "> |
master-port = 3306
1 |
<pre class="wrap:true lang:default decode:true "> |
# binary logging – not required for slaves, but recommended
1 |
<pre class="wrap:true lang:default decode:true "> |
log-bin=mysql-bin
1 |
<pre class="wrap:true lang:default decode:true "> |
# binary logging format – mixed recommended
1 |
<pre class="wrap:true lang:default decode:true "> |
binlog_format=mixed
1 |
<pre class="wrap:true lang:default decode:true "> |
1 |
<pre class="wrap:true lang:default decode:true "> |
接着分别检查master和slave服务器状态,在mysql命令行下敲入如下命令
show master status \G