标签:
1,安装
yum install zlib zlib-devel -y tar xf httpd-2.2.27.tar.gz cd httpd-2.2.27 ./configure --prefix=/application/apache2.2.27 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make && make install ln -s /application/apache2.2.27/ /application/apache ./configure --prefix=/application/apache2.2.27 --enable-deflate \ #压缩 --enable-expires \ #超时 --enable-headers \ #http头 --enable-modules=most --enable-so --with-mpm=worker \ #apache两种模式,worker:进程下派线程,perform:进程提供服务 --enable-rewrite make &&make install ln -s /application/apache2.2.27/ /application/apache
检查语法并启动
/application/apache/bin/apachectl -t
/application/apache/bin/apachectl start
主配置文件
DocumentRoot "/application/apache2.2.27/htdocs" ...
#打开vhost配置 Include conf/extra/httpd-vhosts.conf ...
Include conf/extra/httpd-mpm.conf #默认perfork模式,如果打开mpm就是worker模式
#防止启动时候报错fqdn错 ServerName 127.0.0.1 :80
虚拟主机配置
[root@httpd extra]# vim httpd-vhosts.conf
#虚拟主机支持,必须打开 NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin 781647046@qq.com DocumentRoot "/var/html/www" ServerName www.lanny.com ServerAlias www.ma.com ErrorLog "logs/www-error_log" CustomLog "logs/www-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin 781647046@qq.com DocumentRoot "/var/html/blog" ServerName blog.lanny.com ServerAlias blog.ma.com ErrorLog "logs/blog-error_log" CustomLog "logs/blog-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin 781647046@qq.com DocumentRoot "/var/html/bbs" ServerName bbs.lanny.com ServerAlias bbs.ma.com ErrorLog "logs/bbs-error_log" CustomLog "logs/bbs-access_log" common </VirtualHost> 严重注意:如果不加NameVirtualHost *:80如下会报错.
虚拟主机403错误:
修改后追加到httpd.conf <Directory "/var/html"> AllowOverride None Options None Order allow,deny Allow from all </Directory>
如果index.html或者访问的文件不存在也会报403错误
mkdir /var/html/{www,blog,bbs} -p touch /var/html/{www,blog,bbs}/index.html for i in www bbs blog;do echo "$i.lanny.com" > /var/html/$i/index.html;done for i in www bbs blog;do cat /var/html/$i/index.html;done
strace命令:追踪cpu为什么很高.(一般是程序bug,有死循环等.)
strace /application/apache/bin/apachectl –M
标签:
原文地址:http://www.cnblogs.com/iiiiher/p/5700038.html