Apache虚拟主机配置
将这个配置与 Nginx 配置https并反向代理多台服务器一起使用效果更好.肯定要问我为什么不直接用Nginx提供web服务?我能告诉你的是,我喜欢责任分离.
开始
- 在 /var/www/ 下创建你网站的目录,比如:
mkdir blog.well-known.me
- 创建Virtual配置目录
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
- 配置httpd.conf
vi /etc/httpd/conf/httpd.conf
跳转到文档末尾添加以下内容
IncludeOptional sites-enabled/*.conf
注释掉# DocumentRoot “/var/www/html”
- 创建网站Virtual配置文件
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服务,完事儿!