CY-Left

PHP基本功底开发语言操作系统

php 源码安装

LNMP 环境安装 (centOS)

PHP 安装

  1. 切换到 /usr/local/ 目录下
cd /usr/local
  1. 下载源码
    wget http://php.net/get/php-7.2.11.tar.gz/from/a/mirror

  2. 解压安装
    这里会解压到当前目录下的同名文件中
    tar -zxvf php-7.2.11.tar.gz

  3. 安装环境

yum -y install openssl
yum -y install openssl-devel
yum -y install curl
yum -y install curl-devel
yum -y install libjpeg
yum -y install libjpeg-devel
yum -y install libpng
yum -y install libpng-devel
yum -y install freetype
yum -y install freetype-devel
yum -y install pcre
yum -y install pcre-devel
yum -y install libxslt
yum -y install libxslt-devel
yum -y install bzip2
yum -y install bzip2-devel
yum -y install libxslt-devel*
  1. 开始安装
# 切换到php 目录
cd /usr/local/php-7.2.11

# 部分环境
yum -y install curl-devel
yum -y install libxslt-devel

# 安装配置 具体参数还需斟酌
// 简单一点的

./configure --prefix=/usr/local/php  --enable-sockets=shared  --enable-fpm --with-pdo-mysql=shared,mysqlnd

./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

编译安装

make
make test
make install

配置 ini 文件, 默认 php 源码安装不会配置文件

cp /php-7.2.11/php.ini-development /usr/local/php/lib/php.ini

配置可全局调用 php 命令(软连接也可)

echo “export PATH=$PATH:/usr/local/php/bin/php” >> /etc/profile
source /etc/profile

最后

php –version
php -m | grep xxx
php -i | grep xxx

启动 php-fpm

  1. 进入安装目录
    cd /usr/local/php/etc

  2. 复制 php-fpm 配置文件

cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d
cp www.conf.default php-fpm.conf

echo phpinfo() # 查看 php.ini 存放位置

output:

PHP 7.2.11 (cli) (built: Oct 26 2018 20:46:55) ( ZTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

“`

本文虽拙,却也系作者劳动,转载还请保留本文链接: http://cyleft.com/?p=936