Host Behind Nginx
Introduction
When moving from php artisan serve to a local Nginx/PHP-FPM stack or a production deployment, you must ensure your environment variables and file permissions are correctly configured.
Step 1 — Directory Permissions
Ensure the web server user (e.g., www-data or nginx) has write permissions to the storage and bootstrap/cache directories.
chown -R www-data:www-data storage bootstrap/cacheIf you are using the default SQLite database, the web server must also have write access to both the database file *and the directory containing it* to write the WAL files.
chown www-data:www-data database/
chown www-data:www-data database/database.sqliteStep 2 — Configuring Vite HMR
If you are running the Vite development server (npm run dev) behind an Nginx proxy, set the origin and port in your .env file so the hot-module replacement websocket connects successfully:
VITE_DEV_SERVER_PORT=5173
VITE_DEV_SERVER_ORIGIN=http://my-app.test:5173Ensure your Nginx vhost proxies /vite-hmr to the correct Vite port.
Was this page helpful?