#!/bin/bash

#安装依赖软件
yum -y install libxml2-devel curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel net-snmp net-snmp-devel #安装libiconv-1.14(下面使用sed增加2行,不增加会报错,详细查看www.cnblogs.com/blog-tim/p/10537708.html)
cd /usr/local/src/
wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -xf libiconv-1.14.tar.gz
sed -i '697a #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)' /usr/local/src/libiconv-1.14/srclib/stdio.in.h
sed -i '699a #endif' /usr/local/src/libiconv-1.14/srclib/stdio.in.h
cd libiconv-1.14
./configure --prefix=/usr/local/php/libiconv && make && make install #安装libmcrypt-2.5.8
cd /usr/local/src/
wget -c http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -xf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install
/sbin/ldconfig && cd libltdl/
./configure --enable-ltdl-install && make && make install #安装mhash-0.9.9.9
cd /usr/local/src/
wget -c http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar -xf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure && make && make install #安装mcrypt-2.6.8
cd /usr/local/src/
wget -c http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar -xf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig && export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
./configure && make && make install #编译安装php-5.6.40
cd /usr/local/src/
wget -c http://jp2.php.net/distributions/php-5.6.40.tar.gz
tar -xf php-5.6.40.tar.gz
cd php-5.6.40
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv=/usr/local/php/libiconv --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-pear --with-freetype-dir --with-zlib --with-libxml-dir --with-iconv-dir --with-xmlrpc --with-mhash --with-mcrypt --with-curl --with-openssl --with-snmp --with-gettext --enable-pdo --enable-mbstring --enable-ctype --enable-simplexml --enable-ftp --enable-sockets --enable-gd-native-ttf --enable-sysvsem --enable-exif --enable-sysvshm --enable-xml --enable-dom --enable-simplexml --enable-shmop --enable-zip --enable-mbregex --enable-bcmath --enable-inline-optimization --enable-soap
make && make install #配置php和环境变量,关闭httpd服务
cp /usr/local/src/php-5.6.40/php.ini-production /usr/local/php/etc/php.ini
echo "export PATH=/usr/local/php/bin:$PATH" >>/etc/profile
source /etc/profile
killall -9 httpd #配置php首页,然后重新启动httpd服务
rm -f /var/www/html/index.html
cat > /var/www/html/index.php << EOF
<?php
phpinfo()
?>
EOF
/usr/local/apache/bin/apachectl start

安装完成后需检查apache主配置文件httpd.conf 中是否有增加 libphp5.so 模块内容

LoadModule php5_module        modules/libphp5.so           #<===编译安装PHP完成后会自动在apache主配置文件httpd.conf中产生此行

测试php5.6.40链接MySQL5.6.43是否成功,新建test.php文件到站点目录下,添加以下内容测试

[root@lamp html]# cat test.php
<?php
$servername = "10.0.0.3:3306";
$username = "oldboy";
$password = "123456";
$dbname = "mysql";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . mysqli_connect_error());
}else{
echo "this is connected";
}
?>

打开浏览器测试链接成功

注意:此脚本适用于LAMP环境,php在apache中以模块形式插入调用,而LNMP中php是进程方式运行!

