Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kordix's avatar

Reaching api after deployment on Digital Ocean

Such api route: http://localhost:8000/api/handles/KK works perfectly on local serving But after deploying the app on DigitalOcean I can't get to api in any way. I tried http:// MYIP /mysite/api/handles/KK or http://MYIP/mysite/public/api/handles/KK

(the app isn't directly in www folder but subfolder since i have many apps)

EDIT now it works after I run php artisan serve on remote server, but do I have to keep it all the time or what? Is that a proper method?

0 likes
5 replies
Snapey's avatar

no,no,no

You have to configure your choice of webserver to serve public as the document root

There is one of these questions literally everyday. Clearly no good tutorials out there.

kordix's avatar

In 000-default.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/konfigurator/public

        <Directory /var/www/html/konfigurator/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

</VirtualHost>

It works quite well but still I must write index.php , without it the site kind of "catches" the routing but results at not found, when I write http://myip/index.php works perfectly, but routing works like http://myip/index.php/myroute that's still ridicioulous

EDIT Alright got it /var/www/html/konfigurator/public/index.php

jlrdw's avatar

There are pages of previous replies already on this forum on how to set this stuff correctly. And D.O. has tutorials. You should not have to run php artisan serve on remote server.

kordix's avatar

I have set public as document root but I still have to write index.php and api is not working

Last time i thought I have to set public/index.php instead of public, but it worked only because I had local instance running

I did it like in tutorials someone could help?

kordix's avatar

SOLUTION I had to allow mod_rewrite

Please or to participate in this conversation.