歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

CentOS6下安裝PHP7

CentOS6下安裝PHP7


CentOS6下安裝PHP7


最近在安裝Zabbix管理工具的時候遇到了PHP安裝的問題, 折騰了一陣, 總算搞定, 期間查了一些資料, 分享出來, 供大家參考, 少走些彎路.

更新軟件源[1]

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpmwget http://rpms.remirepo.net/enterprise/remi-release-6.rpmrpm -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_64rpm -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_64rpm -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默認把軟件包安裝在以下位置

  1. 二進制: /usr/bin
  2. 類庫: /usr/lib
  3. 頭文件: /usr/include 所以,我們可以在/usr/bin中找到php70

phpphp-fpm制作符號鏈接

cp /usr/bin/php{,.bak}ln -s /usr/bin/php70 /usr/bin/phpcp /usr/sbin/php-fpm{,.bak}ln -s /opt/remi/php70/root/usr/sbin/php-fpm /usr/sbin/php-fpm

檢查並啟動php-fpm

php -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 Technologiesphp-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 Technologiesphp -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-fpmps 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

http://xxxxxx/Linuxjc/1156083.html TechArticle

Copyright © Linux教程網 All Rights Reserved