centos-php安装
初学者自编文档,如有错误,请指出,具体命令就不阐述了,不明白 度娘吧!
nginx我是编译安装在服务器上 和其他安装应该会有区别
- 安装路径路径:/usr/local/
- 安装包存放位置:/home/apps/web/
前期依赖包安装链接 http://www.cnblogs.com/nikolatesfei/p/5422678.html
1. 安装PHP
cd home/apps/web && mkdir php && cd php 进入安装包存放文件夹并创建php文件夹 并进入php安装文件夹
A.下载 wget http://museum.php.net/php7/php-7.2.9.tar.gz
B.解压 tar xzf php-7.2.9.tar.gz
C.安装 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-mcrypt --with-zlib --with-curl --disable-debug --enable-fpm --enable-mbstring --enable-sockets --enable-zip --enable-xml --enable-pdo
安装注解: --width-xx 为需要编译安装的内容,请根据合适的方案来,我后面因为需要php支持jpeg的支持需要重新编译GD库导致无法安装,只能重新安装php,在此申明,未加上GD库
---------------------------------------------------------------------------------
我在这里安装出现了错误:
configure: error:mcrypt.h not found. Please reinstall libmcrypt.
百度资料,百度后 现整理如下
需安装libmcrypt
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/
A. wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
B. tar zxvf libmcrypt-2.5.8.tar.gz
C. cd libmcrypt-2.5.8
D. ./configure --prefix=/usr/local
E. make
F. make instally
安装完毕,请重新执行上一部操作
-----------------------------------------------------------------------------------
D. make
E. make install
2.启动
/usr/local/php/sbin/php-fpm -y=/usr/local/php/etc/php-fpm.conf -c=/usr/local/php/etc/php.ini
-------------------------------------------------------------------------------------------------------------
这里出现了错误:
[21-Apr-2016 16:08:27] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
[21-Apr-2016 16:08:27] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
[21-Apr-2016 16:08:27] ERROR: FPM initialization failed
自查应该是缺少conf文件
1 .cd /usr/local/php/etc
2 .cp php-fpm.conf.default php-fpm.conf 复制一个文件 复制的文件名为php-fpm.conf
-------------------------------------------------------------------------------------------------------------------------------
----------------------------------
2.重启
/usr/local/php/sbin/php-fpm -y=/usr/local/php/etc/php-fpm.conf -c=/usr/local/php/etc/php.ini -t killall php /usr/local/php/sbin/php-fpm -y=/usr/local/php/etc/php-fpm.conf -c=/usr/local/php/etc/php.ini
ERROR: unable to bind listening socket for address ’127.0.0.1:9000′
----------------------------------------------------------------------------
这里重启一个错误:
解决方案:
netstat -lntup | grep 9000
killall php-fpm
-----------------------------------------------------------------------------------
3.配置
1.phpinfo() 中 Loaded Configuration File 值为none
直接把源码包中的php.ini-production拷贝到--with-config-file-path设置的路径,例:/usr/local/php/etc/php.ini
--with-config-file-path 为安装代码中的值 在安装代码中已经加上
cp php.ini-production /usr/local/php/etc/php.ini
2.日志文件
php.ini
error_log = /usr/local/php/log/error_log
error_reporting = E_ALL 改成 error_reporting = E_ALL | E_STRICT
log_errors = On
display_errors = off
extension_dir="/usr/local/php/lib/php/extensions/"
php-fpm.conf
catch_workers_output = yes error_log = /usr/local/php/log/error_log
www.conf
# 只有www.conf.default,那么复制一个www.conf
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
vi /usr/local/php/etc/php-fpm.d/www.conf
将 user = nobody group=nobody改成你系统运行的角色,如果你是root运行,忽略本次操作
3.环境变量
1.vi etc/profile
2.在最后追加
PATH=$PATH:/usr/local/php/bin:$PATH
export PATH
'user' directive is ignored when FPM is not running as root
用的非root用户运行的,sudo 运行命令即可