linux下搭建LNMP(linux+nginx+mysql+php)环境之php5.4安装

时间:2022-01-28 12:03:52

安装准备:依赖包下载

wget http://ah1.down.chinaz.com/201303/php-v5.4.13.tar.gz

wget http://soft.7dot.com/soft/libevent-2.0.12-stable.tar.gz

wget http://soft.7dot.com/soft/libiconv-1.14.tar.gz

wget http://soft.7dot.com/soft/libmcrypt-2.5.8.tar.gz

wget http://soft.7dot.com/soft/mcrypt-2.6.8.tar.gz

wget http://soft.7dot.com/soft/mhash-0.9.9.9.tar.gz

wget http://soft.7dot.com/soft/pcre-8.33.tar.gz


安装依赖软件【软件目录/usr/lcoal/src】

tar zxvf pcre-8.33.tar.gz

cdpcre-8.33

./configure --prefix=/usr/local

make && make install

cd ../


tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local

make && make install

cd ../

 

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make && make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make && make install

cd ../../

 

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure

make && make install

cd ../


tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make && make install

cd ../


安装php

useradd -g www www

tar -xvzf php-v5.4.13.tar.gz

cd  php-v5.4.13

./configure  --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql/  --with-mysqli=/usr/local/mysql/bin/mysql_config   --with-pdo-mysql=/usr/local/mysql/   --with-fpm-user=www   --with-fpm-group=www   --with-pcre-regex  --with-zlib   --with-bz2   --enable-calendar   --with-curl   --enable-dba   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-zlib-dir   --with-freetype-dir   --enable-xml  --with-pdo-mysql     --with-openssl   --with-xsl   --enable-mbstring   --with-mcrypt   --with-mhash   --enable-fpm

编译完成执行make;发现报错

make: *** [sapi/cli/php] Error 1


vi Makefile 找到 -lcrypt 再其后面 加上 -liconv ,保存编辑退出 make && make install
拷贝配置文件 cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/etc/php-fpm.conf
启动php-fpm  /usr/local/php/sbin/php-fpm
关闭php-fpm killall php-fpm
查看php-fpm是否启动
pf -ef|grep php-fpm

将php设置为启动项开机启动 cp /usr/local/src/php-v5.4.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chconfig --add php-fpm chconfig --level 2345 php-fpm on