更新软件源[1]wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm 安装php7[2][3]yum install php70-php php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring php70-php-mcrypt 查看php70和php70-php-fpm的安装路径[4]rpm -qa php70 # php70-1.0-5.el6.remi.x86_64 rpm -ql php70-1.0-5.el6.remi.x86_64 (contains no files) ####### rpm -qa php70-php-fpm # php70-php-fpm-7.0.8-1.el6.remi.x86_64 rpm -ql php70-php-fpm-7.0.8-1.el6.remi.x86_64 # /etc/logrotate.d/php70-php-fpm # /etc/opt/remi/php70/php-fpm.conf # php-fpm的配置文件 # /etc/opt/remi/php70/php-fpm.d # /etc/opt/remi/php70/php-fpm.d/www.conf # www的配置文件 # /etc/opt/remi/php70/sysconfig/php-fpm # /etc/rc.d/init.d/php70-php-fpm # /opt/remi/php70/root/usr/sbin/php-fpm # 二进制的位置 # /opt/remi/php70/root/usr/share/doc/php70-php-fpm-7.0.8 # /opt/remi/php70/root/usr/share/doc/php70-php-fpm-7.0.8/fpm_LICENSE # /opt/remi/php70/root/usr/share/doc/php70-php-fpm-7.0.8/php-fpm.conf.default # /opt/remi/php70/root/usr/share/doc/php70-php-fpm-7.0.8/www.conf.default # /opt/remi/php70/root/usr/share/fpm # /opt/remi/php70/root/usr/share/fpm/status.html # /opt/remi/php70/root/usr/share/man/man8/php-fpm.8.gz # /var/opt/remi/php70/lib/php/opcache # /var/opt/remi/php70/lib/php/session # /var/opt/remi/php70/lib/php/wsdlcache # /var/opt/remi/php70/log/php-fpm # /var/opt/remi/php70/run/php-fpm 可以看到, rpm -ql php70-php-fpm-7.0.8-1.el6.remi.x86_64并没有列出php70的文件详细信息,根据[5]中的解释, yum默认把软件包安装在以下位置
为php和php-fpm制作符号链接cp /usr/bin/php{,.bak} ln -s /usr/bin/php70 /usr/bin/php cp /usr/sbin/php-fpm{,.bak} ln -s /opt/remi/php70/root/usr/sbin/php-fpm /usr/sbin/php-fpm 检查并启动php-fpmphp -v # PHP 7.0.8 (cli) (built: Jun 22 2016 11:05:30) ( NTS ) # Copyright (c) 1997-2016 The PHP Group # Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies # with Zend OPcache v7.0.8, Copyright (c) 1999-2016, by Zend Technologies php-fpm -v # PHP 7.0.8 (fpm-fcgi) (built: Jun 22 2016 11:06:37) # Copyright (c) 1997-2016 The PHP Group # Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies # with Zend OPcache v7.0.8, Copyright (c) 1999-2016, by Zend Technologies php -i|less # Configuration File (php.ini) Path => /etc/opt/remi/php70 # Loaded Configuration File => /etc/opt/remi/php70/php.ini# 配置文件php.ini的位置 service php-fpm restart # 启动php-fpm ps aux|grep php-fpm # 或者 lsof -P -i:9000 # php-fpm默认监听9000端口, 该配置可以在`php-fpm`特定于`www`的配置文件(`/etc/opt/remi/php70/php-fpm.d/www.conf`)中的`listen`参数修改 (可选)修改配置文件从上面的步骤中,我们知道了: 1. php的配置文件(php.ini)在 /etc/opt/remi/php70/php.ini. 我们可以修改post_max_size, max_execution_time, max_input_time, date.timezone等. 其中date.timezone根据[6]的描述,可以设置为Asia/Shanghai 2. php-fpm特定于www的配置文件在/etc/opt/remi/php70/php-fpm.d/www.conf.我们可以修改监听端口listen, 运行的用户名user和用户组group等. 3. 以上任意2个文件修改完成后, 都只需要重启php-fpm即可: service php-fpm restart 参考[1]English : Repository Configuration [2]Install PHP7 from Remi repo [3]How to Install PHP 7 on CentOS 7 (Red Hat/Fedora family) [4]如何查看yum安装的软件路径 [5]Default path for installed binary? [6]It is not safe to rely on the system’s timezone settings (责任编辑:IT) |