Apache与PHP安装配置

采用的是版本是httpd-2.2.23.tar.gz编译安装的
tar -zxvf httpd-2.2.23.tar.gz
cd httpd-2.2.23
#其他采用默认的配置参数
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/conf --enable-modules=so
make
make install 

常会遇到缺失包出现编译错误configure: error: APR-util not found.  Please read the documentation

                                                    configure:pcre-config for libpcre not found

apr-*.tar.gz
apr-util-*.tar.gz   apache跨平台运行环境的基础库
pcre-*.tar.gz       Perl Compatible Regular Expressions 包括perl兼容的正规表达式库

./configure --prefix=/usr/local/apr; 
 make;
 make install

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr;
 make;
 make install

./configure --prefix=/usr/local/pcre;
 make;
 make install
 
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/conf --enable-modules=so
            --with-apr=/usr/local/apr 
            --with-apr-util=/usr/local/apr-util  
            --with-pcre=/usr/local/pcre
make;
make install 

/usr/local/apache/bin/apachectl start
浏览器中键入安装的IP地址,就会看见It works! 

安装好apache httpd,再来安装php,采用的是php-5.3.20.tar.gz版本

#编译安装
./configure --prefix=/usr/local/php5
            --enable-mbstring 
            --with-apxs2=/usr/local/apache/bin/apxs 
            --with-config-file-path=/usr/local/php5/etc
make
make install

配置php.ini

cp php.ini-production /usr/local/php5/etc/php.ini
vi php.ini

register-golbals = On 
配置httpd.conf

vi /etc/httpd/conf/httpd.conf

DirectoryIndex index.html index.php  
AddType application/x-httpd-php .php .phtml .php3 .inc  
AddType application/x-httpd-php-source .phps  

启动httpd服务时 /usr/local/apache/bin/apachetl start时报错:

Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so:

cannot restore segment prot after reloc: Permission denie

由SELinux保护模式引起的

#  setenforce 0

之后再重启启动,并测试test.php

<?php
    phpinfo();
?>

即可运行正常,显示整个运行环境信息.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值