indes.php默认文件,linux-php的编译安装3

环境: Red Hat Enterprise Linux Server release 6.2 (Santiago)

内核: 2.6.32-220.el6.x86_64

PHP版本: php-5.3.10

Mysql版本:mysql-5.1.62

Apache版本:httpd-2.4.1

PHP的安装路径:/lamp/php

安装文件存放位置:/home/software/lamp

支持库的安装:

[root@A12 lamp]# ]# yum install –y libjpeg freetype libpng gd curl libiconv zlib-devel linxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel

libiconv的安装:

[root@A12 lamp]# tar zcxf libiconv-1.14.tar.gz

[root@A12 lamp]# cd libiconv-1.14

[root@A12 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[root@A12 libiconv-1.14]# make && make install

PHP的安装

[root@A12 lamp]# tar zxf php-5.3.10.tar.gz

[root@A12 lamp]# cd php-5.3.10

[root@A12 php-5.3.10]#./configure --prefix=/lamp/php \

--with-apxs2=/lamp/apache/bin/apxs \

--with-mysql=/lamp/mysql \

--with-xmlrpc \

--with-openssl \

--with-zlib \

--with-freetype-dir \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-iconv=/usr/local/libiconv \

--enable-short-tags \

--enable-sockets \

--enable-zend-multibyte \

--enable-soap \

--enable-static \

--enable-mbstring \

--enable-gd-native-ttf \

--with-curl \

--with-xsl \

--enable-ftp \

--with-libxml-dir

+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE. By continuing this installation  |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+

Thank you for using PHP.

[root@A12 php-5.3.10]# make && make install

复制PHP的配置文件

[root@A12 php-5.3.10]# bin/cp php.ini-production /lamp/php/lib/php.ini

查看apache主配置文件中是否存在php的加载模块:

[root@A12 php-5.3.10]# grep php /lamp/apache/conf/httpd.conf

LoadModule php5_module modules/libphp5.so

增加php的支持:

[root@A12 php-5.3.10]# vim /lamp/apache/conf/httpd.conf

增加以下内容(红色字体为增加的内容)

AddType application/x-httpd-php .php  # .之前一点要有空格

DirectoryIndex index.php index.html

检查apache语法是否正确:

[root@A12 php-5.3.10]# /lamp/apache/bin/apachectl –t

Syntax OK

[root@A12 php-5.3.10]# /lamp/apache/bin/apachectl graceful

[root@A12 php-5.3.10]# netstart -lntup|grep 80

tcp 0 0 :::80 :::* LISTEN 18958/httpd

[root@A12 php-5.3.10]# netstat -lntup|grep 803306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 32363/mysqld

[root@A12 php-5.3.10]# cd /lamp/apache/htdocs/

测试php是否安装成功:

[root@A12 htdocs]# vim indesx.php

phpinfo ();

?>

将上述文件保存后退出;

再使用浏览器测试:http://IP

fa3af17ca206aa53aa1bc007ca524ce7.png

测试与mysql的连接:

[root@A12 htdocs]# vim index.php

$link=mysql_connect('localhost','root','123456');

if(!$link) echo "失败!";

else echo "成功!";

mysql_close();

?>

再使用浏览器测试:http://IP

9e917c9cefc49d3f302266def47fb2b2.png

OK!!php连接mysql是正常的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值