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

vincent15000's avatar

Ubuntu Server and Laravel sail

Hello,

I'm using Laravel sail for a project and I develop the application on Ubuntu Desktop.

Now I need to deploy the application on Ubuntu Server and ... surprise : it doesn't work.

Executing ./vendor/bin/sail npm run dev from the application folder generates an error : it tries to locate the vite.config.js file inside the /var/www/html folder.

Whereas it works fine on Ubuntu Desktop.

I'm looking for a solution for some hours without finding it.

Do you have any idea how to solve this issue ?

Thanks for your help.

Vincent

0 likes
10 replies
LaryAI's avatar
Level 58

It sounds like the issue you're encountering with Laravel Sail on your Ubuntu Server is related to the working directory or path configurations. When you run ./vendor/bin/sail npm run dev, it seems that the command is not being executed in the correct directory context, which is why it's looking for vite.config.js in /var/www/html instead of your project directory.

Here are a few steps to troubleshoot and potentially resolve this issue:

  1. Check Current Working Directory: Ensure that you are in the correct directory when you start Sail. You should be in the root of your Laravel project where the docker-compose.yml file is located.

    cd /path/to/your/project
    
  2. Use Docker Compose Directly: Sometimes, using Sail's wrapper scripts can lead to unexpected behavior, especially regarding path handling. Try running the commands using docker-compose directly to see if the issue persists:

    docker-compose exec laravel.test npm run dev
    

    Replace laravel.test with the appropriate service name if it differs in your docker-compose.yml.

  3. Check Docker Context: If the above doesn't work, there might be an issue with how Docker is interpreting your project's context. Check the docker-compose.yml file to ensure that volumes are mounted correctly:

    volumes:
      - .:/var/www/html
    

    This configuration mounts your project directory (.) to /var/www/html inside the container. Ensure this line is correct and points to the right directories.

  4. Permissions: Permission issues can sometimes cause problems with file access. Ensure that the user inside the Docker container has the right permissions to access the files:

    docker-compose exec laravel.test ls -la /var/www/html
    

    This command will list the files under /var/www/html inside the container and show their ownership and permissions.

  5. Rebuild Containers: If you've made changes to Docker configurations or if something seems off, it might be helpful to rebuild the containers:

    ./vendor/bin/sail down
    ./vendor/bin/sail build --no-cache
    ./vendor/bin/sail up -d
    
  6. Check for Environment Differences: Since it works on your desktop but not on the server, compare the environment settings (env files, Docker versions, etc.) between your desktop and server setups. There might be a configuration difference causing the issue.

If none of these steps resolve the issue, consider providing more detailed logs or error messages from the Docker containers, which might give further insight into what's going wrong.

Nick-'s avatar

Laravel Sail is for local development. Don't use this for production. Instead install a proper LEMP stack on your server.

2 likes
vincent15000's avatar

@Nick- My client wants to run the application with docker.

But no matter, it should work as in local development.

So the question is : what is the problem ? Why does sail not find the vite.config.js file inside the /var/www/html/ folder ?

martinbean's avatar

@vincent15000 Sail is still not suitable for production use. Sail runs your Laravel app using PHP’s built-in development server. You want to use an actual web server—such as Apache or nginx—for serving your site in production.

1 like
vincent15000's avatar

@martinbean Ok ... what about docker ?

Can docker be used for production use ?

I've read some pages on the web saying that docker is not appropriated for production because there's a lack of stability and performance. But some people use it in production.

martinbean's avatar
Level 80

@vincent15000 Yes, Docker can be used for production use.

Sail is Docker-based, but it’s suitable for local development only. You would need to create your own Docker Compose set-up that uses an Apache or nginx image to serve your web application instead.

1 like
s4muel's avatar

do you use sail also on Ubuntu Server? if so, the volumes should be mounted same way 🤔(according to the sames volumes definition in docker-compose). but if by any chance (overlooked or something), you are not, just run npm run dev without the sail command prefix:D

1 like
vincent15000's avatar

Here is the message I get.

failed to load config from /var/www/html/vite.config.js error when starting dev server: Error: EACCES: permission denied, open '/var/www/html/vite.config.js.timestamp-1715004669600-0efafaa9e69ec.mjs'

So it's a problem with the rights.

Please or to participate in this conversation.