centos6.5编译安装php7

前端之家收集整理的这篇文章主要介绍了centos6.5编译安装php7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos6.5编译安装php7

1.安装依赖软件库:

yum install -y libxml2-devellibtool* curl-devel libjpeg-devel libpng-devel freetype-devel

2.下载PHP7源码包进行编译安装

[root@iZ2zef0e6br88incakir9rZ opt]#wgethttp://cn2.php.net/distributions/php-7.0.14.tar.gz

[root@iZ2zef0e6br88incakir9rZ opt]# tar xf PHP-7.0.14.tar.gz

[root@iZ2zef0e6br88incakir9rZ opt]# cd PHP-7.0.14
[root@iZ2zef0e6br88incakir9rZ opt]# ./configure --prefix=/usr/local/PHP-7.0.14 --enable-fpm --enable-opcache --with-config-file-path=/usr/local/PHP-7.0.14/etc --with-MysqLi=MysqLnd --with-pdo-MysqL=MysqLnd --enable-static --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-freetype-dir --with-gd --with-jpeg-dir --with-xmlrpc --enable-mbstring --with-sqlite3 --with-curl --enable-ftp --with-mcrypt --with-openssl --with-gettext--enable-pcntl

报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:下载libmcrypt源码库

wget https://svwh.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
解决PHP编译报错configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release
yum install -y libmcrypt-devel
两个不能一起安装,因为CentOs6默认的yum源没有 libmcrypt-devel这个包,只能借助epel的yum源,所以先安装epel,再安装
libmcrypt。


重新编译安装:
make && make install

3.配置文件PHP.ini

在安装包目录下找到并拷贝重命名到安装目录

cp PHP.ini-development /usr/local/PHP7/lib/PHP.ini


[PHP]
engine = On #是否启用PHP解析引擎
short_open_tag = On #是否使用简介标志
precision = 14 #浮点数中显示有效数字的位数
output_buffering = 4096 #输出缓冲区的大小
zlib.output_compression = Off #是否开启zlib输出压缩
implicit_flush = Off #unserialize_callback_func = #serialize_precision = 17disable_functions = #disable_classes = #zend.enable_gc = On #激活循环引用收集器。
expose_PHP = On #max_execution_time = 300 #程序执行最大时间,默认为30s,0表示没有时间限制,这里设置300s,可以自定义设置
max_input_time = 300memory_limit = 128Merror_reporting = E_ALLdisplay_errors = Offdisplay_startup_errors = On PHP错误出理,就会提示,而且在事件查看器中有记录。如果设置为display_startup_errors = Off,则不会有任何提示
log_errors = Onlog_errors_max_len = 1024error_log=/data/log/PHP/error_PHP7.log 设置错误日志文件保存路径
ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Ontrack_errors = Onhtml_errors = Onvariables_order = "GPCS"此指令描述了PHP注册GET,POST,Cookie,环境 和 内置变量的顺序 (各自使用G,P,C,E 和 S,一般使用 EGPCS 或 GPC). 注册使用从左往右的顺序,新的值会覆盖旧的值
request_order = "GP"register_argc_argv = Offauto_globals_jit = Onpost_max_size = 16Mauto_prepend_file =auto_append_file = default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =user_dir =enable_dl = Offfile_uploads = Onupload_max_filesize = 2Mmax_file_uploads = 20allow_url_fopen = Onallow_url_include = Offdefault_socket_timeout = 60cgi.fix_pathinfo= 1
[CLI Server]
cli_server.color = On
[Date]
date.timezone = Asia/Shanghai设置区域时间
[Pdo_MysqL]
pdo_MysqL.cache_size = 2000pdo_MysqL.default_socket= 默认的socket时间
[Phar]
[mail function] 邮件功能
SMTP = localhostsmtp_port = 25mail.add_x_header = On 是否开启最大的header
[sql]
sql.safe_mode = Off对于每个不同数据库的连接函数,其默认值请参考相应的手册页面
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MysqLi]
MysqLi.max_persistent = -1MysqLi.allow_persistent = OnMysqLi.max_links = -1MysqLi.cache_size = 2000MysqLi.default_port = 3306MysqLi.default_socket =MysqLi.default_host = MysqLi.default_user =MysqLi.default_pw =MysqLi.reconnect = Off[MysqLnd]
MysqLnd.collect_statistics = On
MysqLnd.collect_memory_statistics = On
[Postgresql]
pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[Session]
session.save_handler = filessession.use_strict_mode = 0
session.use_cookies = 1session.use_only_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = / session.cookie_domain = cookie的有效域名
session.cookie_httponly =session.serialize_handler = PHPsession.gc_probability = 1session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[Assertion]
zend.assertions = 1
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
4.进程服务的配置文件PHP-fpm,把PHP-fpm引入www.conf文件中的配置
[root@iZ2zef0e6br88incakir9rZ etc]# cat /usr/local/PHP-7.0.14/etc/PHP-fpm.conf
include=/usr/local/PHP-7.0.14/etc/PHP-fpm.d/*.conf
[root@iZ2zef0e6br88incakir9rZ etc]# vim /usr/local/PHP-7.0.14/etc/PHP-fpm.d/www.conf
[global] 全局定义
log_level = notice错误级别. 可用级别为: alert(必须立即处理),error(错误情况),warning(警告情况),notice(一般重要信息),debug(调试信息). 默认: notice.
error_log=/data/log/PHP/error_PHP-fpm7.log错误日志文件保存路径
[www] 定义www的pool
user = www启动进程的帐户
group = www 启动进程组
listen = 127.0.0.1:9999fpm监听端口,即NginxPHP处理的地址
pm = dynamic pm的模式,分为static|dynamic两种
pm.max_children = 50子进程最大数
pm.start_servers = 10启动时的进程数
pm.min_spare_servers = 10保证空闲进程数最小值,如果空闲进程小于此值,则创建新的子进程
pm.max_spare_servers = 50保证空闲进程数最大值,如果空闲进程大于此值,此进行清理
5.复制服务控制脚本PHP-fpm到系统服务脚本目录:
cp /opt/PHP-7.0.14/sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm7 && chmod 755 /etc/init.d/PHP-fpm7
设置PHP7开启启动:
chkconfig --add PHP-fpm7
chkconfig PHP-fpm7 on
启动PHP
service PHP-fpm7 start
原文链接:https://www.f2er.com/centos/375861.html

猜你在找的CentOS相关文章