|
本帖最后由 cscs__2002 于 2010-9-21 23:32 编辑
若论坛已有相关内容请删除,谢谢。
基于SUSE LINUX Enterprise Server11.1环境的apache+php+mysql+memcache+eaccelerator+db2安装
PS:最好复制内容保存为文本,格式在网页上看起来很乱
一、所需文件清单
********************************************************************************************
* ID * Name * Version * File * Description *
********************************************************************************************
* 1 * DB2 * 9.7 * db2exc_970_LNX_x86.tar.gz * *
* * * * db2exc_nlpack_970_LNX_x86.tar.gz * *
********************************************************************************************
* 2 * Mysql * 5.1.30 * mysql-5.1.30.tar.gz * *
********************************************************************************************
* 3 * Apache * 2.2.9 * httpd-2.2.9.tar.gz * *
********************************************************************************************
* 4 * PHP * 5.2.13 * php-5.2.13.tar.gz * *
* * * * php-5.2.13-fpm-0.5.14.diff.gz * *
********************************************************************************************
* 5 * other * * eaccelerator-0.9.6.tar.bz2 * *
* * * * freetype-2.3.5.tar.gz * *
* * * * jpegsrc.v6b.tar.gz * *
* * * * libevent-1.2.tar.gz * *
* * * * libpng-1.2.10.tar.bz2 * *
* * * * libxml2-2.6.30.tar.gz * *
* * * * memcache-2.2.5.tgz * *
* * * * memcached-1.4.5.tar.gz * *
* * * * zlib-1.2.3.tar.gz * *
********************************************************************************************
* *
* Copy all files to directory: /usr/local/src *
* *
********************************************************************************************
二、安装DB2
# cd /usr/local/src
# tar xzvf db2exc_970_LNX_x86.tar.gz
# tar xzvf db2exc_nlpack_970_LNX_x86.tar.gz
# cp -r nlpack/* ./expc/
# cd expc
# ./db2setup
图形界面安装,安装完成后执行:
# cd /usr/local/src
# cp -r include/* /home/db2inst1/sqllib/include/
三、安装Mysql
# cd /usr/local/src
# tar xzvf mysql-5.1.30.tar.gz
# cd mysql-5.1.30
# ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Comsenz --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charset=all --with-pthread --enable-static --enable-thread-safe-client --with-lient-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-isam --without-innodb --without-ndb-debug
# make && make install
# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . //注意后面的点
# chown -R mysql /var/lib/mysql
# cp share/mysql/my-huge.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld
# /etc/init.d/mysqld start //启动mysql
# bin/mysqladmin -u root password 123456 //改密码
*如果服务起不动,则注释掉/etc/my.cnf里的skip-federated,即#skip-federated
四、安装Apache
[1]安装zlib
# cd /usr/local/src
# tar zvxf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make && make install
注:SUSE LINUX Enterprise Server11.1安装zlib-1.2.5会造成重启后图形界面无登陆框
[2]安装Apache
# cd /usr/local/src
# tar zvxf httpd-2.2.9.tar.gz
# cd httpd-2.2.9
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-mpm=worker --with-z
# make && make install
# vi /usr/local/apache2/conf/httpd.conf //修改ServerName localhost:80
# /usr/local/apache2/bin/apachectl start
# /usr/local/apache2/bin/apachectl stop
# /usr/local/apache2/bin/apachectl restart
*发生error:httpd: apr_sockaddr_info_get() failed for linux-i5httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
注释掉httpd.conf中的这行#LoadModule unique_id_module libexec/apache22/mod_unique_id.so
五、安装PHP所需要的支持库
[1]安装libxml2
# cd /usr/local/src
# tar xzvf libxml2-2.6.30.tar.gz
# cd libxml2-2.6.30
# ./configure --prefix=/usr/local/libxml2
# make && make install
[2]安装jpeg6
建立目录
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# cd /usr/local/src
# tar vzxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make install
[3]安装freetype
# cd /usr/local/src
# tar zvxf freetype-2.3.5.tar.gz
# cd freetype-2.3.5
# ./configure --prefix=/usr/local/freetype
# make && make install
[4]安装libpng
# cd /usr/local/src
# tar xjvf libpng-1.2.10.tar.bz2
# cd libpng-1.2.10
# ./configure
# make && make install
[5]安装gd
# cd /usr/local/src
# tar xzvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# ./configure --prefix=/usr/local/gd2 --with-png=/usr/local/lib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6 --with-libxml=/usr/local/libxml2 --with-z
# make && make install
六、安装PHP
# cd /usr/local/src
# tar zxvf php-5.2.13.tar.gz
# gzip -cd php-5.2.13-fpm-0.5.14.diff.gz |patch -d php-5.2.13 -p1
# cd php-5.2.13
# source /home/db2inst1/sqllib/db2profile
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-ibm-db2=/home/db2inst1/sqllib --with-libxml-dir=/usr/local/libxml2 --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype --with-zlib-dir --with-png-dir=/usr/local/lib --with-gd=/usr/local/gd2/ --with-config-file-path=/usr/local/php5/etc --enable-xml --enable-debug=yes --enable-sockets --enable-mbstring --enable-force-cgi-redirect
# make && make install
# cp php.ini-recommended /usr/local/php5/etc/php.ini
七、完成安装并测试
[1]配置httpd.conf
# vi /usr/local/apache2/conf/httpd.conf
# /AddType //在vi中查找AddType
在vi中按a进入编辑模式
A:找到AddType application/x-tar .tgz,加一行AddType application/x-httpd-php .php,修改完成后按Esc退出编辑模式
# /DirectoryIndex //在vi中查找DirectoryIndex
在vi中按a进入编辑模式
B:找到DirectoryIndex index.html,修改为DirectoryIndex index.php index.html,修改完成后按Esc退出编辑模式
# :wq //保存退出
[2]重新启动apache
# /usr/local/apache2/bin/apachectl restart
[3]启动DB2
# su db2inst1 //以db2inst1帐号登录
# db2start //启动DB2
# db2sampl //创建 SAMPLE 数据库
# db2 "connect to SAMPLE" //连接到SAMPLE数据库
[4]创建PHP测试页面
# cd /usr/local/apache2/htdoc2
# vi phpinfo.php
输入以下内容:
<?php
phpinfo();
?>
# :wq //保存退出
# vi db2_test.php
输入以下内容:
<?php
$dbname = "SAMPLE";
$username = "db2inst1";
$password = "db2inst1"; //安装DB2时设置的db2inst1账户密码
if($conn = odbc_connect($dbname,$username,$password)) {
echo "Connected\n";
} else {
echo "Failed\n";
}
?>
# :wq //保存退出
[5]打开浏览器访问:http://localhost/phpinfo.php
有如下内容则说明php与db2可以连接。
--------------------------------------------------------------------------
ODBC
--------------------------------------------------------------------------
ODBC Support | enabled
--------------------------------------------------------------------------
Active Persistent Links | 0
--------------------------------------------------------------------------
Active Links | 0
--------------------------------------------------------------------------
ODBC library | ibm-db2
--------------------------------------------------------------------------
ODBC_INCLUDE | -I/home/db2inst1/sqllib/include
--------------------------------------------------------------------------
ODBC_LFLAGS | -L/home/db2inst1/sqllib/lib
--------------------------------------------------------------------------
ODBC_LIBS | -ldb2
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Directive | Local Value | Master Value
--------------------------------------------------------------------------
odbc.allow_persistent | On | On
--------------------------------------------------------------------------
odbc.check_persistent | On | On
--------------------------------------------------------------------------
odbc.default_cursortype | Static cursor | Static cursor
--------------------------------------------------------------------------
odbc.default_db | no value | no value
--------------------------------------------------------------------------
odbc.default_pw | no value | no value
--------------------------------------------------------------------------
odbc.default_user | no value | no value
--------------------------------------------------------------------------
odbc.defaultbinmode | return as is | return as is
--------------------------------------------------------------------------
odbc.defaultlrl | return up to 4096 bytes | return up to 4096 bytes
--------------------------------------------------------------------------
odbc.max_links | Unlimited | Unlimited
--------------------------------------------------------------------------
odbc.max_persistent | Unlimited | Unlimited
--------------------------------------------------------------------------
......
打开浏览器访问:http://localhost/db2_test.php
输出"Connected"说明db2连接成功。
八、安装memcache
[1]安装libevent:
# cd /usr/local/src
# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure --prefix=/usr
# make && make install
[2]测试libevent是否安装成功:
# ls -al /usr/lib | grep libevent
显示信息:
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3
-rw-r–r– 1 root root 454156 11?? 12 17:38 libevent.a
-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3
[3]安装memcached,同时需要安装中指定libevent的安装位置:
# cd /usr/local/src
# tar zxvf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure --with-libevent=/usr
# make && make install
[4]测试是否成功安装memcached:
# ls -al /usr/local/bin/mem*
显示信息:-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached
[5]安装Memcache的PHP扩展
# cd /usr/local/src
# tar vxzf memcache-2.2.5.tgz
# cd memcache-2.2.5
# /usr/local/php5/bin/phpize
# ./configure --enable-memcache --with-php-config=/usr/local/php5/bin/php-config --with-zlib-dir
# make && make install
上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
[6]把/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/目录下的memcache.so,拷贝至/usr/local/php5/ext/
把php.ini中的extension_dir = “./”修改为
extension_dir = "/usr/local/php5/ext/"
添加一行来载入memcache扩展:extension = memcache.so
[7]A:启动Memcache的服务器端:
# /usr/local/bin/memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,我这里指定了服务器的IP地址127.0.0.1,
-p是设置Memcache监听的端口,我这里设置了11211,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
B:如果要结束Memcache进程,执行:
# kill `cat /tmp/memcached.pid`
[8]重启Apache
# /usr/local/apache2/bin/apachectl restart
[9]创建Memcache测试页面
# cd /usr/local/apache2/htdoc2
# vi memcached_test.php
输入以下内容:
<?php
$mem = new Memcache;
$mem->connect("127.0.0.1", 11211) or die ("Could not connect");
$mem->set('key', 'This is a memcached test!', false, 60) or die ("Failed to save data at the server");
$val = $mem->get('key');
echo $val;
?>
# :wq //保存退出
[10]打开浏览器访问:http://localhost/phpinfo.php
有如下内容则说明memcache安装成功
--------------------------------------------------------------------------
memcache
--------------------------------------------------------------------------
memcache support | enabled
--------------------------------------------------------------------------
Active persistent connections | 0
--------------------------------------------------------------------------
Version | 2.2.5
--------------------------------------------------------------------------
Revision | $Revision: 1.111 $
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Directive | Local Value | Master Value
--------------------------------------------------------------------------
memcache.allow_failover | 1 | 1
--------------------------------------------------------------------------
memcache.chunk_size | 8192 | 8192
--------------------------------------------------------------------------
memcache.default_port | 11211 | 11211
--------------------------------------------------------------------------
memcache.default_timeout_ms | 1000 | 1000
--------------------------------------------------------------------------
memcache.hash_function | crc32 | crc32
--------------------------------------------------------------------------
memcache.hash_strategy | standard | standard
--------------------------------------------------------------------------
memcache.max_failover_attempts | 20 | 20
--------------------------------------------------------------------------
......
打开浏览器访问:http://localhost/memcached_test.php
输出"This is a memcached test!"说明memcache连接成功。
九、安装eaccelerator
[1]安装eaccelerator
# cd /usr/local/src
# tar xjvf eaccelerator-0.9.6.tar.bz2
# cd eaccelerator-0.9.6
# /usr/local/php5/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php5/bin/php-config
# make && make install
[2]安装完会在 /usr/local/php/lib/php/extensions/no-debug-non-zts-*/下产生一个eaccelerator.so,将eaccelerator.so拷贝
至/usr/local/php5/ext/
[3]然后到home目录里建立一个eaccelerator文件夹权限设置为777,命令如下
# mkdir /home/eaccelerator
# chmod 777 /home/eaccelerator
[4]修改php.ini
[eAccelerator]
extension = eaccelerator.so
eaccelerator.shm_size=32
eaccelerator.cache_dir=/home/eaccelerator
eaccelerator.enable=1
eaccelerator.optimizer=1
eaccelerator.check_mtime=1
eaccelerator.debug=0
eaccelerator.filter=
eaccelerator.shm_max=0
eaccelerator.shm_ttl=0
eaccelerator.shm_prune_period=0
eaccelerator.shm_only=0
eaccelerator.compress=1
eaccelerator.compress_level=9
[5]重启Apache
# /usr/local/apache2/bin/apachectl restart
[6]打开浏览器访问:http://localhost/phpinfo.php
有如下内容则说明eaccelerator安装成功
--------------------------------------------------------------------------
eAccelerator
--------------------------------------------------------------------------
eAccelerator support | enabled
--------------------------------------------------------------------------
Version | 0.9.6
--------------------------------------------------------------------------
Caching Enabled | true
--------------------------------------------------------------------------
Optimizer Enabled | true
--------------------------------------------------------------------------
Check mtime Enabled | true
--------------------------------------------------------------------------
Memory Size | 33,554,392 Bytes
--------------------------------------------------------------------------
Memory Available | 33,551,792 Bytes
--------------------------------------------------------------------------
Memory Allocated | 2,600 Bytes
--------------------------------------------------------------------------
Cached Scripts | 1
--------------------------------------------------------------------------
Removed Scripts | 0
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Directive | Local Value | Master Value
--------------------------------------------------------------------------
eaccelerator.allowed_admin_path | no value | no value
--------------------------------------------------------------------------
eaccelerator.cache_dir | /home/eaccelerator | /home/eaccelerator
--------------------------------------------------------------------------
eaccelerator.check_mtime | 1 | 1
--------------------------------------------------------------------------
eaccelerator.debug | 0 | 0
--------------------------------------------------------------------------
eaccelerator.enable | 1 | 1
--------------------------------------------------------------------------
eaccelerator.filter | no value | no value
--------------------------------------------------------------------------
eaccelerator.log_file | no value | no value
--------------------------------------------------------------------------
eaccelerator.optimizer | 1 | 1
--------------------------------------------------------------------------
eaccelerator.shm_max | 0 | 0
--------------------------------------------------------------------------
eaccelerator.shm_only | 0 | 0
--------------------------------------------------------------------------
eaccelerator.shm_prune_period | 0 | 0
--------------------------------------------------------------------------
eaccelerator.shm_size | 32 | 32
--------------------------------------------------------------------------
eaccelerator.shm_ttl | 0 | 0
--------------------------------------------------------------------------
...... |
|