LAMP--源码MySQL集群版搭建
环境:RHEL6.1 x86
软件如下:
#ls
- apr-1.4.6.tar.g memcached-1.4.13.tar.gz pcre-7.9.tar.gz
- apr-iconv-1.2.1.tar.gz libevent-2.0.18-stable.tar.gz mysql-cluster-gpl-7.0.5.tar.gz
- apr-util-1.4.1.tar.gz libiconv-1.13.tar.gz httpd-2.2.22.tar.gz
- mysql-cluster-gpl-7.2.5.tar.gz jdk-6u18-ea-bin-b02-linux-i586-09_sep_2009.bin
1.卸载系统自带java
# yum remove java -y
2.安装 java
#./ jdk-6u18-ea-bin-b02-linux-i586-09_sep_2009.bin
#mv jdk1.6.0_18/ /usr/java
# vim /etc/profile
---------------------加入如下内容到/etc/profile中---------------------
JAVA_HOME=/usr/java
CLASS_PATH=/usr/java/jre:/usr/java/lib
PATH=$PATH:/usr/java/bin/
---------------------------------------------------------------------------------
3.环境要生效
# source /etc/profile
4.libevent
libevent-2.0.18-stable.tar.gz --> 解压
#./configure
#make && make install
#echo /usr/local/lib >/etc/ld.so.conf.d/lamp.conf
# ldconfig //执行ldconfig使库生效
5编译 memcached
memcached-1.4.13.tar.gz --> 解压
#./configure --enable-sasl--enable-sasl-pwdb --with-libevent=/usr/local
#make && make install
6.安装 mysql-cluster <保证系统中有mysql用户,uid=27 gid=27 >
mysql-cluster-gpl-7.2.5.tar.gz
如果之前安装过MySQL则执行以下a、b操作:
a. stop mysql 停库
b. rm -rf /usr/local/mysql 删除MySQL安装目录
# cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DMYSQL_DATADIR:PATH=/database -DMEMCACHED_HOME:PATH=/usr/local -DWITH_CLASSPATH:STRING=/usr/java -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON -DWITH_NDBCLUSTER_STORAGE_ENGINE:BOOL=ON -DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON -DWITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON
#make && make install
c.启动脚本
#cp /usr/src/lamp/mysql-cluster-gpl-7.2.5/support-files/mysql.server/etc/rc.d/init.d/mysql5
d.配置文件
- # mkdir /usr/local/mysql/etc
- #vim /usr/local/mysql/etc/my.cnf
- # cat /usr/local/mysql/etc
- [mysqld]
- user=mysql
- basedir=/usr/local/mysql
- datadir=/database
- socket=/var/run/mysqld/mysql5.socket
- pid-file=/var/run/mysqld/mysql5.pid
- general-log
- general-log-file=/var/log/mysqld/mysql5-access.log
- log-error=/var/log/mysqld/mysql5-error.log
- port=3306
- e.startup
Apache及其相关软件安装
//删除之前安装的Apache目录
# rm -rf /usr/local/apache2
# yum install -y openssl* nss-develbzip2-devel libzip-* net-snmp-*
//yum安装之后所需要的一些软件
apr-1.4.6.tar.gz --> 解压
#./configure --disable-ipv6--enable-threads
#make && make install
……
Libraries have been installed in:
/usr/local/apr/lib
……
#echo /usr/local/apr/lib >>/etc/ld.so.conf.d/lamp.conf
//把/usr/local/apr/lib加入库共享库目录中,执行ldconfig命令生效
libiconv-1.13.tar.gz --> 解压
#./configure --enable-static
#make && make install
apr-iconv-1.2.1.tar.gz --> 解压
# ./configure--with-apr=/usr/local/apr/bin/apr-1-config
#make && make install
apr-util-1.4.1.tar.gz --> 解压
#ln -s /usr/src/lamp/apr-iconv-1.2.1/usr/src/lamp/apr-util-1.4.1/apr-iconv
#./configure--with-apr=/usr/local/apr/bin/apr-1-config --with-apr-iconv=./arp-iconv--with-openssl=/usr --with-nss=/usr --with-mysql=/usr/local/mysql--with-iconv=/usr/local
#make && make install
pcre-7.9.tar.gz --> 解压
#./configure --enable-rebuild-chartables--enable-utf8 --enable-newline-is-any --enable-pcregrep-libz --enable-pcregrep-libbz2
# make && make install
httpd-2.2.22.tar.gz --> 解压
# ./configure--enable-modules=all --enable-mods-shared=all --enable-file-cache--enable-cache --enable-disk-cache --enable-mem-cache --enable-dumpio--enable-echo --enable-example --enable-logio --enable-mime-magic--enable-expires --enable-headers --enable-unique-id --enable-proxy--enable-proxy-balancer --enable-proxy-http --enable-proxy-ajp --enable-proxy-connect --enable-ssl --enable-static-ab --enable-http--enable-info --enable-cgi --enable-vhost-alias --enable-so --enable-rewrite--with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local --with-ssl=/usr --with-mpm=prefork
#make && make install
相关配置:
#########################################################################################
1.中文
/usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/extra/httpd-languages.conf
httpd-languages.conf
DefaultLanguage zh-CN
LanguagePriority zh-CN ...... #修改中文优先级
2.虚拟主机
/usr/local//apache2/conf//httpd.conf
Includeconf/extra/httpd-vhosts.conf
NameVirtualHost*:80
<virtualhost *:80>
docuementroot /www
servername teacher.cluster.com
customlog /var/log/httpd/teacher-access.log combined
errorlog /var/log/httpd/teacher-error.log
</virtualhost>
3.404
/usr/local//apache2/conf//httpd.conf
ErrorDocument404 /404.html
4.允许访问
Order deny,allow
Deny from all
5.索引
DirectoryIndex index.htmlindex.php
6.监控
/usr/local//apache2/conf//httpd.conf
Includeconf/extra/httpd-info.conf
<Location /server-status>
SetHandlerserver-status
Order deny,allow
Deny from all
Allow from10.1.1.0/255.255.255.0
</Location>
ExtendedStatus On
###############################################################################################################
freetype-2.4.9.tar.gz --> 解压
#./configure
#make && make install
libpng-1.5.9.tar.gz --> 解压
# ./configure --with-zlib-prefix=/usr--with-pkgconfigdir=/usr/lib/pkgconfig/
#make && make install
jpegsrc.v8.tar.gz --> 解压
#./configure && make &&make install
# yum install -y imake
xpm-3.4k.tar.gz --> 解压
#xmkmf -a
#make
# make install.man
gd-2.0.36RC1.tar.gz --> 解压
#./configure--with-libiconv-prefix=/usr/local --with-png=/usr/local--with-freetype=/usr/local --with-fontconfig=/usr --with-jpeg=/usr/local--with-xpm=/usr/local
#make && make install
libmcrypt-2.5.8.tar.bz2 --> 解压
# ./configure--enable-static
# make && make install
mhash-0.9.9.9.tar.bz2 --> 解压
# ./configure
#make && make install
mcrypt-2.6.6.tar.gz --> 解压
# ./configure--with-libiconv-prefix=/usr/local --with-libmcrypt-prefix=/usr/local
# make && make install
# yum install -y libxml2 libcurl-devel
php-5.3.10.tar.gz --> 解压
#./configure--with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --with-libxml-dir=/usr--with-openssl=/usr --with-pcre-regex=/usr/local --with-zlib=/usr--with-bz2=/usr --enable-calendar --with-curl=/usr --with-pcre-dir=/usr/local --enable-ftp--with-openssl-dir=/usr --with-gd=/usr/local --with-jpeg-dir=/usr/local--with-png-dir=/usr/local --with-zlib-dir=/usr/local --with-xpm-dir=/usr--with-freetype-dir=/usr/local --enable-gd-native-ttf --enable-gd-jis-conv--with-mhash=/usr/local --enable-mbstring --with-mcrypt=/usr/local--with-mysql=/usr/local/mysql --with-mysql-sock=/var/run/myqld/mysql5.socket--with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp=/usr--enable-sockets --enable-zip
# make && make install
注意:php一旦编译失败,删除源码,重新编译!!!
php相关配置
#########################################################################################
a. cp/usr/src/lamp/php-5.3.10/php.ini-production /usr/local/lib/php.ini
php.ini
1.session
session.save_path = "/tmp/session" <- session目录需要建立, 属性(改成Apache属主即可)
2. support mysql
mysql.default_socket = /var/run/mysqld/mysql5.socket
mysqli.default_socket = /var/run/mysqld/mysql5.socket
3.upload file limit
upload_max_filesize = 2M #网页上传限制
b. /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
#确认,无需再次加入,安装之后自动加入到Apache配置文件中
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
#以上两行需要手动加入
c.restart apache(重启Apache生效)
d.add php patch <php编译完成之后加入扩展>
如加入: bcmath扩展模块
cd到bcmath的目录下(php自带的扩展在源码目录的ext目录下),执行如下操作即可
# phpize //生成编译环境和configure文件
# ./configure
# make install
# vi /usr/local/lib/php.ini //手动加入如下内容到php.ini配置文件即可
extension_dir ="/usr/local/lib/php/extensions/no-debug-non-zts-20090626/"
extension="bcmath.so"