LAMP+memcache群集
LAMP+memcache群集
一、 安装apache
1、 安装apache
1)
安装apache
[[email protected] ~]# rz
z waiting to receive.B0100000023be50
[[email protected] ~]# tar zxvf /benet/httpd-2.2.17.tar.gz -C /usr/src/
2)
配置apache
[[email protected] ~]# cd /usr/src/httpd-2.2.17/
[[email protected] httpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lits --enable-cgi
3)
编译安装apache
[[email protected] httpd-2.2.17]# make && make install
4)
优化apache
[[email protected] httpd-2.2.17]# ln -s /usr/local/httpd/bin/ /usr/local/bin/
5)
生成apache服务
[[email protected] httpd-2.2.17]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[[email protected] httpd-2.2.17]# chmod +x /etc/init.d/httpd
6)
修改apache服务控制文件
[[email protected] ~]# vim /etc/init.d/httpd
#!/bin/sh
#chkconfig:35 21 80
#Description:Apache Server
7)
添加系统服务设置开机自动启动
[[email protected] ~]# chkconfig --add httpd
[[email protected] ~]# chkconfig --level 35 httpd on
二、安装mysql
1、创建管理mysql账户用户组安装依赖程序
1)
创建管理mysql的用户和组
[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -M -s /sbin/nologin -g mysql mysql
2)
安装依赖程序
[[email protected] ~]# rm -rf /etc/yum.repos.d/CentOS-
[[email protected] ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[[email protected] ~]# yum -y install ncurses-devel cmake
3)
安装mysql
[[email protected] ~]# tar zxvf /benet/mysql-5.5.22.tar.gz -C /usr/src/
2、安装mysql
1)
配置mysql
[[email protected] ~]# cd /usr/src/mysql-5.5.22/
[[email protected] mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
2)
编译安装mysql
[[email protected] mysql-5.5.22]# make && make install
2、 配置mysql配置文件和服务控制文件
1)
生成mysql配置文件
[[email protected] mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
2)
生成服务控制文件
[[email protected] mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql-5.5.22]# chmod +x /etc/init.d/mysqld
3)
添加系统服务设置开机自动启动
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig --level 35 mysqld on
4)
优化程序命令
[[email protected] ~]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
[[email protected] ~]# source /etc/profile
3、 初始化mysql设置管理员密码
1)
初始化mysql
[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2)
修改mysql安装目录的所有者
[[email protected] ~]# chown -R mysql:mysql /usr/local/mysql/
3)
启动服务
[[email protected] ~]# systemctl start mysql
4)
设置管理mysql密码[email protected]
[[email protected] ~]# mysqladmin -uroot password
New password:
Confirm new password:
5)
登陆mysql
[[email protected] ~]# mysql -uroot [email protected]
三、 安装php
1、 配置php依赖软件
1)
安装依赖软件
[[email protected] ~]# yum -y install zlib-devel libxml2-devel
2)
安装libmcrypt
[[email protected] ~]# tar zxvf /benet/libmcrypt-2.5.8.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/libmcrypt-2.5.8/
[[email protected] libmcrypt-2.5.8]# ./configure && make && make install
[[email protected] libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib/
3)
安装mhash
[[email protected] ~]# tar zxvf /benet/mhash-0.9.9.9.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/mhash-0.9.9.9/
[[email protected] mhash-0.9.9.9]# ./configure && make && make install
[[email protected] mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib/
4)
安装mcrypt
[[email protected] ]# tar zxvf /benet/mcrypt-2.6.8.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/mcrypt-2.6.8/
[[email protected] mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib
[[email protected] mcrypt-2.6.8]# ./configure
[[email protected] mcrypt-2.6.8]# make && make install
2、 安装php
1)
安装php
[[email protected] ~]# tar zxvf /benet/php-5.3.28.tar.gz -C /usr/src/
2)
配置php
[[email protected] ~]# cd /usr/src/php-5.3.28/
[[email protected] php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php --enable-mbstring
3)
安装php
[[email protected] php-5.3.28]# make && make install
4)
生成php配置文件
[[email protected] php-5.3.28]# cp php.ini-production /usr/local/php/php.ini
5)
安装zend、加载zend加速访问模块
[[email protected] ~]# tar zxvf /benet/zendguardloader-php-5.3-linux-glibc23-i386.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x
[[email protected] php-5.3.x]# cp ZendGuardLoader.so /usr/local/php/lib/php/
[[email protected] ~]# vim /usr/local/php/php.ini
2 zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so
3 zend_loader.enable=1
228 short_open_tag = on
787 default_charset = “utf-8”
6)
修改apache主配置文件支持php
[[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf
99 ServerName 192.168.100.30:80
168 DirectoryIndex index.html index.php
311 AddType application/x-httpd-php .php
7)
启动apache
[[email protected] ~]# systemctl start httpd
8)
编写php测试页
[[email protected] ~]# vim /usr/local/httpd/htdocs/index.php
9)
客户端访问没有memcache
四、 配置memcache客户端
1、 配置memcache客户端
1)
安装memcache客户端
[[email protected] ~]# rz
z waiting to receive.**B0100000023be50
[[email protected] ~]# tar zxvf memcache-2.2.7.tgz -C /usr/src/
2)
php加载memcache
[[email protected] ~]# cd /usr/src/memcache-2.2.7/
[[email protected] memcache-2.2.7]# /usr/local/php/bin/phpize
3)
配置memcache加载php
[[email protected] memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
[[email protected] memcache-2.2.7]# make && make install
4)
修改php主配置文件加载memcache
[[email protected] ~]# vim /usr/local/php/php.ini
823 extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20090 626/”
824 extension = memcache.so
5)
重新启动apache
[[email protected] ~]# systemctl stop httpd
[[email protected] ~]# systemctl start httpd
6)
客户端访问