您的位置:首页 > 运维架构 > Linux

linux 源码安装php

2015-09-26 17:11 525 查看
源码安装php /article/6982728.html

1.获取安装文件: http://www.php.net/downloads.php php-5.3.8.tar.gz
获取安装php需要的支持文件:http://download.csdn.net/download/netlong339/1351852
libxml2-2.6.32.tar.gz
2.安装libxml2

1 tar zxvf libxml2-2.6.32.tar.gz
2 cd libxml2-2.6.32
3 ./configure --prefix=/usr/local/libxml2
4 make
5 make install


如果安装成功以后,在/usr/local/libxml2/目录下将生成bin、include、lib、man和share五个目录。在后面安装PHP5源代码包的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/ local/libxml2"选项,用于指定安装libxml2库文件的位置。
3.安装php5 (--with-mysql 和--with-apxs的路径 根据自己实际情况写,用下面的查询命令查找)



#tar zvxf php-5.3.8.tar.gz
#cd php-5.3.8
#./configure \
--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/ local/libxml2
#make
#make install


用如下查找命令,可以找到程序的路径:
find / -name xxx
whereis mysql 用于程序名的搜索 which 用于命令的搜索
rpm -qa | grep mysql 查看是否安装该软件
rpm -ql mysql | grep '/etc' 查看软件包安装的/etc相关的路径,不加过滤条件就是显示所有的

实际操作:
[root@Java228 php-5.6.10]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-apxs2=/usr/sbin/httpd // 没有apxs 路径不对然后上面那样的报错

报错:
.........
Configuring SAPI modules

checking for AOLserver support... no

checking for Apache 1.x module support via DSO through APXS... no

checking for Apache 1.x module support... no

checking whether to enable Apache charset compatibility option... no

checking for Apache 2.0 filter-module support via DSO through APXS... no

checking for Apache 2.0 handler-module support via DSO through APXS...

Sorry, I cannot run apxs. Possible reasons follow:



1. Perl is not installed 刚开始没有apxs这样报错

2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs

3. Apache was not built using --enable-so (the apxs usage page is displayed)


解决办法:


rpm安装的apache没有apxs文件吗 没有,需要安装httpd-devel才有apxs

[root@Java228 ~]#yum -y install httpd-devel
[root@Java228 ~]# whereis apxs

apxs: /usr/sbin/apxs /usr/share/man/man8/apxs.8.gz 装了httpd-devel 才有这个!!!!!

再次 /.configure
[root@Java228 php-5.6.10]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2 --with-apxs2=/usr/sbin/apxs
[root@Java228 php-5.6.10]#make
[root@Java228 php-5.6.10]#make install

4.重新配置apache2让他支持php

配置 httpd.conf 让apache支持PHP:

  # vi /usr/local/apache/conf/httpd.conf
  找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
  AddType application/x-httpd-php .php (.前面有空格)
  AddType application/x-httpd-php-source .phps (.前面有空格)

然后CPOPY PHP的配置文件

  cp php-5.3.8/php.ini.dist /usr/local/php/lib/php.ini
(如果没有php.ini.dist 则把php.ini-development php.ini-production中的任何一个重命名为php.ini.dist即可。)
  修改php.ini文件 register_globals = On

重启apache

  service apache restart
5.测试php是否成功安装
写一个php测试页info.php,放到apache2/htdocs中。
<?php
phpinfo();
?>;
在浏览器中输入:服务器地址/info.php
如果能正常显示出php的信息,则说明Apche+Mysql+PHP安装成功!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: