Home >php教程 >php手册 >Linux下安装PHP 5.4.3(以Apache为WebServer)

Linux下安装PHP 5.4.3(以Apache为WebServer)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:50:491473browse

本文为Rainisic http://www.cnblogs.com/rainisic/archive/2012/05/23/Apache_PHP_Install.html 下载PHP 官方下载:http://www.php.net/downloads.php 安装PHP 首先,确保Apache在编译安装时支持PHP模块,详情请参考:http://www.cnblogs.com/rainisic/archi

本文为Rainisic

http://www.cnblogs.com/rainisic/archive/2012/05/23/Apache_PHP_Install.html

下载PHP

官方下载:http://www.php.net/downloads.php

安装PHP

首先,确保Apache在编译安装时支持PHP模块,详情请参考:http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html

解压缩PHP

shell> <span>sudo</span> <span>tar</span> zxvf php-<span>5.4</span>.<span>3</span>.<span>tar</span>.gz /opt/sources

停止Apache服务

shell> <span>sudo</span> service httpd stop

配置安装PHP

shell> cd /opt/sources/php-<span>5.4</span>.<span>3</span><span>
shell</span>> <span>sudo</span> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-<span>mysql
shell</span>> <span>sudo</span> <span>make</span><span>
shell</span>> <span>sudo</span> <span>make</span> <span>install</span>

配置php.ini

shell> <span>sudo</span> <span>cp</span> php.ini-development /usr/local/lib/php.ini

编辑 httpd.conf 文件以调用 PHP 模块。LoadModule 表达式右边的路径必须指向 系统中的 PHP。以上的 make install 命令可能已经完成了这些,但务必要检查。

LoadModule php5_module modules/libphp5.so

告知 Apache 将特定的扩展名解析成 PHP,例如,让 Apache 将扩展名 .php 解析成 PHP。编辑httpd.conf

<filesmatch><span>
    SetHandler application</span>/x-httpd-<span>php
</span></filesmatch>

按照通常的方式启动 Apache 服务测试即可。

扩展阅读

  • PHP官方安装文档:http://www.php.net/manual/zh/install.unix.apache2.php
  • Apache2安装:http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html
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