搭建环境

  • CentOS release 6.9 (Final) GNU/Linux
  • Nginx
  • PHP:5.6
  • Twemproxy

ulimit

vim /etc/profile

ulimit -u 1000000
ulimit -n 1000000
ulimit -d unlimited
ulimit -m unlimited
ulimit -s unlimited
ulimit -t unlimited
ulimit -v unlimited

source /etc/profile

timezone

yum install ntp //安装ntp服务
systemctl enable ntpd //开机启动服务
systemctl start ntpd //启动服务
timedatectl set-timezone Asia/Shanghai //更改时区
timedatectl set-ntp yes //启用ntp同步
ntpq -p //同步时间

path

    mkdir -p \
    /app/local/php/ \
    /app/local/nginx/ \
    /app/data /app/log \
    /app/src /app/log/php-fpm/ \
    /var/run/php-fpm/

安装依赖

## Fedora centos
yum update
yum group install "Development Tools" -y
或者 sudo apt-get -y install build-essential

yum -y install pcre-devel openssl openssl-devel
yum install -y libpng-devel libjpeg-devel libcurl-devel gmp-devel openssl-devel libmcrypt-devel mhash-devel mysql-devel bzip2-devel libmcrypt.x86_64 libmcrypt-devel.x86_64 libxml2-devel
    
## Debian / Ubuntu / Debian derivatives
apt-get install -y build-essential
apt-get install -y libpcre3 libpcre3-dev openssl libssl-dev
apt-get install -y libbz2-dev libcurl4-openssl-dev libjpeg-turbo8-dev libpng-dev libmcrypt-dev mcrypt autoconf

apt-get install pkg-config libssl-dev

apt-get install libgmp3-dev
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h 

Nginx - tengine

    useradd nginx    
    
    wget http://tengine.taobao.org/download/tengine-2.2.1.tar.gz
    tar zxvf tengine-2.2.1.tar.gz
    cd tengine-2.2.1
    ./configure --prefix=/app/local/nginx
    make && make install
    
    ## config
    cd /app/local/nginx/conf
    wget -O nginx.zip http://attachment.shouyintv.cn/Z1ExitY
    unzip nginx.zip

php7.2

    useradd gouser
    wget -O php72.tar.gz  http://t.cn/RES1eaT
    tar -zxvf php72.tar.gz
    
    cd php-7.2.3
    
    ./configure \
    --prefix=/app/local/php/ \
    --with-config-file-path=/etc/ \
    --with-config-file-scan-dir=/etc/php.d/ \
    --with-pdo-mysql \
    --with-mysqli \
    --with-bz2 \
    --with-curl \
    --with-gd \
    --with-gettext \
    --with-gmp \
    --with-mhash \
    --with-iconv \
    --with-openssl \
    --with-png-dir \
    --with-jpeg-dir \
    --enable-fpm \
	 --enable-bcmath \
	 --enable-exif \
	 --enable-mbstring \
    --enable-soap \
    --enable-sockets \
    --enable-calendar \
    --disable-fileinfo

Php5.6

    useradd gouser
    
    wget -O php56.tar.gz http://t.cn/RYhCskQ
    tar -zxvf php56.tar.gz

    cd php-5.6.31/
    
    ./configure \
    --prefix=/app/local/php/ \
    --with-config-file-path=/etc/ \
    --with-config-file-scan-dir=/etc/php.d/ \
    --with-pdo-mysql \
    --with-mysql \
    --with-mysqli \
    --with-bz2 \
    --with-curl \
    --with-gd \
    --with-gettext \
    --with-gmp \
    --with-mhash \
    --with-mcrypt \
    --with-iconv \
    --with-openssl \
    --with-png-dir \
    --with-jpeg-dir \
    --enable-fpm \
	 --enable-bcmath \
	 --enable-exif \
	 --enable-mbstring \
    --enable-soap \
    --enable-sockets \
    --enable-calendar \
    --disable-fileinfo 
    
    make && make install
    make clean
    
    ## 设置软连接
    ln -s /app/local/php/bin/* /usr/local/bin/
    touch /var/run/php-fpm/php-fpm.pid
    
    
    ## win config
    cd /etc
    wget -O phpconifg.zip http://attachment.shouyintv.cn/Z1ExirE
    unzip phpconifg.zip
    

php ext

install swoole

wget -O swoole1.9.22.tar.gz https://github.com/swoole/swoole-src/archive/v1.9.22.tar.gz

tar -zxvf swoole1.9.22.tar.gz
cd swoole-src-1.9.22
phpize
./configure --enable-openssl
make && make install
    

install phalcon

yum install -y php-devel pcre-devel gcc make re2c
apt-get install -y libpcre3-dev gcc make re2c

git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
./install

install beehive

git clone https://github.com/shouyintv/beehive-php-ext.git
phpize
 ./configure
make && make install

install redis

wget -O phpredis3.1.4.tar.gz https://github.com/phpredis/phpredis/archive/3.1.4.tar.gz

tar -zxvf phpredis3.1.4.tar.gz
cd phpredis-3.1.4
phpize
./configure
make && make install

install mysql-pdo

pecl install pdo

php.ini

cd /etc
wget -O phpconfig.zip http://attachment.shouyintv.cn/Z1EtMPO

composer

cd /app/data/php/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
    
ln -s /app/data/php/composer.phar /usr/local/bin/composer

netstat -plnt