mkdir -pv /usr/local/src/lamp
cd /usr/local/src/lamp

##download apache source code
wget http://apache.etoak.com/httpd/httpd-2.4.3.tar.gz
wget http://apache.dataguru.cn/apr/apr-1.4.6.tar.bz2
wget http://labs.mop.com/apache-mirror/apr/apr-util-1.5.1.tar.bz2

APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。

yum install zlib-devel gcc gcc-c++ openssl-devel pcre-devel -y


tar fvxj apr-1.4.6.tar.bz2 
./configure --prefix=/usr/local/apr
make
make install
tar fvxj apr-util-1.5.1.tar.bz2 
./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr/
make 
make install

##configure
tar fvxz httpd-2.4.3.tar.gz 

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-module=so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-ab --disable-userdir --with-mpm=prefork --enable-nonportable-atomics --disable-ipv6  --with-sendfile

make 
make install

/usr/local/apache2/bin/apachectl -k start

 


install mysql

rpm -ivh /tmp/cmake-2.6.4-7.el5.i386.rpm
groupadd mysql
useradd -g mysql mysql

tar xvf mysql-5.5.29

yum remove mysql-server mysql mysql-devel -y
yum install gcc gcc-c++ ncurses-devel libtool openssl-devel -y

cmake -H
mkdir -pv /usr/local/mysql/data

mysql souce code 
1 mysql client
2 mysql server (disable) ??
3 mysql devel

cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DWITH_INNODBBASE_STORAGE_ENGINE=1 \
-DENABLE_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_EMBEDED_SERVER=0


make

make install

cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
##config file edit
vim /etc/my.cnf
skip-name-resolve=1

cp support-files/mysql.server /etc/init.d/mysqlsource
chmod 755 /etc/init.d/mysqlsource   给权限

chown mysql.mysql /usr/local/mysql/ -R   
##init mysql datadir
sh scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/#初始化mysql


##error log
/usr/local/mysql/data/localhost.localdomain.err

 

##client login test   #mysql先关链接命令文件
ln -s /usr/local/mysql/bin/* /usr/bin/
ln -s /usr/local/mysql/lib/* /usr/lib/
ln -s /usr/local/mysql/libexec/*  /usr/local/libexec
ln -s /usr/local/mysql/share/man/man1/*  /usr/share/man/man1
ln -s /usr/local/mysql/share/man/man8/*  /usr/share/man/man8

mysql 


##secure after install
mysql_secure_installation  #设密码

 

php
yum install libxml2-devel bzip2-devel net-snmp-devel curl-devel libpng-devel freetype-devel libjpeg-devel zlib-devel gd-* -y

wget http://lnamp-web-server.googlecode.com/files/libiconv-1.14.tar.gz
tar fvxz libiconv-1.14.tar.gz
./configure --prefix=/usr/local/ --with-apr=/usr/local/apr
make
make install

 

wget http://lcmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz
wget http://lcmp.googlecode.com/files/mhash-0.9.9.9.tar.gz
wget http://lcmp.googlecode.com/files/mcrypt-2.6.8.tar.gz

tar fvxz libmcrypt-2.5.8.tar.gz
yum -y install gcc-c++
./configure && make && make install && /sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install && make && make install

 


tar fvxz mhash-0.9.9.9.tar.gz 
./configure && make && make install
ln -s /usr/local/lib/* /usr/lib/
ln -s /usr/local/bin/libmcrypt-config /usr/bin/


tar  fvxz mcrypt-2.6.8.tar.gz
./configure && make && make install

 


##install php
wget http://cn2.php.net/get/php-5.4.11.tar.bz2/from/this/mirror
tar fvxj php-5.4.11.tar.bz2 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-iconv-dir=/usr/local/ --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --disable-phar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt --enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip --enable-bcmath --with-snmp --disable-ipv6 --disable-rpath --disable-debug --with-apxs2=/usr/local/apache2/bin/apxs

 

#if bind to apache
--with-apxs2=/usr/local/apache2/bin/apxs  用apache调用php
#if no mysql
./configure --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd  这个不写

 

make ZEND_EXTRA_LIBS='-liconv'

make install
cp php.ini-production /usr/local/php/etc/php.ini

vim /usr/local/http/conf/httpd.conf
AddType application/x-httpd-php .php  #php5下面添加一行
解压网站到apache网站目录。如果不能安装论坛然后把网站目录设置权限一下

生产环境下  rhel6+php5+fpm+mysql+apache
            rhel6+php5+fastcgi+apache+mysql
-----------------------------------------------------------------------------------------
##install memcache for php
/usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config 
make 
make install

vim /usr/local/http/conf/httpd.conf
DirectoryIndex index.php index.html  #php5下面添加一行
kill all httpd  #杀死http进程
/usr/local/apache2/bin/httpd  #启动apache
cd /usr/local/apache2/htdocs/
vim /phpinfo.php
<?php phpinfo(); ?>  #测试PHP页面

把论坛程序拷到http目录下.
http://192.168.1.123/install
改目录权限

vim /usr/local/php/etc/php.ini
extension_dir=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
extension = "memcache.so"
short_open_tag = On
cgi.fix_pathinfo=0
disable_functions = exec,system ##ask coder

cd sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
listen = 0.0.0.0:9000
access.log = /tmp/fpm.access.log
error_log = /tmp/fpm.err.log


[root@localhost etc]# /etc/init.d/php-fpm start
Starting php-fpm  done
[root@localhost etc]# lsof -i:9000
COMMAND  PID   USER   FD   TYPE DEVICE SIZE NODE NAME
php-fpm 4145   root    7u  IPv4 279703           TCP localhost.localdomain:cslistener (LISTEN)
php-fpm 4146 apache    0u  IPv4 279703       TCP localhost.localdomain:cslistener (LISTEN)
php-fpm 4147 apache    0u  IPv4 279703       TCP localhost.localdomain:cslistener (LISTEN)


[root@localhost etc]# mkdir -pv /tmp/www
mkdir: 已创建目录 “/tmp/www”
[root@localhost etc]# cd /tmp/www/
[root@localhost www]# echo '<? phpinfo() ?>' > /tmp/www/index.php


#################################################################
##nginx config
   location ~ \.php$ {
            fastcgi_pass   fpmhostip:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /tmp/www/$fastcgi_script_name;
            include        fastcgi_params;
        }


#################################################################
##watch php module
php -m

 

 

#mysql 5.5
binlog  3mode ?

semi mysql       google


#################mysql memcache udf############################
install memcached
./configure --prefix=/usr/local/memcached
make
make install
memcached -u root -m 30M

 


wget http://launchpad.net/libmemcached/1.0/0.34/+download/libmemcached-0.34.tar.gz
yum install uuidd libevent libevent-devel libstdc++44-devel gcc44 gcc44-c++ -y
export CC=/usr/bin/gcc44 
export CXX=/usr/bin/g++44 

tar fvxz libmemcached-0.34.tar.gz
./configure --with-memcached=/usr/local/memcached/bin/memcached
make
make install

ln -s /usr/local/lib/libmemcached* /usr/lib
unset CC CXX



wget memcached_functions_mysql-1.1.tar.gz
./configure --with-mysql
make 
make install
ln -s /usr/local/lib/libmemcached_functions_mysql.* /usr/local/mysql/lib/plugin/

mysql -u root -p123 < sql/install_functions.sql 

##create connection####
mysql> select memc_udf_version();
+--------------------+
| memc_udf_version() |
+--------------------+
| 1.1                |
+--------------------+
1 row in set (0.04 sec)

 

memcache----mysql----test
mysql -u root -p123 abc < sql/trigger_fun.sql