php - 尝试访问本地 LAMP 服务器上的 localhost 时出现 404 Not Found 错误

标签 php apache ubuntu http-status-code-404 lamp

我正在运行 Ubuntu。我的 Apache2 默认文件如下所示:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

我在/var/www/中有一个名为 Index.php 的文件

<?
phpinfo();
?>

当我访问 http://localhost/ 时在我的浏览器中,我收到 404 Not Found 错误:

在此服务器上找不到请求的 URL/。 Apache/2.2.16 (Ubuntu) 服务器在 localhost 端口 80

我做错了什么?这在我第一次设置 LAMP 时确实有效,但现在不起作用。

最佳答案

查看/etc/apache2/sites-enabled。似乎我升级到 10.10 已经从该目录中删除了符号链接(symbolic link)。尝试将默认符号链接(symbolic link)到/etc/apache2/sites-available/default

sudo ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/default

关于php - 尝试访问本地 LAMP 服务器上的 localhost 时出现 404 Not Found 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4060034/

相关文章:

javascript - CodeIgniter ajax 上传图片(ajax 有效,而不是 CodeIgniter)

phpDocumentor ubuntu 安装

php - 我必须编写什么代码才能使用 HTTPS?

c - Ruby sqlite3 gem 无法在 WSL 上编译

ruby-on-rails - 安装 Ruby - Digital Ocean - RVM - 不稳定的 ruby​​ 版本 - 无法安装 Gems

PHP 数组...空括号的含义是什么?

apache - 如何从 nextcloud docker 容器获取更详细的日志

apache - htaccess 重写 index.php 并在没有 www 的情况下重定向

apache - 如何使用 Apache Commons Codec 在 Java 中解码 JWT( header 和正文)?

ubuntu - Nginx 错误未写入我的 error_log 指令