设为首页 收藏本站
查看: 765|回复: 0

[经验分享] LAMP环境搭建三(centos7)PHP5和PHP7安装

[复制链接]

尚未签到

发表于 2018-12-13 08:39:16 | 显示全部楼层 |阅读模式
  php其实是Apache的扩展模块。(需要最后安装)
  PHP官网www.php.net
  当前主流版本为5.6/7.1
  cd /usr/local/src/
  wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
  tar zxf php-5.6.30.tar.gz
  cd php-5.6.30
  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  make && make install
  cp php.ini-production  /usr/local/php/etc/php.ini
  实验流程:
  [root@lyon-01 src]# cd /usr/local/src/
  [root@lyon-01 src]#  wget  http://cn2.php.net/distributions/php-5.6.30.tar.gz
  [root@lyon-01 src]# du -h php-5.6.30.tar.gz
  19Mphp-5.6.30.tar.gz
  [root@lyon-01 src]# tar zxvf php-5.6.30.tar.gz
  [root@lyon-01 php-5.6.30]# cd php-5.6.30/
  [root@lyon-01 php-5.6.30]#  ./configure
  --prefix=/usr/local/php                                         //指定安装目录
  --with-apxs2=/usr/local/apache2.4.7/bin/apxs    //Apache的工具   模块相关(你的Apache目录)
  --with-config-file-path=/usr/local/php/etc           //指定配置文件所在路径
  --with-mysql=/usr/local/mysql                               //指定mysql的路径
  --with-pdo-mysql=/usr/local/mysql                                      //
  --with-mysqli=/usr/local/mysql/bin/mysql_config                  //这两个是MySQL的驱动或者是库
  --with-libxml-dir                //后面这些东西都是一些模块,许多需要安装
  --with-gd
  --with-jpeg-dir
  --with-png-dir
  --with-freetype-dir
  --with-iconv-dir
  --with-zlib-dir
  --with-bz2 --with-openssl
  --with-mcrypt
  --enable-soap
  --enable-gd-native-ttf
  --enable-mbstring
  --enable-sockets
  --enable-exif
  报错详解:
  1 configure: error: xml2-config not found. Please check your libxml2 installation.
  [root@lyon-01 php-5.6.30]# yum install -y libxml2-devel
  2  configure: error: Cannot find OpenSSL's
  [root@lyon-01 php-5.6.30]# yum install -y openssl-devel
  3 configure: error: Please reinstall the BZip2 distribution
  [root@lyon-01 php-5.6.30]# yum install -y bzip2-devel
  4  configure: error: jpeglib.h not found.
  [root@lyon-01 php-5.6.30]# yum install -y libjpeg-turbo.x86_64  jpeginfo.x86_64 jpegoptim.x86_64  libjpeg-turbo-devel.x86_64
  5  configure: error: freetype-config not found.
  [root@lyon-01 php-5.6.30]# yum install -y freetype freetype-devel
  6  configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  [root@lyon-01 php-5.6.30]# yum install -y epel-release    //安装扩展源
  [root@lyon-01 php-5.6.30]# yum install -y libmcrypt-devel
  Thank you for using PHP.
  config.status: creating php5.spec
  config.status: creating main/build-defs.h
  config.status: creating scripts/phpize
  config.status: creating scripts/man1/phpize.1
  config.status: creating scripts/php-config
  config.status: creating scripts/man1/php-config.1
  config.status: creating sapi/cli/php.1
  config.status: creating sapi/cgi/php-cgi.1
  config.status: creating ext/phar/phar.1
  config.status: creating ext/phar/phar.phar.1
  config.status: creating main/php_config.h
  config.status: executing default commands
  [root@lyon-01 php-5.6.30]# echo $?
  0
  [root@lyon-01 php-5.6.30]#
  编译参数配置完毕!!
  [root@lyon-01 php-5.6.30]#make
  make的时候会报很多的错,基本上都是缺少库文件,直接下载相应的库即可
  或者 复制粘贴到搜索引擎搜索
  Build complete.
  Don't forget to run 'make test'.
  [root@lyon-01 php-5.6.30]# echo $?
  0
  很奇怪,我的没有报错。
  [root@lyon-01 php-5.6.30]# make install
  [root@lyon-01 php-5.6.30]# echo $?
  0
  [root@lyon-01 php-5.6.30]# ls /usr/local/php/                     //PHP下的目录
  bin  etc  include  lib  php
  [root@lyon-01 php-5.6.30]# ls /usr/local/php/bin/               //bin下是重要的文件
  pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpize
  [root@lyon-01 php-5.6.30]# du -sh /usr/local/php/bin/php
  36M/usr/local/php/bin/php
  [root@lyon-01 php-5.6.30]# du -sh /usr/local/apache2.4.7/modules/libphp5.so
  37M/usr/local/apache2.4.7/modules/libphp5.so                //37M 这个就是我们要的扩展模块
  [root@lyon-01 php-5.6.30]# /usr/local/php/bin/php -m       //查看PHP加载的模块  都是静态模块
  [PHP Modules]
  ..
  最后复制配置文件
  [root@lyon-01 php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
  安装PHP7
  cd /usr/local/src/
  wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
  tar zxf php-7.1.6.tar.bz2
  cd php-7.1.6
  ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc  --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  make && make install
  ls /usr/local/apache2.4/modules/libphp7.so
  cp php.ini-production  /usr/local/php7/etc/php.ini
  实验
  cd /usr/local/src/
  [root@lyon-01 src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
  [root@lyon-01 src]# tar jxf php-7.1.6.tar.bz2
  [root@lyon-01 src]# cd php-7.1.6/
  [root@lyon-01 php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4.7/bin/apxs --with-config-file-path=/usr/local/php7/etc  --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  几分钟之后
  Thank you for using PHP.
  config.status: creating php7.spec
  config.status: creating main/build-defs.h
  config.status: creating scripts/phpize
  config.status: creating scripts/man1/phpize.1
  config.status: creating scripts/php-config
  config.status: creating scripts/man1/php-config.1
  config.status: creating sapi/cli/php.1
  config.status: creating sapi/cgi/php-cgi.1
  config.status: creating ext/phar/phar.1
  config.status: creating ext/phar/phar.phar.1
  config.status: creating main/php_config.h
  config.status: executing default commands
  [root@lyon-01 php-7.1.6]# echo $?
  0
  [root@lyon-01 php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4.7/bin/apxs --with-config-file-path=/usr/local/php7/etc  --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  [root@lyon-01 php-7.1.6]# make
  [root@lyon-01 php-7.1.6]# make  install
  OK
  Linux下查看Nginx、Napache、MySQL、PHP的编译参数的命令如下:
  1、nginx编译参数:
  #/usr/local/nginx/sbin/nginx -V
  2、apache编译参数:
  # cat /usr/local/apache/build/config.nice
  3、php编译参数:
  # /usr/local/php/bin/php -i |grep configure
  4、mysql编译参数:
  # cat /usr/local/mysql/bin/mysqlbug|grep configure
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-650736-1-1.html 上篇帖子: php在linux下call to undefined function imagettftext() 下篇帖子: thinkphp 定时执行php文件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表