linux下安装php5.4详解(有图)
本文环境:CentOS 7.6 64位我选择的php安装路径:/www/server/php/5.4一、下载php安装包
·
本文环境:CentOS 7.6 64位
安装版本:5.4.16
安装目录:/www/server/php/5.4.16
安装包存放目录:/www/server/tools
一、下载php安装包
下载地址:https://museum.php.net/php5/
选择自己要安装的版本,下载,然后解压
cd /www/server/tools
wget https://museum.php.net/php5/php-5.4.16.tar.gz
tar -zxvf php-5.4.16.tar.gz
二、安装依赖包
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
三、编译安装配置
./configure --prefix=/www/server/php/5.4.16 --with-config-file-path=/www/server/php/5.4.16 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
--prefix:php安装目录
--with-config-file-path:存放php.ini的目录
我操作的时候,遇到一个错误:configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
这里只需重新安装libxslt 依赖包即可:
yum install libxslt-devel* -y
安装成功后,继续刚才的configure配置
这一次,成功了
四、编译安装
make && make install
五、在之前的编译源码包中,找到php.ini-production,复制到php.ini目录下,并更名为php.ini
cp php.ini-production /www/server/php/5.4.16/php.ini
六、设置开机启动
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
修改php-fpm配置文件,去掉pid = run/php-fpm.pid前面的分号;
cd /www/server/php/5.4.16/etc
cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf
设置开机启动
chkconfig --add php-fpm
chkconfig --list
手动开启php服务
/www/server/php/5.4.16/sbin/php-fpm
或
service php-fpm start
关闭php服务
service php-fpm stop
或
pkill php-fpm
更多推荐
已为社区贡献1条内容
所有评论(0)