linux yun php,【只需3步】Linux php的安装与配置[源码安装]

作者小波/QQ463431476欢迎转载!

Linux:redhat 6/centos 6

第一步:安装依赖的包libxml2,libxml2-devel

如果没有安装的话,在安装php过程中会出现如下的错误:

configure: error: xml2-config not found. Please check your libxml2 installation.

所以先用yum安装好依赖的包:

yum install libxml2

yum install libxml2-devel

第二步:下载、解压php安装包,以及php的配置:

下载地址: http://www.php.net/downloads.php

解压安装包:

tar -zxvf +php包

进入解压包文件夹内执行:

./configure --prefix=/work/installed/php --with-apxs2=/work/installed/apache/bin/apxs

其中:--with-apxs2=/work/installed/apache/bin/apxs 是安装完后Apache目录下的这里是我的安装目录地址(视你的情况而定)

然后编译:

make

测试编译:

make test

最后安装:

make install

配置文件:

# root@php-5.3.16/ cp php.ini-development  /work/installed/php/lib/php.ini

把原来位于源代码里面的php.ini-development拷贝到/usr/local/php/lib/php.ini下,并且重命名为php.ini

./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared

./configure --prefix=/work/installed/apache --with-apr=/work/installed/apr --with-apr-util=/work/installed/apr-util --with- pcre=/work/installed/pcre --enable-module=shared

要加上后面的参数,否则无法使用php,-enable-module=shared表示Apache可以动态的加载模块

编辑并配置Apache里面文件

编辑 /work/installed/conf/httpd.conf 文件    (别人有的自定义安装的目录/usr/local/apache/conf/httpd.conf

找到:

AddType  application/x-compress .Z

AddType application/x-gzip .gz .tgz

在后面添加:

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .php5

目的是使Apcche支持PHP

4f6dbff246c35d1489d2f63f90975a16.png

找到:

DirectoryIndex index.html

添加:在index.html后面添加index.php就行啦!(这个在上一个笔记配置Apache中已经写到Apache的配置http://www.cnblogs.com/xiaobo-Linux/p/4637056.html)

DirectoryIndex index.html index.php

重启apache: 在安装的Apache目录下重启:

/work/installed/apache/bin/apachectl restart

第三步测试php:

在发布网页的目录下建立一个文index.php的文件:

默认的是在apache的htdocs下建立一个php文件index.php,里面的内容如下:

phpinfo();

?>

我的发布目录则是在/home/web/下建立 index.php文件

e4af718b37887dea77cae158f67619f7.png

出现如上内容则测试成功!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值