CentOS 7.4安装PHP-7.1.5

小柒助手 Linux1 87,71011字数 811阅读2分42秒阅读模式

PHP简介

    PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP是目前动态网页开发中使用最为广泛的语言之一。PHP能运行在包括Windows、Linux等在内的绝大多数操作系统环境中

    PHP 是免费的,并且使用非常广泛。同时,对于像微软 ASP 这样的竞争者来说,PHP 无疑是另一种高效率的选项。文章源自小柒网-https://www.yangxingzhen.cn/3085.html

给大家介绍下CentOS 7.4下如何通过编译去安装php7.1.5,教程为本人亲测。文章源自小柒网-https://www.yangxingzhen.cn/3085.html

1、下载php-7.1.5软件包
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

下载地址:https://mirrors.yangxingzhen.com/php/php-7.1.5.tar.gz
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

[root@localhost ~]# wget -c https://mirrors.yangxingzhen.com/php/php-7.1.5.tar.gz
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

2、解压php7
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

[root@localhost ~]# tar zxf php-7.1.5.tar.gz
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

3、移动解压之后的文件夹到/usr/local/
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

[root@localhost ~]# mv php-7.1.5 /usr/local/php
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

4、进入php目录
文章源自小柒网-https://www.yangxingzhen.cn/3085.html

[root@localhost ~]# cd /usr/local/php

5、安装依赖包

[root@localhost php]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

6、编译配置(如果出现错误,基本都是上一步的依赖文件没有安装所致),嫌麻烦的可以从这一步起参考PHP官方安装说明:http://php.net/manual/zh/install.unix.nginx.php (极简安装)

[root@localhost php]# ./configure \

--prefix=/usr/local/php \

--with-config-file-path=/etc \

--enable-fpm \

--with-fpm-user=www \

--with-fpm-group=www \

--enable-inline-optimization \

--disable-debug \

--disable-rpath \

--enable-shared \

--enable-soap \

--with-libxml-dir \

--with-xmlrpc \

--with-openssl \

--with-mcrypt \

--with-mhash \

--with-pcre-regex \

--with-sqlite3 \

--with-zlib \

--enable-bcmath \

--with-iconv \

--with-bz2 \

--enable-calendar \

--with-curl \

--with-cdb \

--enable-dom \

--enable-exif \

--enable-fileinfo \

--enable-filter \

--with-pcre-dir \

--enable-ftp \

--with-gd \

--with-openssl-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib-dir \

--with-freetype-dir \

--enable-gd-native-ttf \

--enable-gd-jis-conv \

--with-gettext \

--with-gmp \

--with-mhash \

--enable-json \

--enable-mbstring \

--enable-mbregex \

--enable-mbregex-backtrack \

--with-libmbfl \

--with-onig \

--enable-pdo \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-zlib-dir \

--with-pdo-sqlite \

--with-readline \

--enable-session \

--enable-shmop \

--enable-simplexml \

--enable-sockets \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

--enable-wddx \

--with-libxml-dir \

--with-xsl \

--enable-zip \

--enable-mysqlnd-compression-support \

--with-pear \

--enable-opcache

7、正式安装

[root@localhost php]# make && make install

8、配置php-fpm

[root@localhost php]# cp php.ini-production /etc/php.ini

[root@localhost php]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[root@localhost php]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

[root@localhost php]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@localhost php]# chmod +x /etc/init.d/php-fpm

9、创建www用户,启动php-fpm

[root@localhost php]# useradd www

[root@localhost php]# /etc/init.d/php-fpm start

至此就已经安装好php7.1.5了,希望可以帮助到大家。如需转载请注明出处。

