apache服务 搭建及配置

1:从Apache官网下载Apache,http://httpd.apache.org/

2:命令行进入到Apache 的bin目录下面,输入 httpd -k install(注意:这里cmd要以管理员身份进入,否则执行安装的时候会报错)

3:start Apache by typing:httpd -k start

                   Other Command line options:

                   Stop Apache   httpd -k stop

                   Restart Apache httpd -k restart

                   Uninstall Apache Service httpd -k uninstall

                   Test Config Syntax httpd -t

                   Version Details httpd -V

                   Command Line Options List httpd -h

4:安装成功后开始配置httpd.conf文件。

使用代理和反代理

                 将LoadModule proxy_module modules/mod_proxy.so

                 proxy_connect_module modules/mod_proxy_connect.so

                 LoadModule proxy_http_module modules/mod_proxy_http.so

                 LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

设置为启用。

5:配置DocumentRoot

6:添加配置

     # 加载 mod_jk 模块

LoadModule jk_module modules/mod_jk.so

    # 指定 mod_jk 模块所需的配置文件 workers.properties 的位置 

JkWorkersFile conf/workers.properties

7:配置虚拟主机:VirtualHost

        <VirtualHost *:80>

  DocumentRoot E:/httpd-2.4.16-x64/ZYTPlatform/www/newwebsite/

ServerName 172.31.60.117

ErrorLog logs/beta.jointem.com-error_log

CustomLog logs/beta.jointem.com-access_log common

  #设置代理和反代理

  #此时若在浏览器中访问时,/cms会映射到http://172.31.60.117:8080/cms,apache最主要 #功能也就是处理请求负载。

  ProxyPass /cms  http://172.31.60.117:8080/cms

ProxyPassReverse /cms  http://172.31.60.117:8080/cms

 

  ProxyPass /cms_inf  http://172.31.60.117:8080/CMS_INF

ProxyPassReverse /cms_inf  http://172.31.60.117:8080/CMS_INF

 

  ProxyPass /qrs http://172.31.60.117:8080/qrs

ProxyPassReverse /qrs http://172.31.60.117:8080/qrs

 

  ProxyPass /zyt  http://172.31.60.117:8080/zyt

ProxyPassReverse /zyt  http://172.31.60.117:8080/zyt

 

#访问静态资源

 Alias /data  E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/data/

<Directory "E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/data/">

Options None

AllowOverride All

Require all granted

</Directory>

 

    Alias /site  E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/site/

<Directory "E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/site/">

Options None

AllowOverride All

Require all granted

</Directory>

 

    Alias /img  E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/img

<Directory "E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/img">

Options None

AllowOverride All

Require all granted

</Directory>

 

    Alias /tplzip  E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/tplzip/

    <Directory "E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/tplzip/">

Options None

AllowOverride All

Require all granted

</Directory>

 

    Alias /qrcode  E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/qrs/qrcode/

<Directory "E:/httpd-2.4.16-x64/ZYTPlatform/zyb/cms/qrs/qrcode/">

Options None

AllowOverride All

Require all granted

</Directory>        

</VirtualHost>

相关推荐