Home > Backend Development > PHP Tutorial > Linux 安装php

Linux 安装php

WBOY
Release: 2016-06-23 13:17:41
Original
738 people have browsed it

安装libxml2

下载解压  libxml2-2.6.32.tar.gz

安装

./configure --prefix=/usr/local/php --with-libxml-dir=/usr/local/libxml2
Copy after login

安装php

下载  http://www.php.net/downloads.php
解压  tar -zxvf php-5.3.16.tar.gz

安装

./configure --prefix=/usr/local/php --with-libxml-dir=/usr/local/libxml2 --with-apxs2=/usr/local/httpd/bin/apxsmakesudo make install
Copy after login

这里有一个-with-apxs2=/usr/local/httpd/bin/apxs选项,其中apxs是在安装Apache时产生的,apxs是一个为Apache HTTP服务器编译和安装扩展模块的工具,使之可以用由mod_so提供的LoadModule指令在运行时加载到Apache服务器中。通过这个工具把PHP模块动态加载到Apache中


拷贝配置文件

cp ~/php-5.3.16/php.ini-development  /usr/local/php/lib/php.ini
Copy after login

修改apache配置文件

编辑 /usr/local/httpd/conf/httpd.conf 文件
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:

AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .php5 
Copy after login

找到:


DirectoryIndex index.html

添加:

DirectoryIndex index.html index.php

重启apache

sudo apachectl restart
Copy after login

验证

在/usr/local/httpd/php/htdocs下新建info.php文件

<?php    phpinfo();?>
Copy after login

在浏览器中输入:ip/info.php,观察到如下内容,说明安装成功。



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template