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
如果安装成功以后,在/usr/local/libxml2/目录下将生成bin、include、lib、man和share五个目录。在后面安装PHP5源代码包的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/ local/libxml2"选项,用于指定安装libxml2库文件的位置。
3.安装php5 (--with-mysql 和--with-apxs的路径 根据自己实际情况写,用下面的查询命令查找)
用如下查找命令,可以找到程序的路径:
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)
解决办法:
[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安装成功!
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安装成功!
相关文章推荐
- Linux经常使用的命令(必看)
- Linux下LDAP统一认证解决方案
- linux 服务简介
- linux JDK 安装无法建立连接的问题解决 wget方法后面再说
- centos7下面搭建lnmp环境
- 1.4 CentOS7 配置AMP环境之安装准备
- linux上搭建完整go语言vim开发环境
- centos LAMP搭建
- 1.3 CentOS7设置FTP
- Linux apt-get
- Linux(9.21-9.27)学习笔记
- Linux(9.21-9.27)学习笔记
- GNU Linux mount挂载的常用三种方法
- Linux 中 10 个有用的命令行补全例子
- Linux 中 10 个有用的命令行补全例子
- linux安装mysql
- 1.1 VM中CentOS7通过NAT方式设置静态IP
- CentOS–FTP安装与配置
- linux下mysql yum 安装 新建用户 设置权限
- Linux下core文件的生成和使用