# Got Error while using slim framework on web server

**URL:** <https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846>\
**Category:** Questions\
**Created:** [June 7, 2021, 1:38pm UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846 "2021-06-07T13:38:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prkvv](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@prkvv](https://discourse.slimframework.com/u/prkvv)\
**Post date:** [June 7, 2021, 1:38pm UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846/1 "2021-06-07T13:38:33Z")

</div>

Hi all,  
I develop a small api using slim framework and it worked successfully in local server.  
and then I upload all the files on web server. It did not worked. Used web server [Apache and PHP in ubuntu]

For example:

```auto
   $app->get('/', function (Request $request, Response $response) 
   {
       $response->getBody()->write('Hello world!');
       return $response;
   });

```

This code worked successfully. When I enter 185.546.23.54/Folder\_Name/public This will give correct output (Hello world!) [185.546.23.54 Just for example]

But, The below code got error.

```auto
  $app->group('/users', function (Group $group) 
    {
        $group->get('', ListUsersAction::class);
        $group->get('/{id}', ViewUserAction::class);
    });

```

When I enter 185.546.23.54/Folder\_Name/public/users it will give the below error.

Error I got: [185.546.23.54/Folder\_Name/public/users]

```auto
# Not Found

The requested URL was not found on this server.

Apache/2.4.41 (Ubuntu) Server at 185.546.23.54 Port 80

```

And Sometimes 185.546.23.54/Folder\_Name/public this URL give correct output, sometime give error output.

Error I got : [185.546.23.54/Folder\_Name/public]

```auto
{
    "statusCode": 500,
    "error": {
        "type": "SERVER_ERROR",
        "description": "ERROR: Module 'pgsql' already loaded on line 0 in file Unknown."
    }
}

```

Any configuration Needed ? Any suggestion ?

Thanks

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [June 7, 2021, 2:21pm UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846/2 "2021-06-07T14:21:41Z")

</div>

Hi @prkvv

To make it work, you must enable Apache mod\_rewrite and the DocumentRoot must point to the public/ directory of your application.

Read more: [Apache configuration](https://www.slimframework.com/docs/v4/start/web-servers.html#apache-configuration)

When you run your application in a sub-directory of the DocumentRoot, you also have to set the basePath of the Slim $app instance.

---

<div class="post-metadata">

**Author:** ![prkvv](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@prkvv](https://discourse.slimframework.com/u/prkvv)\
**Post date:** [June 8, 2021, 5:07am UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846/3 "2021-06-08T05:07:39Z")

</div>

Hi @odan  
Thanks for your response.

I did all the apache configuration. Still got error.

Error I got : When I enter 185.546.23.54/Folder\_Name/public/users

```auto
{
    "statusCode": 500,
    "error": {
        "type": "SERVER_ERROR",
        "description": "The stream or file \"\/var\/www\/html\/Folder_Name\/app\/..\/logs\/app.log\" could not be opened in append mode: failed to open stream: Permission denied"
    }
}

```

Any suggestion?

Thanks

---

<div class="post-metadata">

**Author:** ![prkvv](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@prkvv](https://discourse.slimframework.com/u/prkvv)\
**Post date:** [June 8, 2021, 5:40am UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846/4 "2021-06-08T05:40:41Z")

</div>

Solved. I gave it `chmod -R 777 /app.log` it worked.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [June 8, 2021, 7:05am UTC](https://discourse.slimframework.com/t/got-error-while-using-slim-framework-on-web-server/4846/5 "2021-06-08T07:05:28Z")

</div>

Ok, great.

Please note that the `public/` directory must not be part of the URL.
