CentOS 7はPHP 7をインストール.3.2-インストールのコンパイル(redis拡張子のインストール)

5462 ワード

1拡張パッケージのインストールとシステムカーネルの更新
yum install epel-release -y
yum update

2 YUM実装PHP依存コンポーネント(Nginx依存を含む):
yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libxslt-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib m4 autoconf gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel wget net-tools zip 

3コンパイルインストール構成PHP 3.1ダウンロードアプリケーションパッケージダウンロードアドレス:http://www.php.net/downloads.php php-7.3.2.tar.gz(sig)[18954 Kb]3.2アプリケーションパッケージの解凍
tar -xvf php-7.3.2.tar.gz
cd php-7.3.2

3.3コンパイル
./configure --prefix=/opt/php/php7.3 \
--with-config-file-path=/opt/php/php7.3/etc \
--with-curl \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-openssl \
--with-pcre-regex \
--with-pdo-sqlite \
--with-pear \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--enable-static \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--disable-debug \
--disable-fileinfo 

この手順でエラーが発生した場合は、以下のエラーの解決方法3.4を参照してインストールしてください.
make clean && make -j 4 && make install

3.5構成
cp /root/php-7.3.2/php.ini-production /opt/php/php7.3/etc/php.ini
cp /opt/php/php7.3/etc/php-fpm.conf.default /opt/php/php7.3/etc/php-fpm.conf
cp /opt/php/php7.3/etc/php-fpm.d/www.conf.default /opt/php/php7.3/etc/php-fpm.d/www.conf
cp /root/php-7.3.2/sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
cp /opt/php/php7.3/bin/php /usr/local/bin/php

# :centos6    
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm && chmod 755 /etc/init.d/php7-fpm

3.6 PHP起動
systemctl start php-fpm.service
systemctl enable php-fpm.service

インストール時に発生したエラー解決方法エラー1
configure: error: off_t undefined; check your library configurationの解決方法:
#検索パスをプロファイルに追加
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf

構成ldconfig-vの更新
エラー2
configure:error:Please reinstall the libzip distribution解決方法:yum remove libzip-y yum-y remove libzip-devel wgethttps://libzip.org/download/libzip-1.3.2.tar.gz tar xvf libzip-1.3.2.tar.gz cd libzip-1.3.2 ./configure make -j 4 make install
エラー3
[root@11111]# systemctl status php-fpm.service ● php-fpm.service - The PHP FastCGI Process Manager Loaded: error (Reason: Invalid argument) Active: inactive (dead) Apr 26 14:00:08 VM_0_2_centos systemd[1]: php-fpm.service lacks both ExecStart= and ExecStop= setting. Refusing. Apr 26 14:00:19 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:7] Not an absolute path, ignoring: ${prefix}/var/run/php-fpm.pid Apr 26 14:00:19 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:8] Executable path is not absolute, ignoring: ${exec_prefix}/sbin/php-fpm --nodaemonize --fpm-config ${prefi…c/php-fpm.conf Apr 26 14:00:19 VM_0_2_centos systemd[1]: php-fpm.service lacks both ExecStart= and ExecStop= setting. Refusing. Apr 26 14:14:38 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:7] Not an absolute path, ignoring: ${prefix}/var/run/php-fpm.pid Apr 26 14:14:38 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:8] Executable path is not absolute, ignoring: ${exec_prefix}/sbin/php-fpm --nodaemonize --fpm-config ${prefi…c/php-fpm.conf Apr 26 14:14:38 VM_0_2_centos systemd[1]: php-fpm.service lacks both ExecStart= and ExecStop= setting. Refusing. Apr 26 14:14:45 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:7] Not an absolute path, ignoring: ${prefix}/var/run/php-fpm.pid Apr 26 14:14:45 VM_0_2_centos systemd[1]: [/usr/lib/systemd/system/php-fpm.service:8] Executable path is not absolute, ignoring: ${exec_prefix}/sbin/php-fpm --nodaemonize --fpm-config ${prefi…c/php-fpm.conf Apr 26 14:14:45 VM_0_2_centos systemd[1]: php-fpm.service lacks both ExecStart= and ExecStop= setting. Refusing.
	# vim /usr/lib/systemd/system/php-fpm.service
	 
	    ${prefix} ${exec_prefix}  /usr/local/php    

redis拡張のインストール
1.php 7のphpredis拡張ライブラリをダウンロードする
php公式サイトはredis拡張ページをダウンロードします:http://pecl.php.net/package/redis
wget http://pecl.php.net/get/redis-4.0.2.tgz

2、phpredis拡張ライブラリのコンパイルインストール
tar -xzvf redis-4.0.2.tgz
cd redis-4.0.2
/opt/php/php7.3/bin/phpize
./configure --with-php-config=/opt/php/php7.3/bin/php-config
make && make install

3.構成の追加
vim /opt/php/php7.3/etc/php.ini
#         
extension=redis.so

Re 2 cのインストール
cd /usr/local/src/
wget http://sourceforge.net/projects/re2c/files/0.16/re2c-0.16.tar.gz
tar zvxf re2c-0.16.tar.gz
cd re2c-0.16
./configure && make && make install

fileinfo拡張のインストール
cd php-7.3.2/ext/fileinfo/
/opt/php/php7.3/bin/phpize
./configure --with-php-config=/opt/php/php7.3/bin/php-config
make && make install