安装依赖
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
1.安装Jemalloc
wget https://github.com/jemalloc/jemalloc/releases/download/4.2.1/jemalloc-4.2.1.tar.bz2
tar -xjvf jemalloc-4.2.1.tar.bz2
cd jemalloc-4.2.1
./configure
make && make install
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
ldconfig
2.安装 mysql 5.7太吃内存
useradd -M -s /sbin/nologin mysql
mkdir -p /data/mysql;chown mysql.mysql -R /data/mysql
wget https://cmake.org/files/v3.7/cmake-3.7.0-rc1.tar.gz
tar -zxvf cmake-3.7.0-rc1.tar.gz
cd cmake-3.7.0-rc1
CFLAGS= CXXFLAGS= ./configure
make && make install
cd ..
/bin/rm -rf cmake-3.7.0-rc1
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.15.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.52.tar.gz
tar -zxvf mysql-5.7.15.tar.gz
cd mysql-5.7.15
make clean
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=1 \
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
make && make install
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
vi /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema = 0
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
chown mysql.mysql -R /data/mysql
service mysqld start
VI /etc/profile
export PATH=/usr/local/mysql/bin:\$PATH
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"123456\" with grant option;"
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"123456\" with grant option;"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.user where Password='';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.db where User='';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.proxies_priv where Host!='localhost';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "drop database test;"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "reset master;"
3.安装php
wget http://soft.hxtdt.com/libiconv-1.14.tar.gz
tar xzf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
cd ../
/bin/rm -rf libiconv-1.14
wget http://soft.hxtdt.com/libmcrypt-2.5.8.tar.gz
tar xzf 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 ../../
/bin/rm -rf libmcrypt-2.5.8
wget http://soft.hxtdt.com/mhash-0.9.9.9.tar.gz
tar xzf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
cd ../
/bin/rm -rf mhash-0.9.9.9
yum -y install openldap openldap-devel nss_ldap openldap-clients openldap-servers
/bin/cp -frp /usr/lib64/libldap* /usr/lib/
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
wget http://soft.hxtdt.com/mcrypt-2.6.8.tar.gz
tar xzf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
ldconfig
./configure
make && make install
cd ../
/bin/rm -rf mcrypt-2.6.8
wget http://soft.hxtdt.com/php-5.6.14.tar.gz
tar xzf php-5.6.14.tar.gz
useradd -M -s /sbin/nologin www
wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
patch -d php-5.6.14 -p0 < fpm-race-condition.patch
cd php-5.6.14
make clean
CFLAGS= CXXFLAGS= ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \
--with-fpm-user=www --with-fpm-group=www --enable-fpm --enable-opcache --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-fileinfo \
--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-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-inline-optimization \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug --with-ldap --with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
rm -rf /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
rm -rf /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ZendGuardLoader.so
wget http://soft.hxtdt.com/opcache.so
mv opcache.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
wget http://soft.hxtdt.com/ZendGuardLoader.so
mv ZendGuardLoader.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ZendGuardLoader.so
/bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm \n
chkconfig php-fpm on
4.安装php扩展
wget http://soft.hxtdt.com/extension/redis-2.2.5.tgz
tar xzf redis-2.2.5.tgz
cd redis-2.2.5
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "redis.so"@' /usr/local/php/etc/php.ini
5.安装ImageMagick
wget http://soft.hxtdt.com/ImageMagick-6.9.2-4.tar.gz
tar xzf ImageMagick-6.9.2-4.tar.gz
cd ImageMagick-6.9.2-4
./configure
make && make install
cd ../
/bin/rm -rf ImageMagick-6.9.2-4
ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick
yum -y install ImageMagick-devel
wget http://soft.hxtdt.com/extension/imagick-3.2.0RC1.tgz
tar xzf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1
make clean
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
/bin/rm -rf imagick-3.2.0RC1
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "imagick.so"@' /usr/local/php/etc/php.ini
6.安装memcache扩展
wget http://soft.hxtdt.com/extension/libmemcached-1.0.18.tar.gz
wget http://soft.hxtdt.com/extension/memcached-2.2.0.tgz
wget http://soft.hxtdt.com/extension/memcache-2.2.7.tgz
# php memcache extension
tar xzf memcache-2.2.7.tgz
cd memcache-2.2.7
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ..
/bin/rm -rf memcache-2.2.7
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcache.so"@' /usr/local/php/etc/php.ini
# php memcached extension
tar xzf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
yum -y install cyrus-sasl-devel
./configure --prefix=/usr/local/libmemcached --with-memcached
make && make install
cd ..
/bin/rm -rf libmemcached-1.0.18
tar xzf memcached-2.2.0.tgz
cd memcached-2.2.0
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached --with-libmemcached-dir=/usr/local/libmemcached
make && make install
cd ../
/bin/rm -rf memcached-2.2.0
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions/ | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcached.so"@' /usr/local/php/etc/php.ini
7.安装openresty
yum install -y gcc gcc-c++ readline-devel pcre-devel openssl-devel tcl perl postgresql-devel
1)安装prec (nginx rewrite依赖于PCRE库)
wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make && make install
cd ../
2)安装openresty
wget http://openresty.org/download/openresty-1.9.15.1.tar.gz
tar -zxvf openresty-1.9.15.1.tar.gz
cd openresty-1.9.15.1
mkdir -p /usr/local/openresty/nginx/var/run
mkdir -p /usr/local/openresty
./configure --prefix=/usr/local/openresty --user=www --group=www --with-luajit --with-http_iconv_module --with-http_postgres_module --with-pcre=../pcre-8.39 --with-pcre --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc-opt=' -O3'
make && make install
cd ..
rm -rf pcre-8.39
rm -rf openresty-1.9.15.1
8.安装nginx
wget http://nginx.org/download/nginx-1.11.5.tar.gz
tar -zxvf nginx-1.11.5.tar.gz
cd nginx-1.11.5
./configure --prefix=/usr/local/openresty/nginx --pid-path=/usr/local/openresty/nginx/var/run --lock-path=/usr/local/openresty/nginx/var/run --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt='-ljemalloc' --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-mail --with-mail_ssl_module --with-http_addition_module --with-debug --with-http_mp4_module --with-http_realip_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-cpp_test_module --with-pcre=../pcre-8.39
make && make install
/bin/cp init/Openresty-init-CentOS /etc/init.d/nginx \n
chkconfig --add nginx \n
chkconfig nginx on
sed -i "s@/usr/local/nginx@/usr/local/openresty/nginx@g" /etc/init.d/nginx
mv /usr/local/openresty/nginx/conf/nginx.conf{,_bk}
/bin/cp conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@/home/wwwroot/default@/data/www/htdocs/default@" /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@/home/wwwlogs@/data/nginx/logs@g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@nginx_install_dir@/usr/local/openresty/nginx@g" /usr/local/openresty/nginx/conf/nginx.conf
9.安装redis
wget http://soft.hxtdt.com/redis-2.8.13.tar.gz
tar xzf redis-2.8.13.tar.gz
cd redis-2.8.13
make
mkdir -p /usr/local/redis/{bin,etc,var} /usr/local/redis/var/run /data/redis/6379 /data/redis/6379/{data,log}
/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} /usr/local/redis/bin/
/bin/cp redis.conf /usr/local/redis/etc/
ln -s /usr/local/redis/bin/* /usr/local/bin/
sed -i "s@#\sbind 127.0.0.1@bind 127.0.0.1@" /usr/local/redis/etc/redis.conf
sed -i "s@pidfile.*@pidfile /usr/local/redis/var/run/redis.pid@" /usr/local/redis/etc/redis.conf
sed -i "s@logfile.*@logfile /data/redis/6379/log/redis.log@" /usr/local/redis/etc/redis.conf
sed -i "s@^dir.*@dir /data/redis/6379/data@" /usr/local/redis/etc/redis.conf
sed -i 's@daemonize no@daemonize yes@' /usr/local/redis/etc/redis.conf
[ -z "`grep ^maxmemory /usr/local/redis/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 128000000@' /usr/local/redis/etc/redis.conf
cd ..
/bin/rm -rf redis-2.8.13
cd ..
/bin/cp init/Redis-server-init-CentOS /etc/init.d/redis-server \n
chkconfig --add redis-server \n
chkconfig redis-server on
sed -i "s@/usr/local/redis@/usr/local/redis@g" /etc/init.d/redis-server
10.安装memcacheq
wget http://soft.hxtdt.com/db-6.1.26.tar.gz
wget http://soft.hxtdt.com/memcacheq-0.2.0.tar.gz
yum -y install libevent libevent-devel
useradd -M -s /sbin/nologin memcacheq
mkdir -p /data/memcacheq/data /data/memcacheq/logs;
chown memcacheq.memcacheq -R /data/memcacheq/data
chown memcacheq.memcacheq -R /data/memcacheq/logs
# memcacheQ server
tar xzf db-6.1.26.tar.gz
cd db-6.1.26
cd build_unix
../dist/configure --prefix=/usr/local/berkeleydb
make & make install
cd ../
cd ../
rm -rf db-6.1.26
echo "/usr/local/berkeleydb/lib/" >> /etc/ld.so.conf
ldconfig
tar zxvf memcacheq-0.2.0.tar.gz
cd memcacheq-0.2.0
./configure --prefix=/usr/local/memcacheq --with-bdb=/usr/local/berkeleydb --with-libevent=/usr/local/lib --enable-threads
make
make install
cd ../
rm -rf memcacheq-0.2.0
ln -s /usr/local/memcacheq/bin/memcacheq /usr/bin/memcacheq
/bin/cp ../init/Memcacheq-init-CentOS /etc/init.d/memcacheq \n
chkconfig --add memcacheq \n
chkconfig memcacheq on
sed -i "s@/usr/local/memcached@/usr/local/memcacheq@g" /etc/init.d/memcacheq
sed -i "s@/data/memcacheq/data@/data/memcacheq/data@g" /etc/init.d/memcacheq
sed -i "s@/data/memcacheq/log@/data/memcacheq/logs@g" /etc/init.d/memcacheq
service memcacheq start
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
1.安装Jemalloc
wget https://github.com/jemalloc/jemalloc/releases/download/4.2.1/jemalloc-4.2.1.tar.bz2
tar -xjvf jemalloc-4.2.1.tar.bz2
cd jemalloc-4.2.1
./configure
make && make install
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
ldconfig
2.安装 mysql 5.7太吃内存
useradd -M -s /sbin/nologin mysql
mkdir -p /data/mysql;chown mysql.mysql -R /data/mysql
wget https://cmake.org/files/v3.7/cmake-3.7.0-rc1.tar.gz
tar -zxvf cmake-3.7.0-rc1.tar.gz
cd cmake-3.7.0-rc1
CFLAGS= CXXFLAGS= ./configure
make && make install
cd ..
/bin/rm -rf cmake-3.7.0-rc1
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.15.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.52.tar.gz
tar -zxvf mysql-5.7.15.tar.gz
cd mysql-5.7.15
make clean
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=1 \
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
make && make install
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
vi /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema = 0
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
chown mysql.mysql -R /data/mysql
service mysqld start
VI /etc/profile
export PATH=/usr/local/mysql/bin:\$PATH
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"123456\" with grant option;"
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"123456\" with grant option;"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.user where Password='';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.db where User='';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "delete from mysql.proxies_priv where Host!='localhost';"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "drop database test;"
/usr/local/mysql/bin/mysql -uroot -p123456 -e "reset master;"
3.安装php
wget http://soft.hxtdt.com/libiconv-1.14.tar.gz
tar xzf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
cd ../
/bin/rm -rf libiconv-1.14
wget http://soft.hxtdt.com/libmcrypt-2.5.8.tar.gz
tar xzf 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 ../../
/bin/rm -rf libmcrypt-2.5.8
wget http://soft.hxtdt.com/mhash-0.9.9.9.tar.gz
tar xzf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
cd ../
/bin/rm -rf mhash-0.9.9.9
yum -y install openldap openldap-devel nss_ldap openldap-clients openldap-servers
/bin/cp -frp /usr/lib64/libldap* /usr/lib/
echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
wget http://soft.hxtdt.com/mcrypt-2.6.8.tar.gz
tar xzf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
ldconfig
./configure
make && make install
cd ../
/bin/rm -rf mcrypt-2.6.8
wget http://soft.hxtdt.com/php-5.6.14.tar.gz
tar xzf php-5.6.14.tar.gz
useradd -M -s /sbin/nologin www
wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1'
patch -d php-5.6.14 -p0 < fpm-race-condition.patch
cd php-5.6.14
make clean
CFLAGS= CXXFLAGS= ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \
--with-fpm-user=www --with-fpm-group=www --enable-fpm --enable-opcache --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-fileinfo \
--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-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-inline-optimization \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp \
--with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug --with-ldap --with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
rm -rf /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
rm -rf /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ZendGuardLoader.so
wget http://soft.hxtdt.com/opcache.so
mv opcache.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
wget http://soft.hxtdt.com/ZendGuardLoader.so
mv ZendGuardLoader.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ZendGuardLoader.so
/bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm \n
chkconfig php-fpm on
4.安装php扩展
wget http://soft.hxtdt.com/extension/redis-2.2.5.tgz
tar xzf redis-2.2.5.tgz
cd redis-2.2.5
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "redis.so"@' /usr/local/php/etc/php.ini
5.安装ImageMagick
wget http://soft.hxtdt.com/ImageMagick-6.9.2-4.tar.gz
tar xzf ImageMagick-6.9.2-4.tar.gz
cd ImageMagick-6.9.2-4
./configure
make && make install
cd ../
/bin/rm -rf ImageMagick-6.9.2-4
ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick
yum -y install ImageMagick-devel
wget http://soft.hxtdt.com/extension/imagick-3.2.0RC1.tgz
tar xzf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1
make clean
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
/bin/rm -rf imagick-3.2.0RC1
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "imagick.so"@' /usr/local/php/etc/php.ini
6.安装memcache扩展
wget http://soft.hxtdt.com/extension/libmemcached-1.0.18.tar.gz
wget http://soft.hxtdt.com/extension/memcached-2.2.0.tgz
wget http://soft.hxtdt.com/extension/memcache-2.2.7.tgz
# php memcache extension
tar xzf memcache-2.2.7.tgz
cd memcache-2.2.7
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ..
/bin/rm -rf memcache-2.2.7
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcache.so"@' /usr/local/php/etc/php.ini
# php memcached extension
tar xzf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
yum -y install cyrus-sasl-devel
./configure --prefix=/usr/local/libmemcached --with-memcached
make && make install
cd ..
/bin/rm -rf libmemcached-1.0.18
tar xzf memcached-2.2.0.tgz
cd memcached-2.2.0
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached --with-libmemcached-dir=/usr/local/libmemcached
make && make install
cd ../
/bin/rm -rf memcached-2.2.0
[ -z "`cat /usr/local/php/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions/ | grep zts`\"@" /usr/local/php/etc/php.ini
sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcached.so"@' /usr/local/php/etc/php.ini
7.安装openresty
yum install -y gcc gcc-c++ readline-devel pcre-devel openssl-devel tcl perl postgresql-devel
1)安装prec (nginx rewrite依赖于PCRE库)
wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make && make install
cd ../
2)安装openresty
wget http://openresty.org/download/openresty-1.9.15.1.tar.gz
tar -zxvf openresty-1.9.15.1.tar.gz
cd openresty-1.9.15.1
mkdir -p /usr/local/openresty/nginx/var/run
mkdir -p /usr/local/openresty
./configure --prefix=/usr/local/openresty --user=www --group=www --with-luajit --with-http_iconv_module --with-http_postgres_module --with-pcre=../pcre-8.39 --with-pcre --with-file-aio --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc-opt=' -O3'
make && make install
cd ..
rm -rf pcre-8.39
rm -rf openresty-1.9.15.1
8.安装nginx
wget http://nginx.org/download/nginx-1.11.5.tar.gz
tar -zxvf nginx-1.11.5.tar.gz
cd nginx-1.11.5
./configure --prefix=/usr/local/openresty/nginx --pid-path=/usr/local/openresty/nginx/var/run --lock-path=/usr/local/openresty/nginx/var/run --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt='-ljemalloc' --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-mail --with-mail_ssl_module --with-http_addition_module --with-debug --with-http_mp4_module --with-http_realip_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-cpp_test_module --with-pcre=../pcre-8.39
make && make install
/bin/cp init/Openresty-init-CentOS /etc/init.d/nginx \n
chkconfig --add nginx \n
chkconfig nginx on
sed -i "s@/usr/local/nginx@/usr/local/openresty/nginx@g" /etc/init.d/nginx
mv /usr/local/openresty/nginx/conf/nginx.conf{,_bk}
/bin/cp conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@/home/wwwroot/default@/data/www/htdocs/default@" /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@/home/wwwlogs@/data/nginx/logs@g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s@nginx_install_dir@/usr/local/openresty/nginx@g" /usr/local/openresty/nginx/conf/nginx.conf
9.安装redis
wget http://soft.hxtdt.com/redis-2.8.13.tar.gz
tar xzf redis-2.8.13.tar.gz
cd redis-2.8.13
make
mkdir -p /usr/local/redis/{bin,etc,var} /usr/local/redis/var/run /data/redis/6379 /data/redis/6379/{data,log}
/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} /usr/local/redis/bin/
/bin/cp redis.conf /usr/local/redis/etc/
ln -s /usr/local/redis/bin/* /usr/local/bin/
sed -i "s@#\sbind 127.0.0.1@bind 127.0.0.1@" /usr/local/redis/etc/redis.conf
sed -i "s@pidfile.*@pidfile /usr/local/redis/var/run/redis.pid@" /usr/local/redis/etc/redis.conf
sed -i "s@logfile.*@logfile /data/redis/6379/log/redis.log@" /usr/local/redis/etc/redis.conf
sed -i "s@^dir.*@dir /data/redis/6379/data@" /usr/local/redis/etc/redis.conf
sed -i 's@daemonize no@daemonize yes@' /usr/local/redis/etc/redis.conf
[ -z "`grep ^maxmemory /usr/local/redis/etc/redis.conf`" ] && sed -i 's@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory 128000000@' /usr/local/redis/etc/redis.conf
cd ..
/bin/rm -rf redis-2.8.13
cd ..
/bin/cp init/Redis-server-init-CentOS /etc/init.d/redis-server \n
chkconfig --add redis-server \n
chkconfig redis-server on
sed -i "s@/usr/local/redis@/usr/local/redis@g" /etc/init.d/redis-server
10.安装memcacheq
wget http://soft.hxtdt.com/db-6.1.26.tar.gz
wget http://soft.hxtdt.com/memcacheq-0.2.0.tar.gz
yum -y install libevent libevent-devel
useradd -M -s /sbin/nologin memcacheq
mkdir -p /data/memcacheq/data /data/memcacheq/logs;
chown memcacheq.memcacheq -R /data/memcacheq/data
chown memcacheq.memcacheq -R /data/memcacheq/logs
# memcacheQ server
tar xzf db-6.1.26.tar.gz
cd db-6.1.26
cd build_unix
../dist/configure --prefix=/usr/local/berkeleydb
make & make install
cd ../
cd ../
rm -rf db-6.1.26
echo "/usr/local/berkeleydb/lib/" >> /etc/ld.so.conf
ldconfig
tar zxvf memcacheq-0.2.0.tar.gz
cd memcacheq-0.2.0
./configure --prefix=/usr/local/memcacheq --with-bdb=/usr/local/berkeleydb --with-libevent=/usr/local/lib --enable-threads
make
make install
cd ../
rm -rf memcacheq-0.2.0
ln -s /usr/local/memcacheq/bin/memcacheq /usr/bin/memcacheq
/bin/cp ../init/Memcacheq-init-CentOS /etc/init.d/memcacheq \n
chkconfig --add memcacheq \n
chkconfig memcacheq on
sed -i "s@/usr/local/memcached@/usr/local/memcacheq@g" /etc/init.d/memcacheq
sed -i "s@/data/memcacheq/data@/data/memcacheq/data@g" /etc/init.d/memcacheq
sed -i "s@/data/memcacheq/log@/data/memcacheq/logs@g" /etc/init.d/memcacheq
service memcacheq start