【问题标题】:Virtual host showing contents of file instead of serving the app虚拟主机显示文件内容而不是为应用程序提供服务
【发布时间】:2023-04-03 21:04:01
【问题描述】:

我有一个Laravel 应用程序,我正在尝试为其创建一个virtual host。这是.conf 文件:

 <VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName todo-app.test
    ServerAlias www.todo-app.test
    DocumentRoot /var/www/html/vuejs/todo-laravel/public

    <Directory "/var/www/html/vuejs/todo-laravel">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
            RewriteEngine On
    </Directory>

    LogLevel debug
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是hosts 文件:

127.0.0.1       localhost
127.0.1.1       titan
127.0.0.1       todo-app.test

当我在浏览器中访问应用程序时,我会得到 index.php 文件的内容,而不是启动应用程序。这里出了什么问题?

我在Laravel 8.40Ubuntu 18.04

编辑: 当我做php artisan serve 时,它适用于这个地址,todo-app.test:8000,但我不想要这里的端口。怎么办?

【问题讨论】:

    标签: php ubuntu apache2 virtualhost laravel-8


    【解决方案1】:

    是否有任何 PHP 可用于 Apache 服务器?一般出现这种情况是因为没有安装PHP模块。

    试试这个:

    sudo apt install libapache2-mod-php
    

    您需要在安装后重新启动 Apache 以确保正确应用该模块:

    sudo service apache2 restart
    

    【讨论】:

    • 那么,我建议您挖掘一下您的日志。我的精神力量几乎不存在,这让我很难从这里管理你的服务器。
    猜你喜欢
    • 2018-06-03
    • 2017-11-17
    • 1970-01-01
    • 2018-09-08
    • 1970-01-01
    • 2017-06-24
    • 2019-07-11
    • 1970-01-01
    • 2016-10-12
    相关资源
    最近更新 更多