2013-10-01 08:32:01
来 源
kejihao
Nginx
这里分享一下CentOS系统编译安装httpd-2.2.17、PHP-5.3.4的memcache扩展详细,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。

Apache是世界使用排名第一的Web服务器软件。同时也是最稳定、安全的服务器之一。

yum install zlib zlib-devel -y

yum install opensll openssl-devel -y

groupadd -g 1000 vgroup

useradd -u 1000 -g vgroup -d /dev/null -s /bin/false vuser

wget http://labs.xiaonei.com/apache-mirror/httpd/httpd-2.2.17.tar.bz2

tar xfj httpd-2.2.17.tar.bz2 -C /usr/local/src/

cd /usr/local/src/httpd-2.2.17

make clean

CHOST="x86_64-pc-linux-gnu"

CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

./configure –prefix=/usr/local/httpd

–with-mpm=worker

–enable-expires –enable-headers –enable-rewrite  –enable-deflate –enable-vhost-alias

–enable-so

–enable-ssl

–enable-cache –enable-file-cache –enable-mem-cache –enable-disk-cache –enable-static-support –enable-static-htpasswd –enable-static-htdigest –enable-static-rotatelogs –enable-static-logresolve –enable-static-htdbm –enable-static-ab –enable-static-checkgid –disable-userdir

–enable-suexec –with-suexec-caller=vuser –with-suexec-logfile=/var/log/httpd/suexec.log –with-suexec-docroot=/usr/local/www –with-suexec-uidmin=500 –with-suexec-gidmin=100

对于32位系统:

CHOST="i686-pc-linux-gnu"

相对来说,prefork方式速度要稍高于worker,然而它需要的cpu和memory资源也稍多于woker。

–enable-module=most –enable-proxy –enable-proxy-ajp –enable-forward –enable-proxy-connect –enable-proxy-http –enable-so –enable-deflate –enable-headers –enable-include

上面的配置,用到了其他一些模块,说不定以后会用到,如支持ssi的include模块

error: APR version 1.2.0 or later is required

yum install apr

或者

http://apr.apache.org/download.cgi

apr-1.2.8.tar.bz2

apr-util-1.2.8.tar.bz2

./configure

./configure –with-apr=/usr/local/apr/

–with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr/

设置自启动

[ -f /etc/init.d/httpd ] || cp support/apachectl /etc/init.d/httpd

#apachectl=/usr/local/httpd/bin/apachectl

#httpd=${HTTPD-/usr/local/httpd/bin/httpd}

vim /etc/init.d/httpd

# vi /etc/init.d/httpd(在第两行之后添加如下内容)

#!/bin/sh

#

# Startup script for the Apache Web Server

# chkconfig: – 85 15

# description: Apache is a World Wide Web server. It is used to serve

# HTML files and CGI.

# processname: httpd

# pidfile: /usr/local/httpd/log/httpd.pid

# config: /usr/local/httpd/conf/httpd.conf

或者

sed -i 's%apachectl=/usr/sbin/apachectl%apachectl=/usr/local/httpd/bin/apachectl%' /etc/init.d/httpd

sed -i 's%httpd=${HTTPD-/usr/sbin/httpd}%httpd=${HTTPD-/usr/local/httpd/bin/httpd}%' /etc/init.d/httpd

cd /usr/local/httpd/conf/

sed -i 's%#Include conf/extra/httpd-default.conf%Include conf/extra/httpd-default.conf%' httpd.conf

sed -i 's/ServerTokens Full/ServerTokens Prod/' extra/httpd-default.conf

sed -i 's/ServerSignature On/ServerSignature Off/' extra/httpd-default.conf

chkconfig –add httpd

chmod 755 /etc/init.d/httpd

chkconfig –level 345 httpd on

sed -i '/<IfModule mime_module>/a    AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps'

/usr/local/httpd/conf/httpd.conf

sed -i -e 's/User daemon/User vuser/' -e 's/Group daemon/Group vgroup/'  /usr/local/httpd/conf/httpd.conf

vim   /usr/local/httpd/conf/httpd.conf

/usr/local/httpd/bin/apachectl graceful

php5安装

yum install curl-devel -y

yum install libxml2-devel -y

yum install gettext-devel -y

yum install libjpeg-devel -y

yum install libpng-devel -y

yum install freetype-devel -y

yum install gmp-devel -y

yum install libmcrypt-devel -y

yum install  libtool-ltdl-devel -y

yum install libevent-devel -y

yum install libtidy-devel -y

yum install libtool-ltdl libtool -y

#/usr/bin/ld: cannot find -lltdl

#ldconfig -p |grep ltdl

#yum install libtool-ltdl.x86_64 libtool.x86_64 -y

wget http://cn.php.net/get/php-5.3.4.tar.bz2/from/ca.php.net/mirror

cd /mnt/backup/soft/

tar xfj php-5.3.4.tar.bz2 -C /usr/local/src

cd /usr/local/src/php-5.3.4

make clean

export PATH=$PATH:/usr/local/mysql/bin

#no fpm

#config file locate apache directory –with-config-file-path=/usr/local/httpd/conf

make clean

./configure –with-apxs2=/usr/local/httpd/bin/apxs –with-config-file-path=/usr/local/httpd/conf –prefix=/usr/local/php –with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysql=/usr/local/mysql  –with-curl –with-zlib –enable-ftp  –with-mcrypt –enable-inline-optimization –disable-debug

–with-gd –enable-gd-native-ttf –enable-gd-jis-conv –with-iconv-dir= –with-freetype-dir –with-jpeg-dir –with-png-dir

–with-libxml-dir=/usr/local/lib/libxml –enable-xml –enable-exif –enable-soap –enable-zip –with-openssl –enable-mbstring –with-mhash –with-tidy –enable-mbstring –with-pdo-mysql=/usr/local/mysql

–enable-sockets –with-gettext

–enable-sqlite-utf8

make -j6 && make install

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf

You may want to add: /usr/local/php/lib/php to your php.ini include_path

cp php.ini-production /usr/local/httpd/conf/php.ini

/usr/local/php/bin/pecl install memcache

wget http://pecl.php.net/get/memcache-2.2.6.tgz

tar xzf memcache-2.2.6.tgz -C /usr/local/src

cd /usr/local/src/memcache-2.2.6

/usr/local/php/bin/phpize

./configure –with-php-config=/usr/local/php/bin/php-config –with-apxs=/usr/local/apache/bin/apxs –enable-memcache

make && make install

提示:Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20090626/

sed -i '/Dynamic Extensions/a

extension=/usr/local/php/lib/php/extensions/no-debug-zts-20090626/memcache.so' /usr/local/httpd/conf/php.ini

然后修改php.ini

extension_dir = "./"

修改为

extension_dir = "/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613"

并添加一行

extension=memcache.so

sed -i '/Dynamic Extensions/a

extension=/usr/local/php/lib/php/extensions/no-debug-zts-20060613/memcache.so' /usr/local/httpd/conf/php.ini

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。