LAMP环境搭建三(centos7)PHP5和PHP7安装

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

实验流程:

[[email protected] src]# cd /usr/local/src/

[[email protected] src]#  wget  http://cn2.php.net/distributions/php-5.6.30.tar.gz

[[email protected] src]# du -h php-5.6.30.tar.gz

19M php-5.6.30.tar.gz

[[email protected] src]# tar zxvf php-5.6.30.tar.gz

[[email protected] php-5.6.30]# cd php-5.6.30/

[[email protected] 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.

[[email protected] php-5.6.30]# yum install -y libxml2-devel

2  configure: error: Cannot find OpenSSL‘s <evp.h>

[[email protected] php-5.6.30]# yum install -y openssl-devel

3 configure: error: Please reinstall the BZip2 distribution

[[email protected] php-5.6.30]# yum install -y bzip2-devel

4  configure: error: jpeglib.h not found.

[[email protected] 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.

[[email protected] php-5.6.30]# yum install -y freetype freetype-devel

6  configure: error: mcrypt.h not found. Please reinstall libmcrypt.

[[email protected] php-5.6.30]# yum install -y epel-release    //安装扩展源

[[email protected] 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

[[email protected] php-5.6.30]# echo $?

0

[[email protected] php-5.6.30]#

编译参数配置完毕!!

[[email protected] php-5.6.30]#make

make的时候会报很多的错,基本上都是缺少库文件,直接下载相应的库即可

或者 复制粘贴到搜索引擎搜索

Build complete.

Don‘t forget to run ‘make test‘.

[[email protected] php-5.6.30]# echo $?

0

很奇怪,我的没有报错。

[[email protected] php-5.6.30]# make install

[[email protected] php-5.6.30]# echo $?

0

[[email protected] php-5.6.30]# ls /usr/local/php/                     //PHP下的目录

bin  etc  include  lib  php

[[email protected] php-5.6.30]# ls /usr/local/php/bin/               //bin下是重要的文件

pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpize

[[email protected] php-5.6.30]# du -sh /usr/local/php/bin/php

36M /usr/local/php/bin/php

[[email protected] php-5.6.30]# du -sh /usr/local/apache2.4.7/modules/libphp5.so

37M /usr/local/apache2.4.7/modules/libphp5.so                //37M 这个就是我们要的扩展模块

[[email protected] php-5.6.30]# /usr/local/php/bin/php -m       //查看PHP加载的模块  都是静态模块

[PHP Modules]

..

最后复制配置文件

[[email protected] 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/

[[email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

[[email protected] src]# tar jxf php-7.1.6.tar.bz2

[[email protected] src]# cd php-7.1.6/

[[email protected] 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

[[email protected] php-7.1.6]# echo $?

0

[[email protected] 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

[[email protected] php-7.1.6]# make

[[email protected] 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

时间: 2024-08-28 22:04:36

LAMP环境搭建三(centos7)PHP5和PHP7安装的相关文章

[LAMP环境搭建三]PHP安装

****说明:先全部看一遍,再开始安装**** 获取PHP源码包 http://cn2.php.net/get/php-5.5.10.tar.gz/from/this/mirrorwget 安装libxml2:wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz./configure --prefix=/usr/local/libxml2# yum -y install python-devel 安装zlib:wget http://zlib.n

lamp环境搭建之二mysql通用二进制安装

首先创建一个mysql数据库存放目录,建议创建一个lvm卷来存放数据库文件 mkdir /mysqldata/data 添加mysql用户 groupadd -r mysql useradd -g mysql -r -s /sbin/nologin -M -d /mysqldata/data mysql 修改数据库目录的属主和属组 chown -R mysql:mysql /mysqldata/data 解压二进制通用包 tar xf mysql-5.6.13-linux-glibc2.5-i6

LAMP环境搭建(源码包安装,仅测试)

linux系统+Apache服务+MySQL数据库+PHP 安装顺序:PHP要在最后安装 首先将安装包上传到/root目录下 链接:http://pan.baidu.com/s/1nvbWEk5 密码:9r9w ************************************************************************************************************************************************

LAMP 环境搭建 C7

#LAMP环境搭建Centos 7        (1)安装开发包组 "Development Tools" "Server Platform Development"    yum groupinstall            注:关闭selinux iptables(2)安装amp    (a)yum install httpd php  php-mysql mariadb mod_ssl        (b)https://xcache.lighttpd.n

LNMP环境搭建(CentOS7+Nginx1.10.1+MySQL5.6.31+PHP5.6.22)

零.准备工作 安装wget:yum install wget -y 安装gcc及g++:yum install gcc gcc-c++ -y 后续所有源代码都下载到/usr/local/src目录 防火墙更改配置及关闭selinux见另一篇文章<LAMP环境搭建> 一.安装Nginx Nginx依赖pcre(重写rewrite).zlib(网页gzip压缩)及openssl(加密传输). 1.安装pcre [root]wget http://pilotfiber.dl.sourceforge.

Centos7下的LAMP环境搭建

参考网站:http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.html http://www.osyunwei.com/archives/5910.html http://www.luoxiao123.cn/centos-yum-lnmp.html http://blog.sina.com.cn/s/blog_66ac09390101ivep.html Centos7.0   lamp环境搭建 CentOS 7.0默认使用的是fire

LAMP环境搭建之编译安装指南(php-5.3.27.tar.gz)

测试环境:CentOS release 6.5 (Final) 软件安装:httpd-2.2.27.tar.gz   mysql-5.1.72.tar.gz   php-5.3.27.tar.gz 1.mysql安装详见:https://www.cnblogs.com/su-root/p/11210794.html 2.apache安装详见:https://www.cnblogs.com/su-root/p/11182549.html 3.PHH安装如下: 一.php安装准备 ①yum安装php

LNMP环境搭建(centos6.9+mysql5.7+php7.1+nginx1.9)

一.安装MySql mysql的安装请参考 LAMP环境搭建(centos6.9+apache2.4+mysql5.7+php7.1), 和里面的安装方法一样. 二.php安装 cd /usr/local/srcwget http://mirrors.sohu.com/php/php-7.1.3.tar.gztar zxvf php-7.1.3.tar.gzcd php-7.1.3 ./configure \--prefix=/usr/local/php \--with-apxs2=/usr/l

LAMP环境搭建教程

学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一.首先安装操作系统 操作系统:centos6.3 IP地址:192.168.146.129 网关: DNS: 操作系统安装步骤,此处不在给出截图. 备注:服务器系统采用最小化安装,安装一下GCC编译工具和一个桌面即可.如下图所示: 二.LAMP安装前的准备 1.获取软件包 httpd-2.4.2.ta