一键安装php5.6.40脚本(LAMP环境)的更多相关文章

  1. centos7.5下yum安装php-5.6.40(LNMP环境)

    cd /etc/yum.repos.d/ yum -y install epel-release #<===安装centos7下php5.6的epel和remi源 rpm -ivh http:/ ...

  2. Vultr VPS建站攻略 – 一键安装LNMP无面板高性能WEB环境

    在"Vultr VPS建站攻略 - 一键安装宝塔面板架设LNMP/LAMP Web环境"文章中,VULTR中文网分享到我们常用的可视化面板宝塔面板安装在VULTR VPS主机中建站 ...

  3. 一键安装apache-2.4.38脚本

    [root@lamp scripts]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@lamp scripts ...

  4. Vultr VPS建站攻略 – 一键安装宝塔面板架设LNMP/LAMP Web环境

    我们选择VULTR VPS建站的还是比较多的,其主要原因在于商家的稳定,毕竟我们用来建站选择服务器价格考虑的不是主要的(当然VULTR价格也是比较便宜),最为主要的是因为VULTR商家比较稳定,而且多 ...

  5. CentOS6.x生产环境下一键安装mono+jexus的脚本,自启动,带服务,版本号自控

    转自: http://linuxdot.net/bbsfile-3784 1.支持哪些个平台?答:暂时仅支持CentOS6.x平台,7.x未测试,欢迎测试并到群里反馈给我(昵称:无聊人士) 2.一键安 ...

  6. linux下一键安装 powershell,的bash脚本

    说明 目前,linux下的powershell约等于pash.希望大家专注mono,关注pash. 一键安装脚本包括for centos6,centos7,ubuntu 14.04  ubuntu 1 ...

  7. 一键安装MySQL5.6.43脚本

    [root@lamp ~]# cat /server/scripts/mysql-5.6.43_install.sh #!/bin/bash #卸载系统自带的Mysql /bin/rpm -e $(/ ...

  8. Oracle安装部署之一键安装oracle数据库及其脚本

    准备工作:通过ftp工具上传oracle安装软件到linux系统/mnt目录下,并通过unzip命令解压软件.--------------------------------------------- ...

  9. 编译安装php5.5.7 脚本

      #!/bin/bash .tar.gz ];then wget http://oss.aliyuncs.com/aliyunecs/onekey/php/php-5.5.7.tar.gz fi . ...

随机推荐

  1. 怎么将文件夹上传到GitHub上

    1. 在GitHub上新建一个仓库地址: http://github.com/......git 2. 在需要上传的文件夹目录下,运行 git   init  初始化git: 3. 运行git  ad ...

  2. xtrabackup备份还原mariadb数据库

    一.xtrabackup 简介 xtrabackup 是由percona公司开源免费的数据库热备软件,它能对InnoDB数据库和XtraDB存储引擎的数据库非阻塞地备份,对于myisam的备份同样需要 ...

  3. 沈阳网络赛 F - 上下界网络流

    "Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...

  4. Nginx作为web静态资源服务器——防盗链

    ​ 基于http_refer防盗链配置模块 Syntax:valid_referers none | blocked | server_names | string ...; Default:—— C ...

  5. Java.数据结构.集合体系详解

    I. 第一部分:常见数据结构 首先简单说下数据结构. 什么是数据结构?数据结构就是组织数据的方式. 常见的数据结构:栈,堆,树,图,数组,队列,链表. 这里主要介绍与java集合体系相关的栈.数组和链 ...

  6. Oracle GoldenGate to Confluent with Kafka Connect

    Confluent is a company founded by the team that built Apache Kafka. It builds a platform around Kafk ...

  7. equals()和hashCode()必须同时覆盖的原因

    我们在用JAVA创建自己的类的时候,一种比较常见的覆盖就是覆盖Object中的equals()方法和hashCode()方法.如果不这样做的话,就很可能违反Object.hashCode()的通用约定 ...

  8. Mayor's posters (线段树+离散化)

    Mayor's posters Description The citizens of Bytetown, AB, could not stand that the candidates in the ...

  9. 同一个环境同时使用python2和python3的方法

    1.首先安装好p2和p3,配置好环境变量.在CMD内执行python返回版本号,返回结果根据配置的环境变量而定,如果p2的环境变量配置在前面,则返回p2的版本号,反之则p3 2.然后把各版本目录下的p ...

  10. SpringBoot缓存篇Ⅱ --- 整合Redis以及序列化机制

    一.Redis环境搭建 系统默认是使用ConcurrentMapCacheManager,然后获取和创建ConcurrentMapCache类型的缓存组件,再将数据保存在ConcurrentMap中 ...