為什麼伺服器顯示預設 Apache 頁面而不是我的應用程式?

為什麼伺服器顯示預設 Apache 頁面而不是我的應用程式?

我在我的 Ec2 實例上設定了 Php+Mysql 應用程序,但是當我到達網域時,會顯示 Apache 預設頁面。 Bookstack 是我的應用程式。尾部日誌

172.68.50.230 - - [21/Apr/2022:05:26:52 +0000] "GET / HTTP/1.1" 304 2539 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"

我的default.conf輸出cat 000-default.conf

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile /etc/apache2/certs/pizd.pem
    SSLCertificateKeyFile /etc/apache2/certs/pizd.key
</VirtualHost>

我的 bookstack.conf

<VirtualHost *:80>
    ServerName bookstack

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/bookstack/public/

    <Directory /var/www/bookstack/public/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        <IfModule mod_rewrite.c>
            <IfModule mod_negotiation.c>
                Options -MultiViews -Indexes
            </IfModule>

            RewriteEngine On

            # Handle Authorization Header
            RewriteCond %{HTTP:Authorization} .
            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

            # Redirect Trailing Slashes If Not A Folder...
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} (.+)/$
            RewriteRule ^ %1 [L,R=301]

            # Handle Front Controller...
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
    </Directory>

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

我檢查了這個

sudo ls -l /etc/apache2/sites-enabled/
total 4
-rw-r--r-- 1 root root 338 Apr 20 14:20 000-default.conf
lrwxrwxrwx 1 root root  33 Apr 18 09:38 bookstack.conf -> ../sites-available/bookstack.conf

我該嘗試什麼?

答案1

首先,檢查 apache ssl-module 是否已啟用sudo a2enmod ssl

然後將以下行新增到000-default.confDocumentRoot部分之後的右側:

<Directory /var/www/html/bookstack/public/>
Options FollowSymlinks
AllowOverride All
Require all granted</Directory>

相關內容