附一键安装脚本,脚本内容如下:

  1. #!/bin/bash
  2. #2019-6-7 09:58:44
  3. #Author blog:
  4. #    https://www.yangxingzhen.cn
  5. #Author site:
  6. #    https://www.yangxingzhen.cn/sitemap.html
  7. #Author mirrors site:
  8. #    https://mirrors.yangxingzhen.com
  9. #About the Author
  10. #    BY:、、、小柒
  11. #    QQ:675583110
  12. #    Mail:675583110@qq.com
  13. #Auto Install PHP-7 Soft
  14. PHP_URL=https://mirrors.yangxingzhen.com/php
  15. PHP_FILE=php-7.1.5.tar.gz
  16. PHP_FILE_DIR=php-7.1.5
  17. PHP_PREFIX=/usr/local/php
  18. USER=www
  19. function install_php {
  20. if [ ! -d ${PHP_PREFIX} ];then
  21. wget -c ${PHP_URL}/${PHP_FILE}
  22. tar zxf ${PHP_FILE}
  23. mv ${PHP_FILE_DIR} ${PHP_PREFIX}
  24. cd ${PHP_PREFIX}
  25. #安装依赖包
  26. yum y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
  27. ./configure \
  28. --prefix=/usr/local/php \
  29. --with-config-file-path=/etc \
  30. --enable-fpm \
  31. --with-fpm-user=${USER} \
  32. --with-fpm-group=${USER} \
  33. --enable-inline-optimization \
  34. --disable-debug \
  35. --disable-rpath \
  36. --enable-shared \
  37. --enable-soap \
  38. --with-libxml-dir \
  39. --with-xmlrpc \
  40. --with-openssl \
  41. --with-mcrypt \
  42. --with-mhash \
  43. --with-pcre-regex \
  44. --with-sqlite3 \
  45. --with-zlib \
  46. --enable-bcmath \
  47. --with-iconv \
  48. --with-bz2 \
  49. --enable-calendar \
  50. --with-curl \
  51. --with-cdb \
  52. --enable-dom \
  53. --enable-exif \
  54. --enable-fileinfo \
  55. --enable-filter \
  56. --with-pcre-dir \
  57. --enable-ftp \
  58. --with-gd \
  59. --with-openssl-dir \
  60. --with-jpeg-dir \
  61. --with-png-dir \
  62. --with-zlib-dir \
  63. --with-freetype-dir \
  64. --enable-gd-native-ttf \
  65. --enable-gd-jis-conv \
  66. --with-gettext \
  67. --with-gmp \
  68. --with-mhash \
  69. --enable-json \
  70. --enable-mbstring \
  71. --enable-mbregex \
  72. --enable-mbregex-backtrack \
  73. --with-libmbfl \
  74. --with-onig \
  75. --enable-pdo \
  76. --with-mysqli=mysqlnd \
  77. --with-pdo-mysql=mysqlnd \
  78. --with-zlib-dir \
  79. --with-pdo-sqlite \
  80. --with-readline \
  81. --enable-session \
  82. --enable-shmop \
  83. --enable-simplexml \
  84. --enable-sockets \
  85. --enable-sysvmsg \
  86. --enable-sysvsem \
  87. --enable-sysvshm \
  88. --enable-wddx \
  89. --with-libxml-dir \
  90. --with-xsl \
  91. --enable-zip \
  92. --enable-mysqlnd-compression-support \
  93. --with-pear \
  94. --enable-opcache
  95. if [ $? -eq 0 ];then
  96.     make && make install
  97. else
  98.     exit 1
  99. fi
  100. fi
  101. }
  102. function config_php {
  103. cp php.ini-production /etc/php.ini
  104. cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
  105. cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
  106. cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  107. chmod +x /etc/init.d/php-fpm
  108. useradd ${USER}
  109. /etc/init.d/php-fpm start
  110. }
  111. install_php
  112. config_php

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
我的微信
微信号已复制
微信公众号
微信扫一扫,关注我!
weinxin
我的公众号
公众号已复制
Linux最后更新:2022-11-23
小柒助手
  • 本文由 小柒助手 发表于 2019年6月7日 10:11:50
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.cn/3085.html
    • 运维老司机
      运维老司机 6

      亲测,写的不错 :razz:

    匿名

    发表评论

    匿名网友
    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

    拖动滑块以完成验证
    加载中...