ch3.ng

Apache虚拟主机配置


将这个配置与 Nginx 配置https并反向代理多台服务器一起使用效果更好.肯定要问我为什么不直接用Nginx提供web服务?我能告诉你的是,我喜欢责任分离.

开始

mkdir blog.well-known.me
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
vi /etc/httpd/conf/httpd.conf

跳转到文档末尾添加以下内容

IncludeOptional sites-enabled/*.conf

注释掉# DocumentRoot “/var/www/html”

vi /etc/httpd/sites-available/blog.well-known.me.conf

添加以下内容

<VirtualHost *:8000>
    ServerName blog.well-known.me
    ServerAlias blog.well-known.com
    DocumentRoot /var/www/blog.well-known.me
</VirtualHost>
<Directory "/var/www/blog.well-known.me">
    Options +Includes -Indexes
    AllowOverride All
    Require all granted
</Directory>

ln -s /etc/httpd/sites-available/blog.well-known.me.conf

重启httpd服务,完事儿!