Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:apache

Apache(A Patchy Server)

配置

/etc/apache2/
├── apache2.conf # 基本配置
├── conf.d       # 扩展配置, 如 security, 另外一些程序(比如 nagios3) 也把配置放在此目录
├── envvars      # 默认环境变量, 如用户, 组等
├── ports.conf   # 端口
├── httpd.conf   # 一个空文件
├── magic        # Magic data for mod_mime_magic ??
├── mods-available  # 可用模块
├── mods-enabled    # 激活模块
├── sites-available # 可用站点
└── sites-enabled   # 激活站点
    └── 000-default -> ../sites-available/default  # 默认站点(/var/www/)

macOS 自带 apache,有时候做测试用 apache 比较方便

Proxy

<VirtualHost rx.b.test:80>
    ProxyPreserveHost On
 
    # Servers to proxy the connection, or;
    # List of application servers:
    # Usage:
    # ProxyPass / http://[IP Addr.]:[port]/
    # ProxyPassReverse / http://[IP Addr.]:[port]/
    # Example:
    ProxyPass / http://0.0.0.0:3002/
    ProxyPassReverse / http://0.0.0.0:3002/
 
    ServerName localhost
</VirtualHost>

VirtualHost 虚拟主机

绑定端口

$ vi ports.conf
NameVirtualHost *:8080 # 虚拟主机名
Listen 8080            # 对此虚拟主机监听端口
# ...针对每个虚拟主机都需有一条
NameVirtualHost *:3000
Listen 3000
 
 
$ vi sites-enabled/000-default
<VirtualHost *:8080>   # 修改虚拟主机名与 ports.conf 符合
...
</VirtualHost>
 
$ vi sites-enabled/001-puppetdashboard
<VirtualHost *:3000>
...
</VirtualHost>

开启 mod_rewrite, 并启用 .htaccess 重载

$ ln -s ../mods-available/rewrite.load .
$ vi sites-enabled/000-default # AllowOverride All
it/apache.txt · Last modified: 2016/10/15 17:09 by admin