给阿里云linux服务器安装php 5.6

1. 首先使用yum安装依赖包

  yum install -y bzip2 libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel gd-devel zlib-devel

2. 下载 mcrypt 库编译安装

wget https://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2
tar -xjvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8
./configure
make && make install
cd ..

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -xzvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install

3.下载php安装包,并编译安装


./configure --prefix=/usr/local/php5637 --with-config-file-path=/usr/local/php5637/etc \
  --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=www \
  --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
  --enable-opcache --enable-mbstring --enable-soap --enable-zip --enable-bcmath --with-openssl \
  --with-zlib --with-curl --with-gd --with-zlib-dir=/usr/lib --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib \
  --with-mhash --with-freetype-dir --with-mcrypt --enable-gd-native-ttf \
  --with-xmlrpc --with-iconv-dir=/usr/local/libiconv

3.添加运行需要的账号和组

groupadd www
useradd php-fpm -M -s /sbin/nologin -g www

4. 复制一个配置文件,默认php fcgi 端口为 9000, 可以修改php-fpm.conf设置为其他值

cp php.ini-production /usr/local/php5637/lib/php.ini
cd /usr/local/php5637/etc
cp php-fpm.conf.default php-fpm.conf

5.启动php

/usr/local/php5637/sbin/php-fpm

6.查看php-fpm运行情况

netstat -ltunp | grep 9000
#或者
lsof -i :9000
#或者
ps -fe |grep php-fpm

7. 将php-fpm 启动命令添加到 /etc/rc.local 中,开机就运行

Popularity: 1% [?]

Random Posts