php - laravel 404 error when deploying live

Viewed 2024

I'm getting a 404 error when I'm deploying my project on a live server. I'm getting a laravel page saying Sorry, the page you are looking for could not be found. so I know it is reaching my project.

I ran php artisan config:cacheand php artisan route:cacheto register my routes and cache, but it still isn't changing. not really sure why I'm getting this error. My document root in my vhost is set to my public folder as well.

Steps I took to deploy

  1. cloned my project from git
  2. changed branch to my develop branch
  3. made my permissions for the project 777 (I know its wrong by I just wanted to get it to deploy and see if it had bugs)
  4. pointed my vhost to project/public
  5. added .env (was using it in previous deployment)
  6. composer install
  7. composer update
  8. php artisan config:cache
  9. php artisan route:cache

vhost

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

.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>
1 Answers

Try to change php version in your hosting panel.

Related