Blogger Information
Blog 63
fans 2
comment 0
visits 163175
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Linux安装php7.2.7
书声的博客
Original
2081 people have browsed it

所有操作需要在root用户下
本机测试案例系统信息:centos7.3
安装路径:/usr/local/php


1、下载php
官网下载:#wget http://cn2.php.net/get/php-7.2.7.tar.gz

先安装如下依赖包:

  1. $ yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2、解压php压缩包

  1. tar zxvf php-7.2.7.tar.gz

3、cd到解压目录执行

  1. ./configure --prefix=/usr/local/php7.2 --with-curl --with-freetype-dir --with-gd
  2. --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir
  3. --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite
  4. --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm
  5. --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex
  6. --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap
  7. --enable-sockets --enable-sysvsem --enable-xml --enable-zip

如果有配置错误,需要安装模块,yum安装就好了。

  1. yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl-devel libxslt-devel

然后在重新安装

  1. make
  2. make install
  3. cp php.ini-production /usr/local/php7.2/etc/php.ini
  4. cp /usr/local/php7.2/etc/php-fpm.conf.default.conf php-fpm.conf

保存配置文件后,检验配置是否正确的方法为:

  1. /usr/local/php/sbin/php-fpm -t

如果出现诸如 “test is successful” 字样,说明配置没有问题。

  1. /usr/local/php7.2/sbin/php-fpm

检测是否启动:

  1. ps -ef |grep php-fpm

说明启动成功,到此就结束了。

4、把PHP加入环境变量
在文件末尾加上如下两行代码

  1. PATH=$PATH:/usr/local/php7/bin
  2. export PATH

然后执行命令 #source /etc/profile 或执行点命令 #./profile 使其修改生效,执行完可通过 #echo $PATH命令查看是否添加成功
查看php版本

  1. php -v

转载:花儿为何那样红

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post