Chinaunix首页 | 论坛 | 博客
  • 博客访问: 693156
  • 博文数量: 139
  • 博客积分: 7607
  • 博客等级: 少将
  • 技术积分: 1964
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-11 23:43
个人简介

...

文章分类

全部博文(139)

文章存档

2012年(53)

2011年(4)

2010年(29)

2009年(10)

2008年(33)

2007年(10)

分类: LINUX

2012-02-16 14:53:44

1. 最小化安装 centos 5.6

2. 编译环境前提
# yum -y install gcc gcc-c++ make openssl-devel
# groupadd -g 80 www
# useradd -u 80 -g www -M -s /sbin/nologin www

3. WEB服务端安装

a. apache服务端安装
# wget
# tar zxvf httpd-2.2.17.tar.gz
# cd httpd-2.2.17
# ./configure –prefix=/usr/local/httpd –enable-so –enable-modules=so –enable-rewrite –enable-deflate –enable-ssl
# make && make install

参数说明:
–prefix=/usr/local/httpd //apache安装目录
–enable-so //支持so模块
–enable-module=so //打开so模块,so模块是用来提dso支持的apache核心模块
–enable-rewrite //支持伪静态
–enable-ssl //支持ssl
–enable-deflate //支持网页压缩

其他参数:
–enable-cache //支持缓存
–enable-file-cache //支持文件缓存
–enable-mem-cache //支持内存缓存
–enable-disk-cache //支持磁盘缓存
–enable-mods-shared=all //动态加载所有模块
–enable-static-support //支持静态连接(默认为动态连接)
–enable-static-htpasswd //使用静态连接编译 htpasswd – 管理用于基本认证的用户文件
–enable-static-htdigest //使用静态连接编译 htdigest – 管理用于摘要认证的用户文件
–enable-static-rotatelogs //使用静态连接编译 rotatelogs – 滚动 apache 日志的管道日志程序
–enable-static-logresolve //使用静态连接编译 logresolve – 解析apache日志中的ip地址为主机名
–enable-static-htdbm //使用静态连接编译 htdbm – 操作 dbm 密码数据库
–enable-static-ab //使用静态连接编译 ab – apache http 服务器性能测试工具
–enable-static-checkgid //使用静态连接编译 checkgid
–enable-mod_cgi //禁止用一个外部 CGI 守护进程执行CGI脚本
–enable-expires=shared //支持缓存
–disable-cgid //禁止用一个外部 cgi 守护进程执行cgi脚本
–disable-cgi //禁止编译cgi版本的php
–disable-userdir //禁止用户从自己的主目录中提供页面
–with-mpm=worker //让apache以worker方式运行
–enable-authn-dbm=shared //对动态数据库进行操作,rewrite时需要

# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
# vi /etc/init.d/httpd 在第二行加入以下两行内容

1# chkconfig: 2345 10 90
2# description: Activates/Deactivates Apache Web Server

# chkconfig –add httpd
# chkconfig –level 2345 httpd on
# chown -R www:www /usr/local/httpd

b. nginx服务端安装

# yum -y install pcre-devel
# wget
# tar zxvf nginx-1.0.2.tar.gz
# cd nginx-1.0.2
# ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_ssl_module –with-http_gzip_static_module –with-http_stub_status_module –with-http_sub_module
# make && make install
# chown -R www:www /usr/local/nginx
# vi /etc/init.d/nginx

001#!/bin/sh
002#
003# nginx - this script starts and stops the nginx daemon
004#
005# chkconfig:   - 85 15
006# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
007#               proxy and IMAP/POP3 proxy server
008# processname: nginx
009# config:      /etc/nginx/nginx.conf
010# config:      /etc/sysconfig/nginx
011# pidfile:     /var/run/nginx.pid
012 
013# Source function library.
014. /etc/rc.d/init.d/functions
015 
016# Source networking configuration.
017. /etc/sysconfig/network
018 
019# Check that networking is up.
020[ "$NETWORKING" = "no" ] && exit 0
021 
022nginx="/usr/local/nginx/sbin/nginx"
023prog=$(basename $nginx)
024 
025NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
026 
027[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
028 
029lockfile=/var/lock/subsys/nginx
030 
031start() {
032    [ -x $nginx ] || exit 5
033    [ -f $NGINX_CONF_FILE ] || exit 6
034    echo -n $"Starting $prog: "
035    daemon $nginx -c $NGINX_CONF_FILE
036    retval=$?
037    echo
038    [ $retval -eq 0 ] && touch $lockfile
039    return $retval
040}
041 
042stop() {
043    echo -n $"Stopping $prog: "
044    killproc $prog -QUIT
045    retval=$?
046    echo
047    [ $retval -eq 0 ] && rm -f $lockfile
048    return $retval
049killall -9 nginx
050}
051 
052restart() {
053    configtest || return $?
054    stop
055    sleep 1
056    start
057}
058 
059reload() {
060    configtest || return $?
061    echo -n $"Reloading $prog: "
062    killproc $nginx -HUP
063RETVAL=$?
064    echo
065}
066 
067force_reload() {
068    restart
069}
070 
071configtest() {
072$nginx -t -c $NGINX_CONF_FILE
073}
074 
075rh_status() {
076    status $prog
077}
078 
079rh_status_q() {
080    rh_status >/dev/null 2>&1
081}
082 
083case "$1" in
084    start)
085        rh_status_q && exit 0
086    $1
087        ;;
088    stop)
089        rh_status_q || exit 0
090        $1
091        ;;
092    restart|configtest)
093        $1
094        ;;
095    reload)
096        rh_status_q || exit 7
097        $1
098        ;;
099    force-reload)
100        force_reload
101        ;;
102    status)
103        rh_status
104        ;;
105    condrestart|try-restart)
106        rh_status_q || exit 0
107            ;;
108    *)   
109      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
110        exit 2
111esac

# chmod 755 /etc/init.d/nginx
# chkconfig –add nginx
# chkconfig –level 2345 nginx on

阅读(1227) | 评论(0) | 转发(0) |
0

上一篇:awk 用法

下一篇:Nginx+Apache配置

给主人留下些什么吧!~~