采用的是版本是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();
?>
即可运行正常,显示整个运行环境信息.