(本文出自yangjj ^_^)
======关于APACHE安装和配置======
--离线包解压并进入解压后文件夹
tar -zvxf httpd-2.2.25.tar
cd httpd-2.2.25
./configure \
--enable-mods-shared=max \
--enable-module=most \
--with-mpm=prefork \
--enable-ext-filter \
--enable-file-cache \
--enable-suexec \
--enable-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-file-cache \
--enable-suexec \
--enable-ext-filter \
--enable-so \
--enable-headers \
--enable-rewrite \
--enable-proxy \
--enable-proxy-connect \
--enable-proxy-http \
--enable-proxy-balancer
--这里配置apache代理和反向代理不用这个也成
--enable-deflate \
--报错 error: mod_deflate has been requested but can not be built due to prerequisite failures,那是没有安装zlib包
yum install zlib-deve
--不指定路径默认在/usr/local/apache2
--指定路径加参数 --prefix=/usr/local/^$&#你特立独行的路径/
--如果configure失败又手贱make,可能导致make失败,最好
make clean
ldconfig
--重新configure成功后再make
make
make install
--完成之后在/usr/local/apache2/bin下
./httpd -l
--查看httpd的模块
Compiled in modules:
core.c
mod_authn_file.c
mod_authn_default.c
mod_authz_host.c
mod_authz_groupfile.c
mod_authz_user.c
mod_authz_default.c
mod_auth_basic.c
mod_file_cache.c
mod_cache.c
mod_disk_cache.c
mod_mem_cache.c
mod_ext_filter.c
mod_include.c
mod_filter.c
mod_log_config.c
mod_env.c
mod_headers.c
mod_setenvif.c
mod_version.c
mod_proxy.c
mod_proxy_connect.c
mod_proxy_ftp.c
mod_proxy_http.c
mod_proxy_scgi.c
mod_proxy_ajp.c
mod_proxy_balancer.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_suexec.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_so.c
--这几个没有就fuck up了!
service httpd status
--如果报错并且通过
chkconfig --list httpd
--检查不是系统服务
--则添加httpd为系统服务
chkconfig --add httpd
chkconfig httpd on
--如果添加系统服务报错:service httpd does not support chkconfig
--直接用安装的httpd配置覆盖rd.d/init.d的httpd
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
--之后
vi /etc/rc.d/init.d/httpd
--#!/bin/sh后加上
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
--如果apache启动报错(98)Address already in use: make_sock: could not bind to address [::]:80
ps -ef|grep httpd
--或者(前提是你没改过httpd端口)
lsof -i:80
--kill掉
--如果报如下错误
--httpd: apr_sockaddr_info_get() failed for ckstmis-app2
--httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1 for ServerName
vi /usr/local/apache2/conf/httpd.conf
--屁股加上
ServerName localhost:
--最后通过curl访问it works(没有GUI,没有内网可视化远程桌面的苦逼)
======关于APACHE代理和反向代理云云======
--简单的配置修改,针对httpd.conf(/usr/local/apache2,即安装目录下的)
--将apache监听端口改成nat的内网端口
Listen 8080
--屁股增加反向虚拟主机include文件
# Virtual hosts
Include conf/httpd-vhosts.conf
--原配置及说明按需参考
--简单代理配置:
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://mycluster>
ProxySet stickysession=ROUTEID
</Proxy>
--稍复杂反向代理配置
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; " env=BALANCER_ROUTE_CHANGED
<Proxy balancer://cluster名>
Order deny,allow
Allow from all
BalancerMember ajp://ip1:偏移端口 route=节点名称1:工程路径
BalancerMember ajp://ip2:偏移端口 route=节点名称2:工程路径
ProxySet stickysession=ROUTEID
</Proxy>
<VirtualHost *:8080>
Timeout 7200
ProxyRequests Off
ProxyPass /工程路径 balancer://cluster名/工程路径
ProxyPassReverse /工程路径 balancer://cluster名/工程路径/
#反向代理的最后的/ 最好加下,网评不一,加了肯定不会挂
ProxyPreserveHost On
#KeepAliveTimeout 500
#MaxKeepAliveRequests 200
#ProxyPassReverseCookiePath / /
</VirtualHost>