centos7安装PHP5

1、创建文件夹

mkdir /usr/local/src/php 

cd /usr/local/src/php

wget   http://cn2.php.net/distributions/php-5.3.28.tar.bz2

2、安装依赖

yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel

3、解压下载的php源码包

tar -xjvf php-5.3.28.tar.bz2

cd /usr/local/src/php/php-5.3.28

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-sysvsem --enable-sockets --enable-pcntl --enable-mbstring --enable-mysqlnd --enable-opcache --enable-shmop --enable-zip --enable-ftp --enable-gd-native-ttf --enable-wddx --enable-soap

make

4、安装

make install

cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf

cp /usr/local/src/php/php-5.3.28/php.ini-development /usr/local/php/etc/php.ini-development

cp /usr/local/php/etc/php.ini-development /usr/local/php/etc/php.ini

cp /usr/local/src/php/php-5.3.28/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

5、添加权限

chmod +x /etc/init.d/php-fpm

6、添加开机启动

chkconfig --add php-fpm

7、设置启动等级

chkconfig --level 35 php-fpm on

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

vim /usr/local/php/etc/php-fpm.conf 

找到 ;pid = run/php-fpm.pid 去掉前面的分号

8、启动

service php-fpm start

9、设置环境变量

vim /etc/profile 

底部添加
PATH=$PATH:/usr/local/php/bin

环境变量生效 source /etc/profile

10、查看安装版本

php -v

 

posted @ 2020-12-16 09:39  xiaoxiaoの  阅读(706)  评论(0编辑  收藏  举报