# 手动安装lnmp 包含 libiconv libunwind gperftools libmcrypt mhash mcrypt libpng freetype jpeg gd pcre libmemcached php_memcached(memcached.so) eaccelerator ZendOptimizer MySQL5.5 php5.3 nginx1.2.7 memcached tokyocabinet tokyotyrant #路径 程序存放 /data/service lib or common /data/service/common 数据存放 /data/data 日志存放 /data/logs
# yum源更改 rm -f CentOS6-Base-163.repo \ rm -f /etc/yum.repos.d/CentOS6-Base-163.repo yum install -y wget wget -4 --no-cache http://mirrors.163.com/.help/CentOS6-Base-163.repo \ -O /etc/yum.repos.d/CentOS6-Base-163.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
yum makecache && yum update -y && rm -f /etc/yum.repos.d/CentOS-Base.repo
yum install ntp wget cpp gcc gcc-c++ gcc-g77 make unzip libtool \ libtool-ltdl-devel libc-client-devel libstdc++-devel db4-utils libcap-devel \ expat-devel perl pam-devel perl-Time-HiRes libaio-devel bzr patch bzip2-devel \ cmake bison libevent-devel ncurses-devel openssl-devel zlib-devel curl-devel \ libxml2-devel tcp_wrappers-devel nasm lemon flex libXpm-devel fontconfig-devel \ pcre-devel sqlite-devel perl-ExtUtils-Embed neon-devel
# centos 5 yum install libmcrypt-devel mhash-devel
# 系统自带png, jpeg, freetype yum install libpng-devel libjpeg-devel freetype-devel
# libiconv ./configure make && make install echo "/usr/local/lib" >> \ /etc/ld.so.conf.d/service_lib.conf && /sbin/ldconfig
# libunwind CFLAGS=-fPIC ./configure make CFLAGS=-fPIC && make CFLAGS=-fPIC install
# gperftools ./configure --enable-frame-pointers make && make install /sbin/ldconfig
# mysql 5.5 groupadd mysql -g 1002 useradd mysql -u 1002 -g mysql -s /sbin/nologin
rm -f CMakeCache.txt cmake \ . -DCMAKE_INSTALL_PREFIX=/data/service/mysql \ -DMYSQL_DATADIR=/data/data/mysql \ -DSYSCONFDIR=/data/service/mysql/etc \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_EXAMPLE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_TCP_PORT=3306 \ -DWITH_DEBUG=0 make && make install
# mysql5.1 ./configure \ --prefix=/data/service/mysql \ --localstatedir=/data/data/mysql \ --sysconfdir=/data/service/mysql/etc \ --with-mysqld-user=mysql \ --without-debug \ --with-big-tables \ --with-unix-socket-path=/tmp/mysql.sock \ --with-charset=gbk \ --with-collation=gbk_chinese_ci \ --with-extra-charsets=all \ --with-plugins=partition \ --enable-static \ --with-client-ldflags=-all-static \ --with-tcp-port=3306
ln -s /data/service/mysql/lib /data/service/mysql/lib64 echo "/data/service/mysql/lib64/" >> \ /etc/ld.so.conf.d/service_lib.conf && /sbin/ldconfig
mkdir -p /data/service/mysql/etc && mkdir -p /data/data/mysql cp -f support-files/my-medium.cnf /data/service/mysql/etc/my.cnf # add gperftools sed -i 's/executing\ mysqld_safe$/&\nexport\ LD_PRELOAD="\/usr\/local\/lib\/libtcmalloc.so"/' \ /data/service/mysql/bin/mysqld_safe
cp -f support-files/mysql.server /data/service/mysql/mysqld chmod 755 /data/service/mysql/mysqld chown -R mysql.mysql /data/data/mysql
[mysqld] pid-file = /data/data/mysql/mysqld.pid datadir = /data/data/mysql
max_connections = 500 max_connect_errors=10000 slow_query_log=1 slow_query_log_file = /data/data/mysql/slowsql.log long_query_time = 2 log-queries-not-using-indexes
innodb_file_per_table = 1 innodb_data_home_dir = /data/data/mysql innodb_data_file_path = ibdata1:10M:autoextend:max:2000M innodb_log_group_home_dir = /data/data/mysql innodb_file_per_table = 1 innodb_buffer_pool_size = 256M innodb_additional_mem_pool_size = 2M innodb_log_buffer_size = 8M innodb_log_file_size = 256M innodb_log_files_in_group = 3 sync_binlog = 1 innodb_flush_log_at_trx_commit = 0 innodb_lock_wait_timeout = 50
log-bin=mysql-bin binlog_format = mixed expire_logs_days = 7
[mysqld_safe] log-error = /data/data/mysql/mysql.log
/data/service/mysql/scripts/mysql_install_db \ --user=mysql --basedir=/data/service/mysql --datadir=/data/data/mysql /data/service/mysql/mysqld start /data/service/mysql/mysqld restart #/data/service/mysql/bin/mysqladmin -uroot password /data/service/mysql/mysqld stop
# libmcrypt, centos6 ./configure --prefix=/data/service/common/libmcrypt make && make install ln -s /data/service/common/libmcrypt/lib /data/service/common/libmcrypt/lib64 echo "/data/service/common/libmcrypt/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# mhash, centos6 ./configure --prefix=/data/service/common/mhash make && make install ln -s /data/service/common/mhash/lib /data/service/common/mhash/lib64 echo "/data/service/common/mhash/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# mcrypt, centos6 #LD_LIBRARY_PATH=/data/service/common/libmcrypt/lib:/data/service/common/mhash/lib \ LDFLAGS="-L/data/service/common/mhash/lib/ -I/data/service/common/mhash/include/" \ CFLAGS="-I/data/service/common/mhash/include/" \ ./configure --prefix=/data/service/common/mcrypt \ --with-libmcrypt-prefix=/data/service/common/libmcrypt make && make install ln -s /data/service/common/mcrypt/lib /data/service/common/mcrypt/lib64 echo "/data/service/common/mcrypt/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# libpng #下面这句,测试不能执行,否则就会报告下面的错误,而且无法安装到/usr/lib/libpng/下 #cp scripts/makefile.linux makefile ./configure --prefix=/data/service/common/libpng --enable-shared --enable-static make && make install ln -s /data/service/common/libpng/lib /data/service/common/libpng/lib64 echo "/data/service/common/libpng/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# freetype ./configure --prefix=/data/service/common/freetype --enable-shared --enable-static make && make install ln -s /data/service/common/freetype/lib /data/service/common/freetype/lib64 echo "/data/service/common/freetype/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# libjpeg ./configure --prefix=/data/service/common/libjpeg --enable-shared --enable-static make && make install ln -s /data/service/common/libjpeg/lib /data/service/common/libjpeg/lib64 echo "/data/service/common/libjpeg/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# gd yum install libXpm-devel fontconfig-devel
##centos 5需安装gettext ./configure \ make && make install
PATH=/data/service/common/libpng/bin/:$PATH \ LDFLAGS="-L/data/service/common/libpng/lib/" \ CFLAGS="-I/data/service/common/libpng/include/" \ ./configure --prefix=/data/service/common/gd \ --enable-shared --enable-static \ --with-png=/data/service/common/libpng \ --with-freetype=/data/service/common/freetype \ --with-jpeg=/data/service/common/libjpeg
make && make install ln -s /data/service/common/gd/lib /data/service/common/gd/lib64 echo "/data/service/common/gd/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# pcre ./configure --prefix=/data/service/common/pcre \ --enable-shared --enable-static make && make install ln -s /data/service/common/pcre/lib /data/service/common/pcre/lib64 echo "/data/service/common/pcre/lib64" >> \ /etc/ld.so.conf.d/service_lib.conf && ldconfig
# php5.3 You will need re2c 0.13.4 or later if you want to regenerate PHP parsers http://nchc.dl.sourceforge.net/project/re2c/re2c/0.13.5/re2c-0.13.5.tar.gz ./configure && make && make install
./configure \ --prefix=/data/service/phpfpm \ --with-config-file-path=/data/service/phpfpm/etc \ --with-libdir=lib64 \ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mcrypt=/data/service/common/libmcrypt \ --with-mhash=/data/service/common/mhash \ --with-gd=/data/service/common/gd \ --with-pcre-dir=/data/service/common/pcre \ --with-freetype-dir=/data/service/common/freetype \ --with-jpeg-dir=/data/service/common/libjpeg \ --with-png-dir=/data/service/common/libpng \ --with-openssl \ --with-zlib \ --with-curl \ --with-curlwrappers \ --with-xmlrpc \ --with-bz2 \ --with-gettext \ --with-xpm-dir \ --enable-fpm \ --enable-ftp \ --enable-sockets \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-mbstring \ --enable-gd-native-ttf \ --enable-sockets \ --enable-zip \ --enable-soap \ --enable-pcntl \ --disable-rpath
#--with-iconv-dir=/data/service/common/libiconv
make && make install mkdir -p /data/service/phpfpm/etc cp -f php.ini-production /data/service/phpfpm/etc/php.ini sed -i '$a \\nextension_dir = "/data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626/"' \ /data/service/phpfpm/etc/php.ini
#php5.2 wget -4 http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz ./configure --prefix=/data/service/common/autoconf_2.13 \ make && make install
wget -4 http://cn2.php.net/distributions/php-5.2.17.tar.gz wget -4 http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz wget -4 https://raw.github.com/laruence/laruence.github.com/master/php-5.2-max-input-vars/php-5.2.17-max-input-vars.patch gzip -d php-5.2.17-fpm-0.5.14.diff.gz tar zxf php-5.2.17.tar.gz cd php-5.2.17 patch -p1 < ../php-5.2.17-fpm-0.5.14.diff patch -p1 < ../php-5.2.17-max-input-vars.patch rm -rf configure \ && PHP_AUTOCONF="/data/service/common/autoconf_2.13/bin/autoconf" \ PHP_AUTOHEADER="/data/service/common/autoconf_2.13/bin/autoheader" \ ./buildconf --force
./configure --prefix=/data/service/phpfpm_52 \ --with-config-file-path=/data/service/phpfpm_52/etc \ --with-libdir=lib64 \ --with-mysql=/data/service/mysql \ --with-mysqli=/data/service/mysql/bin/mysql_config \ --with-pdo-mysql=/data/service/mysql \ --with-mcrypt=/data/service/common/libmcrypt \ --with-mhash=/data/service/common/mhash \ --with-gd=/data/service/common/gd \ --with-freetype-dir=/data/service/common/freetype \ --with-jpeg-dir=/data/service/common/libjpeg \ --with-png-dir=/data/service/common/libpng \ --with-openssl \ --with-zlib \ --with-curl \ --with-curlwrappers \ --with-xmlrpc \ --with-bz2 \ --with-xpm-dir \ --enable-fpm \ --enable-fastcgi \ --enable-force-cgi-redirect \ --enable-ftp \ --enable-sockets \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-inline-optimization \ --enable-mbregex \ --enable-mbstring \ --enable-gd-native-ttf \ --enable-sockets \ --enable-zip \ --enable-soap \ --enable-pcntl \ --disable-rpath
./configure --prefix=/data/service/php \ --with-config-file-path=/data/service/php/etc \ --with-libdir=lib64 \ --with-apxs2=/data/service/httpd/bin/apxs \ --with-mysql=/data/service/mysql \ --with-mysqli=/data/service/mysql/bin/mysql_config \ --with-pdo-mysql=/data/service/mysql \ --with-gd=/data/service/common/gd \ --with-mcrypt \ --with-mhash \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-openssl \ --with-zlib \ --with-curl \ --with-curlwrappers \ --with-xmlrpc \ --with-bz2 \ --with-xpm-dir \ --enable-ftp \ --enable-sockets \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-inline-optimization \ --enable-mbregex \ --enable-mbstring \ --enable-gd-native-ttf \ --enable-sockets \ --enable-zip \ --enable-soap \ --enable-pcntl \ --disable-rpath make && make install mkdir -p /data/service/phpfpm_52/etc cp -f php.ini-recommended /data/service/phpfpm_52/etc/php.ini cp sapi/cgi/fpm/php-fpm /data/service/phpfpm_52/bin/php-fpm && chmod 755 /data/service/phpfpm_52/bin/php-fpm sed -i '$a \\nextension_dir = "/data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/"' /data/service/phpfpm_52/etc/php.ini
short_open_tag = On
# memcached/tar.gz ./configure --prefix=/data/service/memcached make && make install
# libmemcached ##centos5需安装gcc44 gcc44-c++ yum install gcc44 gcc44-c++ libstdc++44-devel export CC=/usr/bin/gcc44 export CXX=/usr/bin/g++44
./configure --prefix=/data/service/common/libmemcached \ --with-memcached=/data/service/memcached make && make install ln -s /data/service/common/libmemcached/lib /data/service/common/libmemcached/lib64
# memcache.so/tgz php_memcache /data/service/phpfpm/bin/phpize \ && ./configure \ --enable-memcache \ --with-php-config=/data/service/phpfpm/bin/php-config make && make install sed -i '$a \;extension=memcache.so' /data/service/phpfpm/etc/php.ini # php5.2 /data/service/php/bin/phpize \ && ./configure \ --enable-memcache \ --with-php-config=/data/service/php/bin/php-config make && make install sed -i '$a \;extension=memcache.so' /data/service/php/etc/php.ini
# memcached.so/tgz zlib/php_memcached /data/service/php/bin/phpize \ && ./configure \ --with-php-config=/data/service/php/bin/php-config \ --enable-memcached \ --with-libmemcached-dir=/data/service/common/libmemcached make && make install sed -i '$a \extension=memcached.so' /data/service/php/etc/php.ini # php5.2 /data/service/phpfpm_52/bin/phpize \ && ./configure \ --with-php-config=/data/service/phpfpm_52/bin/php-config \ --enable-memcached \ --with-libmemcached-dir=/data/service/common/libmemcached make && make install sed -i '$a \extension=memcached.so' /data/service/phpfpm_52/etc/php.ini
sed -i "s#session.save_handler\ =\ files#;session.save_handler\ =\ files#g" /data/service/phpfpm/etc/php.ini sed -i '$a \;session.save_handler = memcached\n;session.save_path = "ip:port"' /data/service/phpfpm/etc/php.ini
#php5.2 sed -i "s#session.save_handler\ =\ files#;session.save_handler\ =\ files#g" /data/service/phpfpm_52/etc/php.ini sed -i '$a \;session.save_handler = memcached\n;session.save_path = "ip:port"' /data/service/phpfpm_52/etc/php.ini
# eaccelerator /data/service/phpfpm/bin/phpize \ && ./configure \ --enable-eaccelerator=shared \ --with-php-config=/data/service/phpfpm/bin/php-config make && make install sed -i '$a \;extension=eaccelerator.so' /data/service/phpfpm/etc/php.ini
#5.2 /data/service/php/bin/phpize \ && ./configure \ --enable-eaccelerator=shared \ --with-php-config=/data/service/php/bin/php-config make && make install sed -i '$a \;extension=eaccelerator.so' /data/service/php/etc/php.ini
#APC /data/service/phpfpm/bin/phpize \ && ./configure \ --enable-eaccelerator=shared \ --with-php-config=/data/service/phpfpm/bin/php-config make && make install sed -i '$a \;extension=eaccelerator.so' /data/service/phpfpm/etc/php.ini
# ZendGuardLoader php5.3 cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so \ /data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626/ sed -i '$a \\n\;[Zend]\n;zend_extension="/data/service/phpfpm/lib/php/extensions/no-debug-non-zts-20090626/ZendGuardLoader.so"\n;zend_loader.enable=1\n;zend_loader.disable_licensing=0\n;zend_loader.obfuscation_level_support=3\n;zend_loader.license_path=\n' /data/service/phpfpm/etc/php.ini # ZendOptimizer php5.2 cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/ sed -i '$a \\n\;[Zend]\n;zend_extension="/data/service/phpfpm_52/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so"\n;zend_loader.enable=1\n;zend_loader.disable_licensing=0\n;zend_loader.obfuscation_level_support=3\n;zend_loader.license_path=\n' /data/service/phpfpm_52/etc/php.ini
# nginx groupadd www -g 1001 useradd www -u 1001 -g www -s /sbin/nologin
./configure \ --prefix=/data/service/nginx \ --with-http_stub_status_module \ --with-pcre=../pcre-8.32 \ --with-http_ssl_module \ --with-google_perftools_module
./configure --prefix='/data/service/nginx' --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt='-Wno-error' --add-module='/usr/local/lib/ruby/gems/2.0.0/gems/passenger-3.0.21/ext/nginx' make && make install
# 安装apr ./configure \ --prefix=/data/service/common/apr make && make install # 安装apr-util ./configure \ --prefix=/data/service/common/apr-util \ --with-apr=/data/service/common/apr make && make install # 编译apache2服务 fcgid groupadd www -g 1001 \ && useradd www -u 1001 -g www -s /sbin/nologin ./configure --prefix=/data/service/httpd \ --with-perl \ --enable-usertrack \ --enable-headers \ --enable-deflate \ --enable-expires \ --enable-status \ --enable-http \ --enable-dav \ --enable-rewrite \ --enable-ssl \ --enable-so \ --enable-proxy \ --enable-proxy-fcgi \ --enable-mpms-shared=all \ --enable-modules=all \ --enable-mods-shared=all \ --with-pcre=/data/service/common/pcre \ --with-apr=/data/service/common/apr \ --with-apr-util=/data/service/common/apr-util mod_fcgid APXS=/data/service/httpd/bin/apxs ./configure.apxs make && make instal
# 编译apache2服务 mod_php.so ./configure \ --prefix=/data/service/httpd \ --with-perl \ --enable-v4-mapped \ --enable-usertrack \ --enable-headers \ --enable-deflate \ --enable-expires \ --enable-status \ --enable-http \ --enable-dav \ --enable-rewrite=shared \ --enable-ssl \ --enable-so \ --enable-proxy \ --enable-mpms-shared=prefork \ --enable-modules=all \ --enable-mods-shared=most \ --enable-http \ --enable-module=so \ --with-pcre=/data/service/common/pcre \ --with-apr=/data/service/common/apr \ --with-apr-util=/data/service/common/apr-util
#vsftpd vi defs.h 把/etc/vsftpd.conf /data/service/vsftpd/etc/vsftpd.conf vi builddefs.h 把 #undef VSF_BUILD_TCPWRAPPERS 修改成 #define VSF_BUILD_TCPWRAPPERS 把 #undef VSF_BUILD_SSL 修改成 #define VSF_BUILD_SSL
make mkdir -p /data/service/vsftpd/sbin /data/service/vsftpd/man /data/service/vsftpd/etc /data/service/vsftpd/etc/virtual cp vsftpd /data/service/vsftpd/sbin/vsftpd \ && chmod 755 /data/service/vsftpd/sbin/vsftpd cp vsftpd.8 /data/service/vsftpd/man/vsftpd.8 \ && chmod 644 /data/service/vsftpd/man/vsftpd.8 cp vsftpd.conf.5 /data/service/vsftpd/man/vsftpd.conf.5 \ && chmod 644 /data/service/vsftpd/man/vsftpd.conf.5 cp vsftpd.conf /data/service/vsftpd/etc/vsftpd.conf.default \ && chmod 644 /data/service/vsftpd/etc/vsftpd.conf.default cp RedHat/vsftpd.pam /data/service/vsftpd/etc/vsftpd.pam \ && chmod 644 /data/service/vsftpd/etc/vsftpd.pam echo -e "user\npassword\n" > /data/service/vsftpd/etc/user_pass \ echo "user" > /data/service/vsftpd/etc/user_list
echo "/usr/bin/db_load -T -t hash -f /data/service/vsftpd/etc/user_pass /data/service/vsftpd/etc/login.db" \ >> /data/service/vsftpd/sbin/pass.sh \ && chmod 755 /data/service/vsftpd/sbin/pass.sh
vi /etc/pam.d/vsftpd auth required /lib64/security/pam_userdb.so db=/data/service/vsftpd/etc/login account required /lib64/security/pam_userdb.so db=/data/service/vsftpd/etc/login
# tokyo cabinet ./configure --prefix=/data/service/common/tokyocabinet make && make install
# tokyo tyrant ./configure --prefix=/data/service/tokyotyrant --with-tc=/data/service/common/tokyocabinet make && make install
/data/service/tokyotyrant/bin/ttserver -port 11213 -thnum 8 -dmn -pid /data/data/ttdb/ttserver.pid -log /data/data/ttdb/ttserver.log -le -ulog /data/data/ttdb/ -ulim 256m -sid 1 -rts /data/data/ttdb/ttserver.rts /data/data/ttdb/database.tcb#lmemb=1024#nmemb2048#bnum10000000
/data/service/memcached/bin/memcached -d -u www -c 64 -p 11212