標籤:
1,安裝
yum install zlib zlib-devel -ytar 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-rewritemake && make installln -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-rewritemake &&make installln -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
虛擬機器主機配置
[[email protected] 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} -ptouch /var/html/{www,blog,bbs}/index.htmlfor i in www bbs blog;do echo "$i.lanny.com" > /var/html/$i/index.html;donefor i in www bbs blog;do cat /var/html/$i/index.html;done
strace命令:追蹤cpu為什麼很高.(一般是程式bug,有死迴圈等.)
strace /application/apache/bin/apachectl –M
apache編譯安裝