Apache2:未加载启用的虚拟主机目录,而是获取默认页面
Apache2: Enabled vhost directory is not loading, getting default page instead
我的 php apache2 站点已配置并准备就绪,但不知何故我一直在获取默认页面。
sworup@sandwitchslayer:/etc/apache2/sites-enabled$ ls -l
total 0
lrwxrwxrwx 1 root root 34 Sep 17 00:38 sworup.com.conf -> ../sites-available/sworup.com.conf
sworup@sandwitchslayer:/etc/apache2/sites-enabled$ cat sworup.com.conf
<VirtualHost *:80>
ServerName sworup.com.np
ServerAlias sworup.com.np
ServerAdmin sworup@sworup.com.np
DocumentRoot /home/sworup/Code/sworup.com/current/public
<Directory /home/sworup/Code/sworup.com/current/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
好的,编辑您的 conf 文件并将端口更改回 *:80。删除新的监听线。
然后编辑您的“000-default.conf”文件(应该在已启用站点中)并删除对 sworup.com.np 的所有引用。只有你的 sworop.com.conf 虚拟主机文件应该列出它。
重新启动apache,你应该可以开始了。请记住遵循所有这些步骤。我要去睡觉了,如果这不起作用(我相信它会起作用),那么明天我会再次尝试提供帮助。
[在此处插入时区适当的时间段]祝你玩得愉快。
只是根据您在这里和 the chats 中的评论和对话列出问题。
禁用默认的 apache2 虚拟主机!
sudo a2dissite 000-default.conf
- 检查您的 Apache 的根服务器配置并注释掉那里的
DocumentRoot
指令。
- 在您的 VHost 配置中使用
VHostUser
指令,因为您从另一个用户的帐户提供文件,may/may 未授予 www-data
用户访问权限。
- 我还建议将日志文件从默认更改为与您的 chost/domain 本身相似的名称。那样检查它们更容易 ;-)
- 将服务器的监听端口改回80,最终的VHost配置应该如下
<VirtualHost *:80>
ServerName sworup.com.np
ServerAlias sworup.com.np
VHostUser sworup
VHostGroup sworup
ServerAdmin sworup@sworup.com.np
DocumentRoot /home/sworup/Code/sworup.com/current/public
<Directory /home/sworup/Code/sworup.com/current/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/sworup.com.np-error.log
CustomLog ${APACHE_LOG_DIR}/sworup.com.np-access.log combined
</VirtualHost>
我的 php apache2 站点已配置并准备就绪,但不知何故我一直在获取默认页面。
sworup@sandwitchslayer:/etc/apache2/sites-enabled$ ls -l
total 0
lrwxrwxrwx 1 root root 34 Sep 17 00:38 sworup.com.conf -> ../sites-available/sworup.com.conf
sworup@sandwitchslayer:/etc/apache2/sites-enabled$ cat sworup.com.conf
<VirtualHost *:80>
ServerName sworup.com.np
ServerAlias sworup.com.np
ServerAdmin sworup@sworup.com.np
DocumentRoot /home/sworup/Code/sworup.com/current/public
<Directory /home/sworup/Code/sworup.com/current/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
好的,编辑您的 conf 文件并将端口更改回 *:80。删除新的监听线。
然后编辑您的“000-default.conf”文件(应该在已启用站点中)并删除对 sworup.com.np 的所有引用。只有你的 sworop.com.conf 虚拟主机文件应该列出它。
重新启动apache,你应该可以开始了。请记住遵循所有这些步骤。我要去睡觉了,如果这不起作用(我相信它会起作用),那么明天我会再次尝试提供帮助。
[在此处插入时区适当的时间段]祝你玩得愉快。
只是根据您在这里和 the chats 中的评论和对话列出问题。
禁用默认的 apache2 虚拟主机!
sudo a2dissite 000-default.conf
- 检查您的 Apache 的根服务器配置并注释掉那里的
DocumentRoot
指令。 - 在您的 VHost 配置中使用
VHostUser
指令,因为您从另一个用户的帐户提供文件,may/may 未授予www-data
用户访问权限。 - 我还建议将日志文件从默认更改为与您的 chost/domain 本身相似的名称。那样检查它们更容易 ;-)
- 将服务器的监听端口改回80,最终的VHost配置应该如下
<VirtualHost *:80>
ServerName sworup.com.np
ServerAlias sworup.com.np
VHostUser sworup
VHostGroup sworup
ServerAdmin sworup@sworup.com.np
DocumentRoot /home/sworup/Code/sworup.com/current/public
<Directory /home/sworup/Code/sworup.com/current/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/sworup.com.np-error.log
CustomLog ${APACHE_LOG_DIR}/sworup.com.np-access.log combined
</VirtualHost>