![Apache 服务器不为除默认网站之外的任何网站提供服务](https://linux22.com/image/1181075/Apache%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8D%E4%B8%BA%E9%99%A4%E9%BB%98%E8%AE%A4%E7%BD%91%E7%AB%99%E4%B9%8B%E5%A4%96%E7%9A%84%E4%BB%BB%E4%BD%95%E7%BD%91%E7%AB%99%E6%8F%90%E4%BE%9B%E6%9C%8D%E5%8A%A1.png)
你好,我是 Apache 新手,想学习如何托管多个网站。
我有 2 个域名www.daily-updates.ga
和www.prudent-solutions.co.in
一个安装了 ubuntu 18.04 和 Apache2 的 VPS 服务器。当我从其他 PC 访问我的服务器的 IP 时,我能够看到 Apache 的默认页面。
下一步,我在 中创建了 2 个测试网站和 2 个目录/var/www
。我还复制了默认配置文件并更改了ServerName, ServerAlias, DocumentRoot
两个网站的 。
每日更新.ga.conf:
<VirtualHost *:80>
ServerName daily-updates.ga
ServerAlias www.daily-updates.ga
DocumentRoot /var/www/daily-updates.ga/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
prudent-solutions.co.in:
<VirtualHost *:80>
ServerName prudent-solutions.co.in
ServerAlias www.prudent-solutions.co.in
DocumentRoot /var/www/prudent-solutions.co.in/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
apache2.conf
# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf.d
# | `-- *
# Global configuration
PidFile ${APACHE_PID_FILE}
Timeout 30
KeepAlive Off
MaxKeepAliveRequests 300
KeepAliveTimeout 10
<IfModule mpm_prefork_module>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 200
MaxRequestsPerChild 4000
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 200
MaxRequestsPerChild 4000
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 200
MaxRequestsPerChild 4000
</IfModule>
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#User www-data
#Group www-data
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
DefaultType None
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf
# Include list of ports to listen on and which to use for name based vhosts
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%b" bytes
Include conf.d/
# Include the virtual host configurations:
#Include sites-enabled/
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/50x.html
ErrorDocument 501 /error/50x.html
ErrorDocument 502 /error/50x.html
ErrorDocument 503 /error/50x.html
ErrorDocument 506 /error/50x.html
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/prudent-solutions.co.in>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
然后我通过a2ensite
命令启用了它们
我很确定我的 DNS 记录是完美的,并且指向我的服务器的 IP 地址。但是,当我转到www.daily-updates.ga
或时,www.prudent-solutions.co.in
我仍然只看到 Apache2 默认页面
截屏www.prudent-solutions.co.in
:
默认页面截图
同样,当我访问时,www.daily-updates.ga
我得到的是相同的页面。
我做错了什么?为什么我看不到正确的网站?我知道 conf 文件中有错误,但无法弄清楚
请帮忙 !!!