window xp,win7 apache2.2静态HTML服务器安装与反向代理设置方法

昨天深夜在大神的指导下终于启动了apache,步骤如下。

安装

1.去官网下载apache2.2 httpd-2.2.19-win32-x86-no_ssl.msi 安装包。

2.执行安装文件,一路下去到结束即可安装完毕。

3.查看管理工具-服务中是否有apache2.2,默认是启动状态。



配置工程

1.进入apache安装目录,查找conf文件夹内httpd.conf并打开

2. 46行 Listen 80 ,apache默认80端口

3.179行 DocumentRoot "D:/Apache2.2/htdocs" apache启动后会自动查找htdocs下的index.html或者jsp等。优先html。可将这里改成你自己的项目根目录。

4.重新启动apache。


httpd.conf中配置多个端口
如:#Listen 12.34.56.78:80后添加
Listen 81
Listen 82
Listen 83
解锁 Include conf/extra/httpd-vhosts.conf  开启多个端口

NameVirtualHost *:81
<VirtualHost *:81>
    ServerAdmin [email protected]
    DocumentRoot "D:/"
    ServerName dummy-host2.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>
NameVirtualHost *:82
<VirtualHost *:82>
    ServerAdmin [email protected]
    DocumentRoot "E:/"
    ServerName dummy-host2.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>
NameVirtualHost *:83
<VirtualHost *:83>
    ServerAdmin [email protected]
    DocumentRoot "F:/"
    ServerName dummy-host2.localhost
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>


配置反向代理

1.解锁httpd.conf中 110-117 去掉#就行

2.打开extra目下httpd-vhosts.conf文件

3.修改如下

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/Workspace/project"
    ServerName dummy-host.localhost
    ServerAlias www.dummy-host.localhost
    ErrorLog "logs/dummy-host.localhost-error.log"
    CustomLog "logs/dummy-host.localhost-access.log" common
    <Directory "D:/JerryWorkspace/HNWebUI">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ProxyPass /src/admin http://localhost:8080/projectTOMCAT  #需要代理的工程
    ProxyPassReverse /src/admin http://localhost:8080/projectTOMCAT #需要代理的工程
    ProxyPassReverseCookiePath /projectTOMCAT /
   #需要代理的工程 后面有个空格啊
</VirtualHost>

5.重启apache 并启动对应的tomcat工程。

6.如果apache启动失败

#检查apache启动具体哪里出了错误,进入apache的bin目录下执行
C:\Program Files\Apache Software Foundation\Apache2.2\bin>httpd.exe -w -n "Apach
e2" -k start








你可能感兴趣的:(window xp,win7 apache2.2静态HTML服务器安装与反向代理设置方法)