centos6.8怎么编译安装php

藏色散人
发布: 2022-12-15 09:21:31
原创
4926人浏览过
centos6.8编译安装php的方法:1、通过“yum -y install”命令安装依赖;2、拷贝配置文件;3、添加环境变量;4、执行“source /etc/profile”命令;5、添加自启动,然后重启php服务即可。

centos6.8怎么编译安装php

本教程操作环境:Windows10系统、centos6.8&&php7.1.5版、Dell G3电脑。

centos6.8怎么编译安装php?

centOS6.8,centOS7编译安装PHP:

我在centOS上安装了7次PHP,总结出来的centOS6.8,ccentOS7都能用的编译安装PHP的方法。久病成良医的感觉,刚开始安不上不要着急,多安几次就有经验了

立即学习PHP免费学习笔记(深入)”;

 

安装依赖:

yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt
登录后复制

无法自动安装的网上搜手动安装的教程,其实基本不会出错

进入本地目录:cd /usr/local

下载PHP7.1.5:wget http://am1.php.net/distributions/php-7.1.5.tar.gz

解压缩:tar zxvf php-7.1.5.tar.gz

进入解压目录:cd php-7.1.5

编译:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --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-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-mysql --enable-mysqlnd-compression-support --with-pear --enable-maintainer-zts --enable-session --with-gettext
登录后复制

安装目录是/usr/local/php

编译完成后会看到:Thank you for using PHP.

会译·对照式翻译
会译·对照式翻译

会译是一款AI智能翻译浏览器插件,支持多语种对照式翻译

会译·对照式翻译 0
查看详情 会译·对照式翻译

之后执行安装命令:

make
make install
登录后复制

之后拷贝配置文件(当前还在php7.1.5文件夹下,不要用mv命令,这些配置文件以后还可以用不要删):

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm(这个很重要)
登录后复制

添加环境变量:

echo 'export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH'>> /etc/profile
登录后复制

加载环境变量:source /etc/profile (我的习惯是虚拟机开机后先执行这个命令,会避免很多麻烦)

执行到这里,运行php -v就能看到安装的PHP的版本了

添加自启动:

chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig --list php-fpm
登录后复制

加权限:chmod 755 /etc/init.d/php-fpm

启动PHP:/etc/init.d/php-fpm start

查看PHP服务状态:/etc/init.d/php-fpm status

停止PHP服务:/etc/init.d/php-fpm stop

重启php服务:/etc/init.d/php-fpm restart

php的配置文件是/usr/local/php/lib/php.ini 以后安装扩展了可以在这里引用。

推荐学习:《PHP视频教程

以上就是centos6.8怎么编译安装php的详细内容,更多请关注php中文网其它相关文章!

相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号