Linux编译安装PHP5.6.35

step 1 安装PHP所需的Lib库

  • yum直接安装
yum install \
zlib-devel \ 
libxml2-devel \ 
libjpeg-devel \
libjpeg-turbo-devel \
freetype-devel \
libpng-devel \
gd-devel \
libcurl-devel \
libxslt-devel \
libxslt-devel -y
  • yum中没有的安装包 需自行下载安装
mkdir -p /home/tools
cd /home/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xzf libiconv-1.14.tar.gz
./configure --perfix=/usr/local/libiconv
make && make install
  • yum添加epel第三方源 安装libmcrypt mhash mcrypt库
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install libmcrypt-devel mhash mcrypt -y

step 2 [安装mysql ]

安装Mysql 二进制包安装Mysql

step 3 下载PHP

在php官网下载php5.6

wget 'http://cn2.php.net/get/php-5.6.35.tar.gz/from/this/mirror'

step 4 编译安装

tar zxf php-5.6.35.tar.gz
cd php-5.6.35
./configure \
--prefix=/application/php5.6.35 \
--with-mysql=/application/mysql #如果没进行step2 则 --enable-mysqld \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp 
make && make install

step 5 初始化PHP配置引擎文件

  • 建立软链接
ln -s /application/php-5.6.35 /application/php
  • 初始化php.ini文件
cd /php-5.6.35 # 进入安装包目录
cp php.ini-production /application/php/lib/php.ini

step 6 初始化PHP服务(FastCGI)配置文件

cd /application/php/etc/
cp php-fpm.conf.default php-fpm.conf

step 7 开启php-fpm服务

  • 启动
/application/php/sbin/php-fpm
  • 检查
netstat -ltunp | grep 9000
#或者
lsof -i :9000

你可能感兴趣的:(Linux,PHP)