mercredi 13 février 2019

Deploying laravel api rest on ubuntu and nginx

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::post('/api/projects', 'ProjectController@index');

now when I go to myservername.com/api/projects I get a 404 not found. I know it should be a post request but still a get request should return something other than 404 right?

Anyone know what I am missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire