Laravel ONLY on Live Server Error MethodNotAllowedHttpException - php

I'm getting this error overnight, despite I haven't updated any file.
The website has been working perfectly fine for 3 weeks and I am suddenly
getting this error when trying to submit anything through POST method.
I'm hosting two laravel-based websites and it's happening in both of them.
Any idea would be really appreciated. Thanks in advance

As I don't know if can use that, the simplest solution would be to connect via SSH to your live server. If you don't have access to your server via SSH you probably used FTP to publish your project. While this can work (i.e. deploying on a windows machine) it can also cause tricky problems.
I had a similar problem recently on a windows machine where one cannot simply execute an artisan command on the shell.
My solution was to set up a route and added this code in the controller method
$output = new BufferedOutput;
Artisan::call('route:list', [], $output); // use route:clear instead
return dd($output->fetch());
You can try the same replacing 'route:list' with 'route:clear'.
Also maybe try to comment all other routes in your route file and try the one not working at the moment again.
If it is still failing, the problem comes from your server settings.
If this works, it has more presumably something to do with the arrangement of your routes.

It was all caused by a single quote character (') in the PDF files I was trying to upload.
insert facepalm gif

Related

How to view ERROR feedback in AWS PHP application?

I am currently developing a web application using AWS services and it's written in PHP. Previously, I used XAMPP to do the work, but now I use EC2 and RDS (MySQL) of AWS. And I also hosted the web on domain using Route 53 and it is secure with Certificate Manager (HTTPS enabled).
This is how I do my job. Sublime Text to write code, then copy paste the file from local to server using WinSCP. If nothing wrong, the code will instantly reflect in my webpage. However, unlike XAMPP, the ERROR will reflect exactly which line is going wrong. The approach I am using will only show HTTP 500 (Request cannot be handled) within the webpage.
For now, I have to test code by code to find the ERROR and it's a waste of time. So, if I want to view which part is going wrong like XAMPP, how can I do so?
Thank you.
In a production environment, it is recommended to switch off detailed errors so that your implementation details are not exposed. Sounds like this is the problem you're facing with the new setup. You need to enable this in your php.ini file, and you might want to look into your .htaccess as well.
Check out the answer here for a more detailed explanation - How can I make PHP display the error instead of giving me 500 Internal Server Error
Here's a guide on implementing the changes you need - https://stackify.com/display-php-errors/
By default, the Errors logs are stored at /var/log/apache2/error.log. So you can do something like the below to see the apache logs in real-time:
tail -f /var/log/apache2/error.log

Problem in nginx server not running php files suddenly

I have a dynamic website developed by native PHP on a server using NGINX which was functioning normally, but suddenly it broke down such that the PHP files no longer run and just download automatically to the client with the code whole source when he tries to excute that files. I don't know why it happened, and is it because of a hacking or an internal server problem. When I contact the web host, he says that a php file that is causing this problem, knowing that I haven't changed anything at last time.
Please clarify the cause of this problem if you have an idea !! Thank you in advance.
There is no idea yet ? I add that the last time, the host re-initialized the configuration of the VPS, and the website is now running well. It is clear that the problem was in the configuration! But I ask the same question, why did this failure happen? I want to know the reason: if the problem comes from PHP files or from the server itself !!

How to solve the error "The localhost page isn’t working" in laravel

I am developing a web application in Laravel 5. I created the project in a local machine at my workplace and it runs just fine. But when i run the machine in another windows machine, it gives me an error The localhost page isn’t working with HTTP ERROR 500 as a server internal error.
I have also tried to look at the laravel.log file and found an exception Call to undefined function site_url() but don't know how to fix this.
Any idea on how to work around this is much appreciated.
This error is coming because you forgot to start laravel service.
If you wish to run your project on http://localhost:8000 Try with the following command :
php arisan serve
If you wish to choose specific port then try with the following command :
php artisan serve --port={port number}
Happy Coding :)
If you run local server by php artisan serve it will give url localhost:8000 by default and will run only in your machine to run in another machine of LAN you need to first find Local IP by ipconfig suppose you get this (192.168.2.10) then use this command.
`php artisan serve --host 192.168.2.10`
this will give url 192.168.2.10:8000 and can be access from any LAN connected machine.
In case none of this was working for you, there may be a more sinister explanation.
In our case, someone who shall go unnamed accidentally deleted the public/index.php file, and committed that to git! So taboo I didn't even think to look. This will stop ANYTHING in your site from running, including logging, but the server will go ahead, so there is nothing to go on, just a 500 error with no response or preview.
Again, seems ridiculous, but it was SO ridiculous who would even look for it?
please change your php version. you need to install php 7.2 version for laravel 5.6 version.

