码迷,mamicode.com
首页 > Web开发 > 详细

LAMP搭建3:PHP安装

时间:2017-01-12 03:35:40      阅读:39      评论:0      收藏:0      [点我收藏+]

标签:lamp   php   安装   

1.进入/usr/local/src/目录下载安装包php-5.4.36.tar.bz2

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

[[email protected] src]# ls

php-5.4.36.tar.bz2

2.解压安装包

[[email protected] src]# tar jxvf php-5.4.36.tar.bz2

[[email protected] src]# echo $?

0

3.进入安装目录

[[email protected] src]# cd php-5.4.36

4.配置安装选项

[[email protected] php-5.4.36]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/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 --disable-ipv6

php编译安装中常见配置错误处理请参考:

(1)http://www.poluoluo.com/jzxy/201505/364819.html

(2)http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html

错误1:configure: error: Cannot find OpenSSL‘s <evp.h>

解决:[[email protected] php-5.4.36]# yum install -y openssl openssl-devel

错误2:configure: error: Please reinstall the BZip2 distribution

解决:[[email protected] php-5.4.36]# yum install bzip2 bzip2-devel

错误3:configure: error: jpeglib.h not found.

解决:[[email protected] php-5.4.36]# yum -y install libjpeg-devel

错误4:configure: error: png.h not found.

解决:[[email protected] php-5.4.36]# yum -y install libpng-devel

错误5:configure: error: freetype-config not found.

解决:[[email protected] php-5.4.36]# yum -y install freetype-devel

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

解决:由于centos官方源中没有libmcrypy-devel这个包,我们需要安装一个工具epel,然后再安装libmcrypy-devel。

[[email protected] php-5.4.36]# rpm -ivh ‘http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm‘

[[email protected] php-5.4.36]# yum list |grep -i mcrypt

libmcrypt.i686                              2.5.8-9.el6                  epel

libmcrypt-devel.i686                        2.5.8-9.el6                  epel

libtomcrypt.i686                            1.17-21.el6                  epel

libtomcrypt-devel.i686                      1.17-21.el6                  epel

libtomcrypt-doc.noarch                      1.17-21.el6                  epel

mcrypt.i686                                 2.6.8-10.el6                 epel

php-mcrypt.i686                             5.3.3-5.el6                  epel

[[email protected] php-5.4.36]# yum install -y libmcrypt-devel

直到配置全部正确:

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

0

5.编译:

[[email protected] php-5.4.36]# make

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

0

6.安装:

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

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

0

7.查看安装结果:

[[email protected] php-5.4.36]# ls /usr/local/php/

bin  etc  include  lib  php

8.将php加入系统环境变量:

[[email protected] support-files]# vim /etc/profile.d/path.sh

#!/bin/bash

export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/:/usr/local

/php/bin/

[[email protected] support-files]# source /etc/profile.d/path.sh

9.测试PHP

[[email protected] php-5.4.36]# php -m # -m选项查看php的静态模块

[[email protected] php-5.4.36]# php -i # -i选项列出php配置的详细信息,包括模块的

部分配置选项说明:

[[email protected] php-5.4.36]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/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 --disable-ipv6

--with-apxs2 帮助安装动态模块的工具

[[email protected] php-5.4.36]# ls /usr/local/apache2/modules/

httpd.exp  libphp5.so  mod_deflate.so  mod_expires.so  mod_rewrite.so

Apache目录下多了一个动态模块libphp5就是apxs的功劳

--with-mysql 说明php依赖MySQL,所以才先安装MySQL


LAMP搭建3:PHP安装

标签:lamp   php   安装   

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!