Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

php - how to configure apache 2.4 and laravel 8 in debian 10(buster)

i need to configure: laravel 8 php 7.4 apache 2.4 debian 10 (buster)

when i create a new project "laravel new project", i run this command, php artisan serve and all works ok, but when I configure a virtual host something goes wrong, the browser says

http://develop.test

   <?php

use IlluminateContractsHttpKernel;
use IlluminateHttpRequest;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
    require __DIR__.'/../storage/framework/maintenance.php';
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = tap($kernel->handle(
    $request = Request::capture()
))->send();

$kernel->terminate($request, $response); 

and the aplication is not in maintenance mode, i never run command like php artisan down. with that problem i try to run php artisan down and next php artisan up, but nothing happen, the error is always there.

here is my apache conf file

 <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName develop.test
    ServerAlias www.develop.test
    DocumentRoot /var/www/html/develop/public


    <Directory /var/www/html/develop/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        ReWriteEngine On
        Require all granted
        <FilesMatch .php$>
            # Change this "proxy:unix:/path/to/fpm.socket"
            # if using a Unix socket
            # SetHandler "proxy:fcgi://127.0.0.1:9000"
        </FilesMatch>
        
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/develop-error.log
    CustomLog ${APACHE_LOG_DIR}/develop-access.log combined

</VirtualHost>

I followed this article for this conf file Setting document root for Laravel project on Apache virtual host


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...