Failed to open Stream, no such file or directory

I recently started using the Laravel framework and i set up a little workspace for me to work in. I setup a Xubuntu client at home that runs a Apache server from which i program and host my Laravel instance from. Now recently I've run into a little bit of a problem. I was following a tutorial series and everything went fine, the next day however i run into this error http://puu.sh/nh5vQ/8ae11c52ab.png
Both from opening the /var/www/html/test/public directory in apache2 from my webbrowser or from running php artisan and actually hosting the laravel instance.
So the first thing that came to mind was permissions, but the permissions for the public folder are fine, It should be able to read or execute as any program. http://puu.sh/nh5Ho/06e061a056.png
Mostly other posts can reference to a bit of code where they specified the wrong filepath. What i find odd is that when i open my hosted instance of apache server in my webbrowser, where you can technically browse all the files in the hosted directory it is there in the list, but when i click it it pops up with that same error.
I checked if all the files that the server is trying to acces exist, and they do exist and i made no typo's.
I'm going to continue on looking and i shall post the solution as soon as i find one, though I'm hoping you guys have an idea since I've been looking for about 2 days to find a solution.
Thanks for your time
I Decided I'd have to start a new Laravel project to fix this without making a chaoticly configured project.

Error 0 couldn't connect to host in wamp windows 7

I have a joomla GIT repository of my project. We are using wamp and windows 7 as a development environment. This repository works fine on one machine. But when we tried to clone same repository on other two machines, we are facing a strange error.
Error is: Error 0 couldn't connect to host
As shown in screenshot.
All other repositories on those two machines work fine.
There is no error logged in under any of error logs file (apache, php and mysql).
I enabled joomla's error reporting. Searched on Google but, no luck.
Please help.
Thanks.
When you clone your Joomla to another machine, there are several things you need to double check:
Not only the files from the GIT, make sure the database is the same on the other two machines as well (export from the first one, import to 2 other one using phpMyAdmin).
Make sure the configuration.php file on two other machines re-corrected, includes: path to logs, tmp folders; database information (host, username, password, database name).
It should works.
Well, I debugged little bit more and finally found the solution. It was a small issue with missing web service link in one table. We are using com_api for web services. On first machine web service link value in table was local value respective to that machine.
On remaining two machines, we updated this to local value of those respective machines.
And it worked :)
This is not a standard Joomla error - it's either that this error is thrown by an extension or it is a server error.
Try adding a die(); at the beginning of your index.php file and see if it actually dies, if it doesn't, then this is definitely a server error.
If it does die, the use the function: get_included_files() and then make a quick search on all the files included on that page for the sentence "Couldn't connect". You will find the culprit easily this way.
Check your .htaccess file, maybe they have some rule which can not be met. (Rename this file if it exists and see what happening)
But I think that the problem is in the network settings. Errors often come from dns issues or, curl connection restrictions.
Check your DNS records
Check your Curl settings and try to create any Curl request.
Check your .htaccess
I don't think this error related to Joomla , I think it is connection from PHP to Linux, try to change the port of the Linux.
and restart the Apache and try again.

Categories