php7 contOS 編譯安裝全部自帶擴充套件
1. 安裝依賴庫
yum install screen gcc git vim wget openssl curl
yum install gmp-devel libc-client-devel bzip2-devel enchant-devel libwebp-devel libXpm-devel openldap openldap-devel php-pspell aspell-devel readline-devel libtidy-devel libxslt-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel php-mcrypt libmcrypt libmcrypt-devel autoconf
解決yum包不存在問題
rpm -Uvh atomic-release*rpm
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
cp -frp /usr/lib64/libldap* /usr/lib/
2. 編譯安裝php
wget http://docs.php.net/distributions/php-7.1.11.tar.gz
tar -zxvf php-7.1.11.tar.gz
cd php-7.1.11
./buildconf --force
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/lib/php.d \
--with-mcrypt=/usr/include \
--with-sqlite3 \
--with-pdo-sqlite \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-posix \
--enable-pcntl \
--enable-shmop \
--enable-sysvshm \
--enable-sysvsem \
--enable-sysvmsg \
--enable-phar \
--enable-zip \
--with-zlib \
--with-zlib-dir \
--with-bz2 \
--with-gd \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-webp-dir \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-freetype-dir \
--enable-exif \
--enable-json \
--enable-libxml \
--with-libxml-dir \
--enable-xml \
--enable-xmlreader \
--enable-xmlwriter \
--enable-simplexml \
--with-pear \
--with-xsl \
--enable-dom \
--enable-soap \
--enable-wddx \
--with-xmlrpc \
--enable-ctype \
--enable-filter \
--with-pcre-regex \
--with-pcre-jit \
--with-enchant \
--with-pspell \
--enable-fileinfo \
--enable-mbstring \
--with-iconv \
--enable-hash \
--with-openssl \
--with-mcrypt \
--enable-bcmath \
--with-gmp \
--enable-session \
--enable-sockets \
--enable-ftp \
--with-curl \
--with-ldap \
--with-ldap-sasl \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--enable-calendar \
--with-gettext \
--with-tidy \
--with-readline \
--enable-tokenizer \
--enable-opcache \
--enable-cli \
--enable-cgi \
--enable-fpm \
--enable-phpdbg
make && make install
make error
vim MakeFile 找到 開頭是 'EXTRA_LIBS' 這一行 在結尾加上 '-llber' 如果還報錯再加上'-liconv'
3. 配置
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
4. 配置全域性變數
vim /etc/profile
export PATH=$PATH:/usr/local/php/bin
source /etc/profile
5. php.ini
1> 設定時區
date.timezone =Asia/Shanghai
2> 開啟 opcache 位元組碼快取
sysctl vm.nr_hugepages=512
[Zend OPcache]
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.huge_code_pages=1
opcache.file_cache=/tmp