Home  >  Article  >  php教程  >  Linux上安装PHP的问题

Linux上安装PHP的问题

WBOY
WBOYOriginal
2016-06-06 20:02:00902browse

在虚拟机上安装PHP(测试成功通过,问题已经解决) (1)首先把php-5.2.17.tar.gz挂载到操作系统上 mount /mnt/cdrom(我的做法是然后复制到/home/soft目录下,这里专门放置我的软件包,读者可以不需要这样做) (2)然后解压 tar -zxvfphp-5.2.17.tar.gz ,

在虚拟机上安装PHP(测试成功通过,问题已经解决)

(1)首先把php-5.2.17.tar.gz挂载到操作系统上 mount /mnt/cdrom(我的做法是然后复制到/home/soft目录下,这里专门放置我的软件包,读者可以不需要这样做)

(2)然后解压 tar -zxvf php-5.2.17.tar.gz ,当前目录出现php-5.2.17文件,进入php-5.2.17文件中cd php-5.2.17

(3)然后准备安装./configure --prefix=/usr/local/php 

                                                        --with-apxs2=/usr/local/apache/bin/apxs

                                                        --with-mysql=/usr/local/mysql

(4)当执行第三步的代码的时候出现configure: error: libxml2 version 2.6.11 or greater required.这样的问题,这样就不能make以及make install操作了。首先分析问题,看到刚才报错的提示,发现时操作系统自带的libxml2的版本过低。这个时候需要在本操作系统上查看是否安装过libxml.

(5)rpm -qa |grep libxml,发现本操作系统确实安装了libxml的软件,但是版本过低,此时我在www.xmlsoft.org网站中下载更高的版本程序包(libxml2-2.7.2。tar.gz)准备进行安装

(6)首先是卸载过低版本的libxml2。rpm -e libxml --nodeps(强制删除)

(7)卸载完之后接下来安装新版本的libxml2-2.7.2.步骤:挂载-》解压,解压后进入到libxml2-2.7.2目录中然后执行./configure --prefix=/usr/local/libxml命令准备安装-》make->make install 这样就安装完心版本的libxml2-2.7.2

(8)安装完之后返回第三步重新开始安装PHP     

                                ./configure --prefix=/usr/local/php 

                                                        --with-apxs2=/usr/local/apache/bin/apxs

                                                        --with-mysql=/usr/local/mysql

(9)这时候还是出现configure: error: libxml2 version 2.6.11 or greater required.这样的问题,经过分析后发现在PHP的安装过程中没有指定libxml2所在的路径,所以附带参数-

                        ./configure --prefix=/usr/local/php 

                                                        --with-apxs2=/usr/local/apache/bin/apxs

                                                        --with-mysql=/usr/local/mysql

                                                        --with-libxml-dir=/usr/local/libxml。

(10)这时候执行成功,然后执行make,最后执行make install

(11)当我第二天启动系统执行startx进入操作界面的时候又出现新的一个问题

error while loading shared libraries: libxml2.so.2:cannot open shared object file: No such file or directory这样的问题。首先经过分析之后找到原因,是因为昨天我安装了libxml2的时候我指定它一个新的安装目录,系统找不到libxml2.so.2

(12)我进入/usr/local/libxml/lib中确实是发有libxml2.so.2。然后我经过分析之后就在/etc/ld.so.conf中加入/usr/local/libxml/lib这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。

(13)经过以上问题的解决,总体把PHP安装完成,接下来就需要把php,mysql.apache。配置好并运行起来,这样LAMP(Linux+Apache+MySQL+PHP)环境搭建好了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn