CentOS源码安装Apache+php

#安装需要的库
yum -y install zlib-devel

cp /home/root/httpd-2.2.17.tar.gz /usr/local/src
cd /usr/local/src
tar xzvf httpd-2.2.17.tar.gz

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-so --enable-rewrite

make
make install
#启动apache
/usr/local/apache2/bin/apachectl start
#若出现notice如httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
vi /usr/local/apache2/conf/httpd.conf
修改ServerName那行为:ServerName localhost:80
/usr/local/apache2/bin/apachectl restart
 
#安装PHP

#先安装需要的库
yum -y install libxml2
yum -y install libxml2-devel
yum -y install gd
yum -y install gd-devel
yum -y install curl curl-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel
yum -y install freetype freetype-devel
yum -y install openldap
yum -y install openldap-devel
cp /home/root/php-5.2.17.tar.gz /usr/local/src
cd /usr/local/src
tar xzvf php-5.2.17.tar.gz
./configure --prefix=/usr/local/php5 \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/local/lib \
--with-gd \
--with-jpeg-dir=/usr/local/jpeg6 \
--with-zlib \
--with-curl \
--with-ldap \
--with-gettext \
--with-iconv \
--enable-mbstring \
--enable-soap \
--with-png-dir=/usr/local/libpng2 \
--with-freetype-dir=/usr/local/freetype \
--with-xmlrpc \
--with-config-file-path=/usr/local/php5/etc
make
make install
cp /usr/local/src/php.ini-dist /usr/local/php5/etc/php.ini
 
配置
 
vi /usr/local/apache2/conf/httpd.conf
#DirectoryIndex index.html后增加index.php
DirectoryIndex index.html index.php
#<IfModule mime_module>中增加:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
/usr/local/apache2/bin/apachectl restart
#若遇到错误如:/usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
#解决办法:
setenforce 0
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so
/usr/local/apache2/bin/apachectl restart
setenforce 1
/usr/local/apache2/bin/apachectl restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值