mkdir -pv /home/{software,data0,data1}
ln -s /home/software /
ln -s /home/data0 /
ln -s /home/data1 /
cd /software
wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz
wget http://www.monkey.org/~provos/libevent-1.3.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
wget http://www.teslacore.it/projects/amfext/amfext-0.9.zip


tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
ldconfig
./configure
make
make install
cd ../

groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3/
./configure --prefix=/usr/local/gserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod +w /usr/local/gserver/mysql
chown -R mysql:mysql /usr/local/gserver/mysql
cd ../

mkdir -p /data0/mysql/3306/data/
mkdir -p /data0/mysql/3306/binlog/
mkdir -p /data0/mysql/3306/relaylog/
chown -R mysql:mysql /data0/mysql/

/usr/local/gserver/mysql/bin/mysql_install_db --basedir=/usr/local/gserver/mysql --datadir=/data0/mysql/3306/data --user=mysql
vim /data0/mysql/3306/my.cnf
vim /data0/mysql/3306/mysql
chmod +x /data0/mysql/3306/mysql
/data0/mysql/3306/mysql start
/usr/local/gserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'JLDB!@#,.';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY 'JLDB!@#,.';
grant all privileges on *.* to 'admin'@'%' identified by 'JLDB!@#,.' with grant option;


cd /software
tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure --prefix=/usr/local/gserver/php --with-config-file-path=/usr/local/gserver/php/etc --with-mysql=/usr/local/gserver/mysql --with-mysqli=/usr/local/gserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
#结合apache时(运行完后make clean)./configure --prefix=/usr/local/gserver/php --with-config-file-path=/usr/local/gserver/php/etc --with-mysql=/usr/local/gserver/mysql --with-mysqli=/usr/local/gserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex  --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-apxs2=/usr/local/gserver/apache2/bin/apxs --without-sqlite --without-pdo-sqlite
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/gserver/php/etc/php.ini
cd ../

##安装中常见错误及解决方法:
##error: libjpeg.(a|so) not found.
##yum install libjpeg-devel
##yum install libpng-devel

##configure: error: Please reinstall the libcurl
##yum -y install curl-devel

##configure: error: freetype.h not found
##yum install freetype-devel

##configure: error: Cannot find ldap.h
##yum install openldap.i386 openldap-clients.i386 openldap-devel.i386 openldap-servers.i386

##error: mcrypt.h not found
##yum install libmcrypt-devel

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/gserver/php/bin/phpize
./configure --with-php-config=/usr/local/gserver/php/bin/php-config
make
make install
cd ../

#tar jxvf eaccelerator-0.9.6.1.tar.bz2
#cd eaccelerator-0.9.6.1/
#/usr/local/gserver/php/bin/phpize
#./configure --enable-eaccelerator=shared --with-php-config=/usr/local/gserver/php/bin/php-config
#make
#make install
#cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/gserver/php/bin/phpize
./configure --with-php-config=/usr/local/gserver/php/bin/php-config --with-pdo-mysql=/usr/local/gserver/mysql
make
make install
cd ../

tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/gserver/php/bin/phpize
./configure --with-php-config=/usr/local/gserver/php/bin/php-config
make
make install
cd ../

vim /usr/local/gserver/php/etc/php.ini
mkdir -p /usr/local/gserver/eaccelerator_cache

cd /software
unzip amfext-0.9.zip
cd amfext-0.9
/usr/local/gserver/php/bin/phpize
./configure --enable-amf --with-php-config=/usr/local/gserver/php/bin/php-config
make && make install


groupadd www
useradd -g www www
mkdir -p /data0/htdocs
chmod +w /data0/htdocs
chown -R www:www /data0/htdocs

vim /usr/local/gserver/php/etc/php-fpm.conf

ulimit -SHn 65535
/usr/local/gserver/php/sbin/php-fpm start

tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make
make install
cd ../

tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www --group=www --prefix=/usr/local/gserver/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install
cd ../

mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs

vi /usr/local/gserver/nginx/conf/nginx.conf

vi /usr/local/gserver/nginx/conf/fcgi.conf

ulimit -SHn 65535
/usr/local/gserver/nginx/sbin/nginx

tar xvfz  libevent-1.3.tar.gz
cd libevent-1.3
./configure --prefix=/usr
make
make install
cd ..

tar xvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --with-libevent=/usr
make
make install
/usr/local/bin/memcached -d -m 128 -u root -l 127.0.0.1 -p 11211 -c 512 -P /tmp/memcached.pid

echo "ulimit -SHn 65535" >> /etc/rc.local
echo "/usr/local/gserver/php/sbin/php-fpm start" >> /etc/rc.local
echo "/usr/local/gserver/nginx/sbin/nginx" >> /etc/rc.local
echo "/data0/mysql/3306/mysql start" >> /etc/rc.local
echo "/usr/local/bin/memcached -d -m 128 -u root -l 127.0.0.1 -p 11211 -c 512 -P /tmp/memcached.pid" >> /etc/rc.local


vi /etc/sysctl.conf
/sbin/sysctl -pd

 

#/usr/local/gserver/nginx/sbin/nginx -t
#/usr/local/gserver/nginx/sbin/nginx -s reload