php - 实时部署时出现laravel 404错误

jer*_*ams 5 php apache http-status-code-404 laravel

在实时服务器上部署项目时出现 404 错误。我收到了一个 Laravel 页面,说Sorry, the page you are looking for could not be found.我知道它正在到达我的项目。

我运行php artisan config:cachephp artisan route:cache注册了我的路由和缓存,但它仍然没有改变。不太确定为什么我会收到此错误。我的 vhost 中的文档根目录也设置为我的公共文件夹。

我采取的部署步骤

  1. 从 git 克隆我的项目
  2. 将分支更改为我的开发分支
  3. 为该项目授予了我的权限777(我知道这是错误的,我只是想让它部署并查看它是否有错误)
  4. 将我的虚拟主机指向 project/public
  5. 添加了 .env(在之前的部署中使用过)
  6. 作曲家安装
  7. 作曲家更新
  8. php工匠配置:缓存
  9. php工匠路线:缓存

虚拟主机

<IfModule mod_ssl.c>
   <VirtualHost *:443>
      DocumentRoot /var/www/html/API/public
      #DocumentRoot /var/www/API/public/

      ServerName api.app.io
      ServerAlias api.app.io
      ErrorLog ${APACHE_LOG_DIR}/api-error.log
      CustomLog ${APACHE_LOG_DIR}/api-access.log combined

         <Directory "/var/www/API/public">
            #Options +Includes
            #Options +FollowSymLinks -Indexes
            Options All
            AllowOverride All
            Require all granted

         </Directory>

      SSLCertificateFile /etc/letsencrypt/live/api.app.io/cert.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/api.app.io/privkey.pem
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateChainFile /etc/letsencrypt/live/api.app.io/chain.pem
   </VirtualHost>
</IfModule>
Run Code Online (Sandbox Code Playgroud)

.htaccess

<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]

    # Handles JWT middleware
    RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

小智 1

尝试在您的托管面板中更改 php 版本。