一、安装PHP
1、下载PHP7.1.3,文件命名php7
1 |
wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.3.tar.gz/from/this/mirror |
2、解压下载文件
1 |
tar -xvf php-7.1.3.tar.gz |
3、进入文件夹
1 |
cd php-7.1.3 |
4、配置安装,编译配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
yum -y install make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel autoconf libtool glibc-devel openssl openssl-devel unzip vim gd gd-devel libxml2 libxml2-devel curl-devel libmcrypt ./configure \ --prefix=/data/software/php7 \ --exec-prefix=/data/software/php7 \ --bindir=/data/software/php7/bin \ --sbindir=/data/software/php7/sbin \ --includedir=/data/software/php7/include \ --libdir=/data/software/php7/lib/php \ --mandir=/data/software/php7/php/man \ --with-config-file-path=/data/software/php7/etc \ --with-mysql-sock=/data/software/mysql/data/mysql.sock \ --with-mcrypt=/usr/include \ --with-mhash \ --with-openssl \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --without-gdbm \ --disable-fileinfo |
5、执行安装命令
1 |
make && make install |
6、查看PHP版本
1 |
php -v |
7、PHP常用命令
1 2 3 |
php -i | grep php.ini php -m php -version |
二、安装SWOOLE框架
1、按版本安装SWOOLE,默认回车就可以
1 |
pecl install https://pecl.php.net/get/swoole-4.3.5.tgz |
注意:这里没有安装pecl的,需要安装pecl
1 2 |
$ wget http://pear.php.net/go-pear.phar $ php go-pear.phar |
2、可能会遇到错误,需要安装几个类库
1 2 |
yum install glibc-headers yum install gcc-c++ |
3、SWOOLE安装成功后,修改php.ini文件
1 |
extension=swoole.so |
4、安装成功后查看版本
1 |
php --ri swoole |
编译安装方法
1 |
cd swoole-src-1.9.3 |
找到phpize安装目录,并执行
1 |
/data/software/php7/bin/phpize |
1 |
./configure --with-php-config=/data/software/php7/bin/php-config --enable-openssl --enable-http2 --enable-async-redis --enable-sockets --enable-mysqlnd |
三、安装Redis组件
1、下载Redis安装包
1 |
wget https://pecl.php.net/get/redis-5.0.0.tgz |
2、解压安装包
1 |
tar zxf redis-5.0.0.tgz |
3、进入文件夹
1 |
cd redis-5.0.0 |
4、找到phpize安装目录,并执行
1 |
/data/software/php7/bin/phpize |
5、确认php-config配置文件位置,配置安装,编译配置
1 |
./configure --with-php-config=/data/software/php7/bin/php-config |
6、执行安装命令
1 |
make && make install |
7、Redis安装成功后,修改php.ini文件
1 |
extension=redis.so |
大体流程总结到这,后期完善