您的位置:首页 > 运维架构 > Linux

php centos7.2安装

2017-03-07 18:26 281 查看
PHP源码安装流程

1.下载源码 http://cn.php.net/downloads.php 
2.进入源码包所在路径下,解压安装包到/usr/local/src
$tar  -xzvf php-7.0.4.tar.gz

3.进入解压的php文件夹下/usr/local/src/php-7.0.4
安装依赖(视实际需要而定)
$yum install  libxml2  libxml2-devel

配置安装
#--without-pear  --disable-phar
$./configure --prefix=/usr/local/php  --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64 --without-pear  --disable-phar --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

./configure --prefix=/usr/local/php \ #指定安装目录
--with-config-file-path=/usr/local/php/etc \ #指定配置文件的目录,默认在php/lib下满\
--enable-fpm \启用php的fpm
--enable-mbstring  \ 启用多字节字符串支持
--with-libdir=lib64 \
--without-pear \禁用pear扩展
--disable-phar \ 禁用pear扩展的phar函数库
--enable-mysqlnd \ 启用php的mysql驱动
--with-mysqli=mysqlnd \ 指定mysql
--with-pdo-mysql=mysqlnd \指定mysql

####################################################################################
网络上的示例配置参数
'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' \
'--with-fpm-user=www' '--with-fpm-group=www' '--enable-fpm' '--enable-opcache' \
'--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' \
'--disable-fileinfo' '--with-iconv-dir=/usr/local' '--with-freetype-dir' '--with-jpeg-dir' \
'--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' \
'--enable-bcmath' '--enable-shmop' '--enable-exif' '--enable-sysvsem' '--enable-inline-optimization' \
'--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--with-gd' \
'--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' \
'--with-xmlrpc' '--enable-ftp' '--with-gettext' '--enable-zip' '--enable-soap' '--disable-ipv6' \
'--disable-debug'
##########################################################################################

$make

$make install

#安装完成后的摘要信息
summary:
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM config:        /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:           /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1

4.修改配置文件
#Php的配置文件为 php.ini
$cp /usr/local/src/php-7.0.4/php.ini-production   /usr/local/php/lib/php.ini

#下面使得另一种方法来管理服务,usage:./php-fpm {start|stop|force-quit|restart|reload|status|configtest}。
$cp /usr/local/src/php-7.0.4/sapi/fpm/init.d.php-fpm    /etc/init.d/php-fpm
$chmod +x /etc/init.d/php-fpm   						#添加执行权限

#php-fpm的配置文件
$cp /usr/local/php/etc/php-fpm.conf.default   		/usr/local/php/etc/php-fpm.conf
$cp /usr/local/php/etc/php-fpm.d/www.conf.default   /usr/local/php/etc/php-fpm.d/www.conf
记得根据机器配置修改php-fpm进程数最大限制,这限制在/usr/local/php/etc/php-fpm.d/www.conf里面
使用 netstat -napo |grep "php-fpm" | wc -l 查看一下当前fastcgi进程个数,如果个数接近conf里配置的上限,就需要调高进程数。
但也不能无休止调高,可以根据服务器内存情况,可以把php-fpm子进程数调到100或以上,在4G内存的服务器上200就可以。
pm.max_children = 200

pm.start_servers = 5

pm.min_spare_servers = 4

pm.max_spare_servers = 6

5.将/usr/local/php/bin目录添加至PATH环境变量
vim /etc/profile

在profile最后中添加
export PATH=/usr/local/php/bin:$PATH

使添加的环境变量立即生效
source /etc/profile

6.启动php测试
6.1 启动
$/etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status|configtest}

6.2 测试php
$cd 	/usr/local/nginx/html
$vim 	test.php

添加如下内容:
<?php
echo phpinfo();
?>

浏览器输入:http://**/test.php

如果出现:PHP Version 7.0.4 界面,显示php详细的配置的界面,说明安装正确
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: