#mysql完整配置
#groupadd mysql
#useradd -g mysql -s /sbin/nologin -M mysql
#tar -zxvf mysql-5.0.33.tar.gz
#./configure --prefix=/opt/app/mysql5 --without-debug --without-bench --with-charset=utf8 --with-extra-charsets=all --with-plugins=fthightman --enable-thread-safe-client
#make
#make install
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#cd /opt/app/mysql5
#bin/mysql_install_db --user=mysql
#chown -R root  .
#chown -R mysql var
#chgrp -R mysql .
#chkconfig --add mysqld
#bin/mysqld_safe --user=mysql & 或者 /etc/rc.d/init.d/mysqld start 启动数据库
#/etc/rc.d/init.d/mysqld stop|start 停止数据库|启动数据库


#安装GD库
1.安装  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 -zxvf jpegsrc.v6b.tar.gz
# cd jpegsrc.v6b
#./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install

2.安装 libpng
# cd /usr/local/src
# tar -jxvf libpng-1.2.8.tar.bz2
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make
# make install

3.安装 freetype
# cd /usr/local/src
# tar -zxvf freetype-2.3.2.tar.gz
# cd freetype-2.3.2
# ./configure --prefix=/usr/local/freetype
# make
# make install

4.安装libXML2
# cd /usr/local/src
# tar xjvf libxml2-2.6.24.tar.bz2
# cd libxml2-2.6.24
# ./configure --prefix=/usr/local/libxml
# make
# make install

5.安装zlib
安装 zlib
# cd /usr/local/src
# tar zxvf zlib-1.2.2.tar.gz
# cd zlib-1.2.2
# ./configure --prefix=/usr/local/zlib
# make
# make install

6.安装 GD2
# cd /usr/local/src
# tar xzvf gd-2.0.34.tar.gz
# cd gd-2.0.34
#./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype
# make  //第一次编译报错。需要编译二次。
# make install


#.安装mcrypt
1.安装libiconv
#tar -zxvf libiconv-1.12.tar.gz
#./configure --prefix=/usr/local/libionv
#make
#make install

2.安装mhash
# tar -zxvf mhash-0.9.9.tar.gz
# ./configure
# make
# make install
# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2


3.安装libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#./configure
# make
# make install
# /sbin/ldconfig
# cd libltdl/
# ./configure --enable-ltdl-install
# make
# make install
# cp /usr/local/lib/libmcrypt.* /usr/lib

4.安装mcrypt
# tar -zxvf mcrypt-2.6.7.tar.gz
# ./configure
# make
# make install


#安装PHP完整配置
#tar -zxvf php-5.2.6.tar.gz
#gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1
#cd php-5.2.6
#./configure --prefix=/opt/app/php5 --with-libxml-dir=/usr/local/libxml --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6 --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-iconv-dir=/usr/local/libiconv --with-mcrypt --enable-mbstring --enable-zend-multibyte --enable-soap --with-mysql=/opt/app/mysql5 --with-config-file-path=/opt/app/php5/etc --enable-force-cgi-redirect --enable-fastcgi --enable-fpm --disable-debug
# make
# make install
# cp php.ini-dist /opt/app/php5/etc/php.ini

#启动php-fpm
#/opt/app/php5/sbin/php-fpm start


#优化安装memcache
#tar -zxvf libevent-1.4.9-stable.tar.gz
#./configure --prefix=/usr/
#make
#make install
#ls -al /usr/lib | grep libevent

#tar -zxvf memcached-1.2.6.tar.gz
#./configure --prefix=/opt/app/memcached --with-libevent=/usr
#make
#make install
#启动memcached
#/opt/app/memcached/bin/memcached -d -m 250 -u root -l 192.168.1254 -p 12000 -c 256 -P /var/run/memcached.pid
#关闭memcached
#kill `cat /var/run/memcached.pid`

#tar -zxvf memcache-3.0.2.tgz
#export PHP_PREFIX="/opt/app/php5"
#$PHP_PREFIX/bin/phpize
#./configure --with-php-config=$PHP_PREFIX/bin/php-config
#make
#make install
Installing shared extensions:     /opt/app/php5/lib/php/extensions/no-debug-non-zts-20060613/

#vim /opt/app/php5/etc/php.ini
修改:extension_dir = "/opt/app/php5/lib/php/extensions/no-debug-non-zts-20060613/"
添加:extension = "memcache.so"
修改:output_buffering = On
修改:expose_php = Off


