Support the ongoing development of Laravel.io →
posted 3 years ago

I'm deploying a Laravel app to Directadmin.

Background

One thing to note I'm deploying code that works in Dev on Linux PHP8. So there's no issues with the routes files. The env is setup and valid on the deployment machine. Deploying to the same Linux distro and same version of PHP.

My Laravel app is deployed outside of directadmin/public_html and the

Deploy path ``` /home/myuser/domains/example.com/laravel/``

Contents of app/public are symlinked into directadmin/public_html ln -s home/myuser/domains/example.com/laravel/public/* home/myuser/domains/example.com/public_html/

Hope this is clear enough.

Problem

Everything goes as planned except I can only reach the main page of the site i.e. /

Any routes below that like /login or /about return a 404

What I've tried

  • Check storage is symlinked
  • Reset permissions
  • npm run prod
  • php artisan route:clear
  • php artisan cache:clear
  • Checked .htaccess
  • restart httpd
  • enable debug and local to see errors (none found)
  • read httpd error logs, Laravel error logs but these have come up empty.
  • redeploy

Most of these steps are part of the deployment script anyway. But somehow Laravel finds a way to break on each deployment (even when it's scripted). Laravel is so temperamental!!

Can anyone think of something I may have missed in this deployment?

tvbeek liked this thread

1
moderator

Hello @barcovanrhijn it sounds as a frustrating situation.

Thanks for your detailed question and the list with what you've tried!

Some debug things I can think about are:

  • Can you open a file that isn't handled by Laravel (like robots.txt)
  • Do you see the routes if you run php artisan route:list on your server?
  • Do you have a domain name defined on your routes? (That is possible but can result in problems if you do it while it isn't needed)
0

@Tvbeec it's a pickle.

  • Can you open a file that isn't handled by Laravel (like robots.txt) Yes this works if I enter the url/robots.txt
  • Do you see the routes if you run php artisan route:list on your server? The routes list out correctly.
  • Do you have a domain name defined on your routes? (That is possible but can result in problems if you do it while it isn't needed) I'm using very plain routes without domains since I'm essentially building the static bits for this site and getting the deployment going before adding more complex bits.

Example Routes

Route::get('/', function () {
    return view('welcome');
});

Route::get('/about', function () {
    return view('about');
});

I'm considering All Routes except main give 404

So I'm currently testing some additions to .htaccess to see if this will solve the issue.

.htaccess

    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    # Testing -- Suggested symlink additions
       Options Indexes FollowSymLinks
       AllowOverride All
       Require all granted

    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]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Last updated 3 years ago.

sadorect liked this reply

1
moderator

Some strange things that could help (I found this type or problems both interesting and frustrating)

I see you use a relative path (I suspect from your root) Can you use an absolute path? ln -s /home/myuser/domains/example.com/laravel/public /home/myuser/domains/example.com/public_html/

What happen if you copy your public dir to your public_html and update the paths in index.php ? Like require __DIR__.'/../vendor/autoload.php'; will be require __DIR__.'/../laravel/vendor/autoload.php';

0

@tvbeek Thanks for this suggestion.

I ended up deleting the entire deployment. You're right the symlinks are messing things up. In the end my conclusion is that the webserver is not following the symlinks correctly.

After redeploying and copying the index out and correcting the paths and setting the storage link things work as they should.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.