关于指向 /var/www/mySite.com 的新 conf 的基本 Apache2 问题

关于指向 /var/www/mySite.com 的新 conf 的基本 Apache2 问题

我已经使用 conf 文件设置了我的虚拟主机并启用了它,但我想将默认的“Apache2 Ubuntu 默认页面”更改为我自己的 html。

默认指向/var/www/html/index.html 我希望我的 AWS EC2 指向我创建的新 conf。我该怎么做?

并且默认有一个 php 文件而不是 html,这是否需要 .htaccess 文件?

谢谢,巴德。

答案1

您可以编辑 /var/www/html/index.html 文件或编辑您的 conf 以指向您的页面目录。您不需要 .htaccess 文件。请确保重新启动 apache:

## Start command ##
systemctl start apache2.service

## Stop command ##
systemctl stop apache2.service

## Restart command ##
systemctl restart apache2.service

答案2

使用文本编辑器指向您的新配置:

$ sudo nano /etc/apache2/sites-enabled/your_server_domain_or_IP.conf

<VirtualHost *:80>
    . . .
    DocumentRoot /var/www/your_new_dir
    . . .
</VirtualHost>

保存并关闭。现在检查您的配置:

$ sudo apache2ctl configtest

输出应为“syntax OK”。然后重新加载 apache2:

$ sudo systemctl 重新加载 apache2

相关内容