Support the ongoing development of Laravel.io →
Laravel Installation

I have a REST API with Laravel 5.5 LTS that I want to deploy to my ubuntu server and use nginx.

I have uploaded the api to my ubuntu server and the updated my nginx config file like this:

server {
        listen 80;
        listen [::]:80;
        root /myservername/api/public;
        index index.php index.html index.htm;
        server_name myservername.com www.myservername.com;
        location /api {
                try_files $uri/ /server.php?$query_string;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass             unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

I then have an endpoint route configured as:

Route::get('/api/mail/send', 'MailController@index');

now when I go to myservername.com/api/mail/send I get a 404 not found.

The MailController just does a var_dump():

class MailController extends Controller {

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request) {
        var_dump('hi');
    }
}

Anyone know what I am missing? My second location block I basically copy pasted, do i need it? as I notice that unix path does not exist (/var/run/php/php7.2-fpm.sock)

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

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.