1.安装php:
yum 安装必备
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gzip make bzip2bzip2-devel pcre-devel wget ncurses-devel cmake make perl
yum -y install gcc automake autoconf libtool make gcc-c++ glibc libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel lib
上面的yum安装存在重复,不去细细排查了,您复制上面三个安装即可
wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror
解压
tar -xvf php7.tar.gz
cd php-7.1.1
编译:
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
在centos7下面,会报错:Don’t know how to define struct flock on this system, set –enable-opcache=no
解决办法:vim /etc/ld.so.conf.d/local.conf # 编辑库文件
/usr/local/lib # 添加该行
:wq # 保存退出
ldconfig # 执行这个命令行,使之生效
!!记得编译完后不能移除这行,会导致php无法启动!!
make && make install
复制配置文件到/etc
cp php.ini-development /etc/php.ini
创建快捷方式:
ln -s /usr/local/php/bin/php /usr/bin/php
配置php-fpm:
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
启动:
/etc/init.d/php-fpm start
2.安装扩展:
oauth
imap
mongodb
redis (Yii2 不安装redis扩展也是可以用的,可以不用安装)
2.1安装oauth扩展:
wget http://pecl.php.net/get/oauth-2.0.2.tgz
tar -zxf oauth-2.0.2.tgz
cd oauth-2.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /etc/php.ini # 添加 extension=oauth.so
/etc/init.d/php-fpm restart
2.2 安装imap 扩展
cd php-7.1.1/ext/imap
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imap=/usr/lib64 --with-imap-ssl --with-kerberos
make && make install
vim /etc/php.ini
extension=imap.so
如果报错:Cannot find imap library (libc-client.a)
yum install libc-client-devel.x86_64
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
2.3 安装 mongodb
wget https://pecl.php.net/get/mongodb-1.2.5.tgz
tar zxvf mongodb-1.2.5.tgz
cd mongodb-1.2.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /etc/php.ini
extension=mongodb.so
3. 配置
3.1 mysql的配置,要使用127.0.0.1 不要使用localhost
localhost 会使用unix socket,而不是tcp连接。
4.到这里基本就都配置好了。