centos7 访问php页面显示源码_运维干货分享:centos7下源码编译安装php-7.1.5(脚本)...

PHP简介:

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

PHP是免费的,并且使用非常广泛。同时,对于像微软 ASP 这样的竞争者来说,PHP 无疑是另一种高效率的选项。

4897939e542929a2d74372d45d53fd78.png

PHP

给大家介绍下CentOs7下如何通过编译去安装php7.1.5,教程亲测可行。

1、下载php-7.1.5软件包

下载地址:http://ftp.ntu.edu.tw/php/distributions/php-7.1.5.tar.xz

[root@localhost ~]# wget -c http://ftp.ntu.edu.tw/php/distributions/php-7.1.5.tar.gz

2、解压php7

[root@localhost ~]# tar zxf php-7.1.5.tar.gz

3、移动解压之后的文件夹到/usr/local/

[root@localhost ~]# mv php-7.1.5 /usr/local/php

4、进入php目录

[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官方安装说明: (极简安装)

[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了,希望可以帮助到大家。如需转载请注明出处。


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

#!/bin/bash#2019-6-7 09:58:44# BY:FY#Auto Install PHP-7 SoftPHP_URL=http://ftp.ntu.edu.tw/php/distributionsPHP_FILE=php-7.1.5.tar.gzPHP_FILE_DIR=php-7.1.5PHP_PREFIX=/usr/local/phpUSER=wwwfunction install_php {if [ ! -d ${PHP_PREFIX} ];thenwget -c ${PHP_URL}/${PHP_FILE}tar zxf ${PHP_FILE}mv ${PHP_FILE_DIR} ${PHP_PREFIX}cd ${PHP_PREFIX}#安装依赖包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./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=${USER} --with-fpm-group=${USER} --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-opcacheif [ $? -eq 0 ];then make && make installelse exit 1fifi}function config_php {cp php.ini-production /etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmuseradd ${USER}/etc/init.d/php-fpm start}install_phpconfig_php

干货分享完成,喜欢的支持一下吧。

对Linux感兴趣的小伙伴私信Linux资料”,免费获取文档资料。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值