注意:安装包所在目录在/usr/local目录下 步骤一:安装Apache
1,首先安装apr
cd /usr/local
tar xf apr-1.5.1.tar.bz2
cd apr-1.5.1
./configure --prefix=/usr/local/apr
make
make install
2,安装apr-util
tar xf apr-util-1.5.4.tar.bz2
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
3,安装httpd
tar xf httpd-2.4.10.tar.bz2
cd httpd-2.4.10
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
出现错误configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
解决办法:yum install -y pcre-devel
make
make install
cd /usr/local/apache
bin/apachectl start 启动httpd,可看到logs目录下生成的httpd.pid文件。
bin/apachectl stop
打开/etc/httpd/httpd.conf文件,加入PidFile "/var/run/httpd.pid",httpd进程启动时生成的Pidfile默认在/usr/local/apache/logs目录下,将此文件放日志目录下显然不合理。
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
chmod +x /etc/init.d/httpd 给予执行权限
service httpd start
chkconfig --add httpd 加入服务列表
chkconfig httpd on
echo "PATH=$PATH:/usr/local/apache/bin" > /etc/profile.d/httpd.sh 添加PATH路径
su
此处用的mysql软件包是二进制免编译包。
unzip openlogic-mysql-5.6.10-linux-ia32-bin-glibc2.5-1.zip
ln -sv /usr/local/mysql-5.6.10/mysql-5.6.10-linux-glibc2.5-i686/ mysql
cd mysql
cd /usr/local/apache/htdocs/
mv index.html index.php
vim index.php 测试php与mysql的连接性,apache与mysql的连接性。
<html><body><h1>It works!</h1></body></html>
<?php
$conn=mysql_connect('127.0.0.1','root','');
if ($conn)
echo "Success";
else
echo "Failure";
phpinfo();
?>
浏览器输入服务器ip地址, 输出Success成功。
至此php安装成功,接下来安装xcache。
步骤4:编译安装xcache
tar xf xcache-3.2.0.tar.gz
cd xcache-3.2.0
/usr/local/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
make
make install
mkdir /etc/php.d
cp xcache.ini /etc/php.d
service httpd restart
浏览器输入ip,可看到xcache相关信息。
步骤5:使用discuz论坛测试
vim /etc/httpd/httpd.conf
注释掉/DocumentRoot "/usr/local/apache/htdocs"
取消Include /etc/httpd/extra/httpd-vhosts.conf的注释
# Virtual hosts
Include /etc/httpd/extra/httpd-vhosts.conf
vim /etc/httpd/extra/httpd-vhosts.conf