【问题标题】:Access server using Browser and IP instead of DNS使用浏览器和 IP 代替 DNS 访问服务器
【发布时间】:2017-01-30 23:13:34
【问题描述】:

我想在家中使用 Firefox 并输入 IP 而不是 DNS 来访问我的测试站点。

我的服务器是 AWS Ubuntu,它安装了 Mysql、Apache2。

我想在 Firefox 中像这样访问我的测试站点:x.x.x.x/test

但它显示了 404。

当我像这样输入 Firefox 时,它工作正常:x.x.x.x

我不知道怎么做。

这是我在服务器中所做的。

cd /var/www
sudo mkdir test
sudo cp wordpress test/
cd test
sudo mv -R test public
sudo chown -R www-data:www-data public
sudo chmod -R 775 public
cd /etc/apache2/sites-available
sudo cp 000-default.conf test.conf
sudo vim test.conf

这里是 test.conf

<VirtualHost *:80>
    ServerName test
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/test/public
    <Directory /var/www/test/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

命令又来了

sudo a2ensite test.conf
sudo service apache2 restart

现在我转到我的 Firefox 并在地址栏中输入我的 AWS 弹性 IP,如下所示:

x.x.x.x/test

这给了我 404

【问题讨论】:

    标签: linux amazon-web-services ubuntu dns apache2


    【解决方案1】:

    您在文档根目录中犯了一个错误。将您的 Apache 配置更改为以下并重新启动 apache,然后 x.x.x.x/test 它将工作或在您的浏览器中输入此 URL x.x.x.x/test/public

    <VirtualHost *:80>
        ServerName x.x.x.x
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/test
        <Directory /var/www/test>
            AllowOverride All
        </Directory>
    </VirtualHost>
    

    【讨论】:

    • 你在测试目录中有什么文件你有任何名为 index.html 或 index.php 的文件吗?还将 ServerName 更改为您的 IP 地址并重新启动 apache
    • 这是从 wordpress.org 下载的 wordpress 文件的完整副本。它有 index.php
    • 查看我上面的评论
    猜你喜欢
    • 2016-12-22
    • 2012-10-06
    • 2019-07-31
    • 2018-04-01
    • 2017-07-12
    • 2017-03-01
    • 2023-03-11
    • 2020-11-05
    • 1970-01-01
    相关资源
    最近更新 更多