#加速PHP运行程序eaccelerator
#tar -jxvf eaccelerator-0.9.5.2.tar.bz2
#export PHP_PREFIX="/opt/app/php5"
#$PHP_PREFIX/bin/phpize
#./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
#make
#make install
//这时会将eaccelerator安装到php目录中,屏幕会显示eaccelerator.so所在路径                *记住该路径。。。
#vim /opt/app/php/etc/php.ini
   [eaccelerator]
   zend_extension="/opt/app/php5/lib/php/extensions/no-debug-non-zts-20080424/eaccelerator.so"
   eaccelerator.shm_size="16"  //eaccelerator可使用的共享内存大小(单位为MB)。
   eaccelerator.cache_dir="/tmp/cache/eaccelerator"    //缓存路径.
   eaccelerator.enable="1"      //打开或者关闭eaccelerator。"1"指打开,"0"指关闭。默认值为"1"。
   eaccelerator.optimizer="1"   //打开或者关闭代码优化,开启可以加快代码的执行速度。"1"指打开,"0"指关闭。默认值为"1"。
   eaccelerator.check_mtime="1"     //当打开此项时,eaccelerator会在每次请求时检查php文件的修改时间,看其是否被修改过,这会耗费一点时间,如果php文件被修改过, eaccelerator会重新编译缓存该php文件。当关闭此项时,如果php文件被修改,则需要手工删除eaccelerator缓存,才能显示被修改的php文件。"1"指打开,"0"指关闭。默认值为"1"。
   eaccelerator.debug="0"           //打开或者关闭调试记录。当打开时,eaccelerator会将对一个缓存文件的每次请求都写进log。打开此项只对调试eaccelerator是否有BUG时有益处。"1"指打开,"0"指关闭。默认值为"0"。
   eaccelerator.log_file = "/var/log/eaccelerator_log"   //调试记录日志。
   eaccelerator.filter=""     //决定哪些PHP文件应该被缓存。可以指定一个范围(比如"*.php *.phtml"),这样被指定的文件就会被缓存。如果该范围以!开头,被指定的文件就不会被缓存。默认值为"",表示缓存所有的PHP文件。
   eaccelerator.shm_max="0"     //一个用户使用例如eaccelerator_put之类的函数能够往共享内存中加载的最大数据。默认值为"0",表示不限制。(单位为字节)
   eaccelerator.shm_ttl="0"     //当没有足够的空闲共享内存去尝试缓冲一个新脚本时,将删除至少在shm_ttl秒之前没有被访问过的文件。默认值为"0",表示不尝试从共享内存中删除任何旧的脚本。(单位为秒)
   eaccelerator.shm_prune_period="0"   //当没有足够的空闲共享内存去尝试缓冲一个新脚本时,将删所有旧脚本,前提是这个尝试在超过shm_prune_period秒之前被执行过。默认值为"0",表示不尝试从共享内存中删除任何旧的脚本。(单位为秒)
   eaccelerator.shm_only="0"    //打开或者关闭在磁盘上缓存编译过的脚本。这个参数对会话数据和内容缓存没有效果。默认值为"0",表示使用磁盘和共享内存来缓存。
   eaccelerator.compress="1"    //打开或者关闭缓存内容压缩。"1"指打开,"0"指关闭。默认值为"1"。
   eaccelerator.compress_level="9"    //内存压缩的级别。默认值为"9",表示最大压缩。

建立缓存目录:
#mkdir -p /tmp/cache/eaccelerator
#chmod 0777 /tmp/cache/eaccelerator

eaccelerator配置完毕重新启动httpd
#/opt/app/apache2/bin/apachectl restart


#优化php完整配置Zend Optimizer
#tar xzvf ZendOptimizer-3.2.0-linux-glibc21-i386.tar.gz
#./install

以此往下运行填写php.ini位置,注意会让你选择是否有apache,你选择no即可。

#安装ngnix
(1)安装pcre
#tar -zxvf pcre-7.8.tar.gz
#./configure
#make
#make install
(2)安装ngnix
#groupadd www -g 80
#useradd -u 80 -g www -s /sbin/nologin -M www
#tar -zxvf nginx-0.6.32.tar.gz
#vim nginx-0.6.32/src/core/nginx.h

#define NGINX_VERSION      "0.1"
#define NGINX_VER          "nginx/" NGINX_VERSION
修改:
#define NGINX_VERSION      "1.0"
#define NGINX_VER          "IBM_HTTP_SERVER/" NGINX_VERSION

#./configure --user=www --group=www --prefix=/opt/app/nginx0.6 --with-http_ssl_module
#make
#make install

#日志分析
#cat cornlog.sh
#!/bin/bash
log_dir="/opt/app/nginx0.6/logs"
time=`date +%Y%m%d`
/bin/mkdir -p  ${log_dir}/${date_dir} > /dev/null 2>&1
/bin/mv  ${log_dir}/access.test.com.log ${log_dir}/access.test.com.$time.log
kill -USR1 `cat  /var/run/nginx.pid`

#phpMyAdmin管理配制
#tar -zxvf phpMyAdmin-2.11.6-all-languages.tar.gz
#mv phpMyAdmin-2.11.6-all-languages /opt/case/phpmyadmin
#cp config.sample.inc.php config.inc.php
#vim config.inc.php

$cfg['PmaAbsoluteUri'] = 'http://192.168.1.1/phpmyadmin/';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['auth_type'] = 'cookie';  
$cfg['DefaultLang'] = 'zh';

$cfg['blowfish_secret'] = 'mysql@admin';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';