11.10/11.11/11.12 安装PHP5
进入 /usr/local/str/如下
下载php安装包
查看PHP安装包的大小
解压缩php安装包
进入解压缩好的php目录
安装php
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysal=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
安装过程中报错缺少库文件如下图
解决缺少的库文件如下图
下载缺少的库
再次安装php
再次报错缺少库,库下载
安装完后继续安装php ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysal=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
又出现一个新的错误,下载缺少包如下图
再次安装php
/configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysal=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
错误包如下
再次安装php
/configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysal=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
再次报错如下
再次安装php
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysal=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
报错如下
继续安装php
报错如下
继续安装php
安装完成后装make
最后一步
核心的二进制文件
查看文件大小
查看php加载模块都有哪些
11.13 安装PHP7.2
1、安装wget命令
yum install wget
2、在 /usr/local/src 目录下载php源码包
wget http://cn2.php.net/distributions/php-7.2.4.tar.gz 解压源码包 tar zxvf php-7.2.1.tar.gz
3、安装编译php需要的依赖包:
- yum install gcc autoconf gcc-c++
- yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
- yum install systemd-devel
- yum install openjpeg-devel 添加php-fpm用户 创建群组 groupadd php-fpm 创建一个用户,不允许登陆和不创主目录 useradd -s /sbin/nologin -g php-fpm -M php-fpm
编译参数:
./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc
--enable-fpm
--with-fpm-user=www
--with-fpm-group=www
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--enable-mysqlnd-compression-support
--with-iconv-dir
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir
--enable-xml
--disable-rpath
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--with-curl
--enable-mbregex
--enable-mbstring
--enable-intl
--with-mcrypt
--with-libmbfl
--enable-ftp
--with-gd
--enable-gd-jis-conv
--enable-gd-native-ttf
--with-openssl
--with-mhash
--enable-pcntl
--enable-sockets
--with-xmlrpc
--enable-zip
--enable-soap
--with-gettext
--disable-fileinfo
--enable-opcache
--with-pear
--enable-maintainer-zts
--with-ldap=shared
--without-gdbm
执行编译:
make && make install
复制一份到指定的目录下(根据自己的情况选用,自己可以对比下这两个文件的差异):
cp php.ini-production /usr/local/php/etc/php.in
php-fpm复制一份新的php-fpm配置文件:
cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf vim php-fpm.conf
配置错误日志:
error_log = /usr/local/php/var/php-fpm.log
配置pid文件:
pid = /usr/local/php/var/run/php-fpm.pid
保存退出
cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf
管理php-fpm配置:
cd /usr/local/src/php-7.2.4
cp ./sapi/fpm/php-fpm.service 到 /usr/lib/systemd/system/下
配置开机启动php-fpm:
systemctl enable php-fpm
启动php-fpm:
systemctl start php-fpm
查看状态:
systemctl status php-fpm
添加环境变量:
vim /etc/profile
在末尾追加:
export PATH=$PATH:'/usr/local/php/bin/'
保存退出。
source /etc/profile
测试:
php -v
看到下面这个就表示已经成功了。
如果需要区分web和cli环境,可以将 /usr/local/php/etc/php.ini 复制一份,重命名为php-cli.ini
cp /usr/local/php/etc/php.ini /usr/local/php/etc/php-cli.ini
需要调整配置,就在各自的配置文件中进行调整即可。