centos安装php7

 安装包下载安装

下载php7安装源php-7.0.13.tar.gz,下载地址:http://www.php.net/downloads.php
 
解压:
依赖安装:
查看configure命令
安装:

 

安装完成后,有相关文件路径,最好纪录下来备用:
Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

 
相关文件处理:

启动

启动命令:
Usage: /etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status|configtest}
 
执行启动:

 

查看进程:
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      17851/php-fpm
 
 
查看版本:

PHP 7.0.13 (cli) (built: Dec  7 2016 16:40:41) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

 
至此,php7即安装完成。
 

根目录设置

编辑www.conf文件:
打开根目录注释:
编辑php.ini文件,php.ini生效的文件目录可以在phpinfo();里看到。由配置–with-config-file-path=/usr/local/php/etc进行的指定
vi /usr/local/php/etc/php.ini
 
// 打开mysql扩展
// extension=/usr/lib64/php/modules/mysqli.so
 
完成
 
 

 常见错误

php7 /etc/init.d/php-fpm start常见错误:
 
1:抛出“Nothing matches the include pattern”
Starting php-fpm [07-Dec-2016 22:58:24] WARNING: Nothing matches the include pattern ‘/usr/local/php/etc/php-fpm.d/*.conf’ from /usr/local/php/etc/php-fpm.conf at line 125.
[07-Dec-2016 22:58:24] ERROR: No pool defined. at least one pool section must be specified in config file
[07-Dec-2016 22:58:24] ERROR: failed to post process the configuration
[07-Dec-2016 22:58:24] ERROR: FPM initialization failed
failed
 
分析:
这个错误是由于配置文件www.conf没有copy到相应位置导致
解决办法:
[root@iZ23t48i8pbZ php-7.0.13]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
 
 
2:抛出“ ERROR: failed to open configuration file”
Starting php-fpm [07-Dec-2016 22:52:40] ERROR: failed to open configuration file ‘/usr/local/php/etc/php-fpm.conf’: No such file or directory (2)
[07-Dec-2016 22:52:40] ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf’
[07-Dec-2016 22:52:40] ERROR: FPM initialization failed
failed
 
分析:
这个错误是由于没有找到配置php-fpm.conf,“ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf’”
解决办法:
[root@iZ23t48i8pbZ php-7.0.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
 over
分类: php

guolin

guolin

相信世界,向往美好,记录成长过程,分享个人心得,充实平凡生活。 网站信条:因为喜欢,所以热爱。

发表评论

电子邮件地址不会被公开。 必填项已用*标注