deploying laravel filament app on local machine issues
Hi, i'm about to deploy my app on local server, windows system with xampp.
I've build the app for production and putted in the htdocs folder.
What i've donne is:
composer install --optimize-autoloader --no-dev
And
npm run build
I can access login page with: http://localhost/my-app-name/public.
Login page appear correctly but when i try to login, this error appear :
Not found
The request URL was not found on this server.
As in the attached screenshots
The errors in console also in joined screenshots.
I don't realy know what happend,what cause that.
Can i please have your assistance guys?
29 Replies
Your webserver should be setting the entry point of your application as
public/index.php
. Right now it looks like your entry point is the application root (folder level with app, storage, routes folders)
Actually no, it appears that your local environment entry point is htdocs, and your project folder is within. Your entry point should be set to htdocs/my-app-name/public/index.phpHow can i change this and where. I tried to change the app_url in .env file to "http://localhost/my-app-name/public/" but not working.
Use herd. https://herd.laravel.com/
I tried it, for an existing project. But it's not working. I juste placed the laravel filament project in herd directory. But when i open the project in brosser, the xampp dashboard is display on directory-name.test
Remove xamp. Maybe there is a port conflict
I'm using the free version, i'm not seeing any database in services. That's why i kept xampp activated.
The free version only supports SQLite AFAIK. It should be enough for most use cases (especially if you're still learning)
use DBNgin for databases
I'm about to deploy app in production on customer local machine. That's why i'm using MySQL.
Yeap. Even so, you should be fine if you're not using any Mysql-spcific stuff. Anyway, I suggest you look into other local dev solutions. I haven't used the paid version of herd, maybe it's worth it for you. Or I suggest you look into docker. Either with sail or DDEV (https://ddev.com/)
For Windows, there is Laragon as well, worth a try since you 'xampping' already...https://laragon.org/download/
Laragon - portable, isolated, fast & powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby.
Download
Laragon is a universal development environment. It has many features to make you more productive:Benefits of Laragon After downloading, You can add git, phpmyadmin, Node.js/MongoDB, Python/Django/Fla
Trying this one, but after ddev config, it show me "successfully started name-of-project" and project Can be reached at: links
But links not work.
Finaly, i retried this one.
First uninstlled xampp like suggested @David | Fortune Validator .
Installed DBNgin like @toeknee said.
Unzipped my project in a directory and linked existing project in Herd.
After deleted thΓ© config file in bootstrap folder, every thing worked fine.
Except filament PWA not working and public_path for image in domPDF.
Thanks everyone for your precious help.
Now, what if i want to configure cron jobs, is there a way? I precise i'm on windows environment and using Herd and DBNgin.
since you must have to use a windows machine, what about just installing WSL? or a simple VM running Linux?? get a penguin π§ virtualization under windows and be happy my friend π
π seem to be easy. But do you have any guide for that? Or any tutorial ?
There should be numerous WSL guides out there on the web.
Tried first to deploy on linux in /www/html. Same issue occured as before on windows.
"Not found
The request URL was not found on this server."
I suppose this will cause the same error using WSL on windows.
Can you try to deploy in production a laravel or filament project and see if you will be facing to the same errors ?
Tried first to deploy on linux in /www/htmlThe document root should be set to the
public
folder for every Laravel project
So if you code is in /www/html
the document root of the configured server/domain should point to /www/html/public
Where to change this?
All right, how are you serving the app? which tool from those above that everyone mentioned you decided to use? you will have to configure that serving tool to serve from the ./public folder and not the root folder as previously mentioned. Maybe then we can help ya. You said "tried first to deploy on linux in /www/html" , but how did you do it?
Gives us detail about your setup and we may guide ya in the proper direction.
Testing for linux
First, i prepared the app for production.
Second, copied the project in /var/www/html directory.
Then tried to open the app using : http://localhost/project-name/public
Login page appeared properly, but when i try to login, the error occured.
That's what i've done.
I am no sure you mean by "prepared the app for production'", does that mean you built the assets (npm run build)? could you explain with some more details? that would help π it would be better. what is the web server software you are using to serve the app in "production'? Xampp? Herd? Artisan serve? Docker? It is in the web serving software that you will configure the location to serve the app as mentioned before.
Please, detail your current setup
Ubuntu 20.04
PHP 8.2
Apache 2.4
Laravel 10
Filament 3.1
Preparing project for production
Composer install --optimize-autoloader --no-dev
And
npm run build
I'm my unswered your question ?
Great you are using apache
you need to just change its config for virtualhosts
For windows,i used Herd free version. It working. But don't know how to configure cron jobs.
usually you dont have to setup cron jobs, (in windows we have task scheduler) , with laravel you should keep a running instance of
php artisan schedule:work
for scheduled tasks and a queue work to run async tasks
so if in windows , herd is running ok, then all you need to do is open a terminal and keep those command running
i guess you could use Task Scheduler and set up to run an artisan command
now, in the linux world, you do have cron, but usually , even in the docs, we suggest to use a tool called supervisor
so it keeps running the 'php artisan schedule:work' and queueYes, but this means customer have to execute those command himself every time the computer restarted ?
I mean on windows
thats easy to solve, you can script the command in a simple BAT/CMD file and add into you task scheduler/startup folder/run in registry my friend π
ChatGPT:
Step 1: Create a Batch File
Open Notepad or any text editor.
Paste the following code into the file:
@echo off
cd C:\xampp\htdocs\your-laravel-app
php artisan queue:work
Replace C:\xampp\htdocs\your-laravel-app with the path to your Laravel application directory.
Save the file with a .bat extension, for example, start_queue_worker.bat.
Make sure to save it somewhere that will not be moved or deleted, like C:\Scripts.
Step 2: Set Up Task Scheduler
Open Task Scheduler:
Press Win + R, type taskschd.msc, and press Enter.
Create a New Task:
Click Action > Create Task.
General Tab:
Name: Enter a name for the task, e.g., Laravel Queue Worker.
Security Options: Choose Run whether user is logged on or not and check Run with highest privileges.
Triggers Tab:
Click New⦠to create a new trigger.
Begin the task: Choose At startup.
Click OK.
Actions Tab:
Click New⦠to create a new action.
Action: Select Start a program.
Program/script: Browse and select the .bat file you created (e.g., C:\Scripts\start_queue_worker.bat).
Click OK.
Conditions Tab:
Uncheck Start the task only if the computer is on AC power to make sure it runs even if the PC is not plugged in.
Settings Tab:
Make sure Allow task to be run on demand is checked.
You can also check If the task fails, restart every to automatically restart the task if it fails, and set it to 1 minute for a maximum of 3 attempts.
Click OK to save the task.
You can even set ut up so the console/terminal doesnt show on the machine, it just runs on the background
so if you got Herd working, then just need to get those bat files running the artisan commands for you. In the example above it shows setting for the Queue Work, just change it to fit your needs if all you need it the Scheduler Worker
Hopefully that helps my friend!Yes my freind, this is very helpfull. I think it will be ok now. Gonna try this solution.
Thanks you so much for your help.
Facing another issue. I've to allow the others machine to access the app. So app is installed on a machine as server, and others machine have to access it on local network.
I tried to edit the nginx configuration file for the app to set
listen 127.0.0.1:80
to listen 80
as explaned in laravel docs.
But not working.If you got it working on the local /client machine, you just need to do some basic networking my friend. I would setup the app serving machine with a static IP wihtin your intranet, and configure its firewall to allow the web service to be accessed by others on the same network, so that people can use http://<machine-ip> to access it..