So I have a website built in php and it was working perfectly on one server, I then moved the website to a server I have on Digital Ocean and am running into several errors, they seem to be based around http request failures while using the imagick library...
I was hoping to not to have to start debugging this from a code point of view as it was already working perfectly and would prefer to change server settings.
Fatal error: Uncaught exception 'ImagickException' with message 'Imagick::__construct(): HTTP request failed! HTTP/1.1 404 Not Found .
I cannot figure out what differences there, on both server allow_url_fopen is set to on.
The php version is different, 5.520 on the original server, 5.5.9 on the new server.
The versions of imagick are the same. I am also getting some other errors using the mpdf library but I will try deal with these later (Im hoping if I can resolved the first ones these ones will also get resolved).
My question is , is there possibly any other setting on the server I should be looking out for that may be causing these php errors?
EDIT:
Just to add more information, i can get rid of some of the errors by changing the file path https://www.example.com/myimage.jpg to /var/www/example/myimage.jpg . This solves some of the errors but I would rather get the root of the issue thats causing it not to work in the first place, because I feel that its the same problem thats causing other errors.
The error code says it: 404, file not found. You are probably using the wrong URL.
Are you able to fetch https://www.example.com/myimage.jpg using a webbrowser?
On several popular linux distros, /var/www/example/myimage.jpg would be served at https://www.example.com/example/myimage.jpg instead of https://www.example.com/myimage.jpg with the default configuration.
[edit]
It just came to my attention that the URL is HTTPS, there is a possibility that the script is rejecting the server certificate. Try with regular HTTP - no point in using SSL if the file is on the same machine.
Related
I am working on a login system using AngularJS,php, andMySQL. I am following this tutorial on creating an AngularJS user signup and login authentication using php & MySQL. When I put it on "live", I get the error message below:
Failed to load resource: the server responded with a status of 404
(Not Found) angularlogin/files/functions/session:1 Failed to load
resource:
I have checked my phpinfo for session, which is is enabled. What is wrong?
Not the definite answer (comments are too limited), but I spun up the project you linked to, I get almost the same error:
angular.min.js:77 GET .../files/functions/session 500 (Internal Server Error)
But a 500, not 404 so you probably need to give us more info. 404 (file not found) could mean you have forgotten to copy some files?
Anyway:
You can always check the server logs, I got ErrorException: mysqli::__construct(): (HY000/1049): Unknown database 'angularjs_login'. If this is your problem, you've just forgotten to create the database on the server.
During development, don't use the production angularjs (angular.min.js), instead use the non-minified version (angular.js) because you'll get much better error messages!
Open the network tab in your browser dev-tools (press F12), click the failed request (sessions) marked in red when not selected, and if your php-settings allows it, you can see the the error straight away under the preview-tab.
If you are sure you have copied all files, here is a qualified guess:
Your webserver is not configured for slim. Which requires all requests to go through the main index.php, in your case files/functions/index.php. If there is a request to say files/functions/session (which does not exist), the webserver will redirect that request to index.php which sorts the request and passes it along to the right place.
If the request does not go through index.php, then you'll get a 404-error.
Slim solves does this by using a .htaccess-file. files/functions/.htaccess. On windows it might be a hidden file, which could be a reason you've missed it.
Or, your webserver is configurated to not care about .htaccess-files, then you have to change your webserver settings.
Or, you have a webserver that doesn't use .htaccess-files at all, (like nginx) then you have to find another way to redirect those requests. I suggest you have a look at https://www.slimframework.com/docs/v3/start/web-servers.html
There is too little info for us to know for sure, but I think the above seems somewhat likely anyway.
There is a folder on my apache server containing several php scripts. All the php scripts in this folder work except for 1. All the php scripts including the script that doesn't work have the same rights.
When I run the script in my browser I get this error:
HTTP ERROR 500
Details that may be helpful:
PHP Version 7.0.11
Apache/2.2.15 (CentOS)
An Apache status code of 500 means "internal server error". Without seeing the code that is producing this error it is hard to say what is causing it but the first things to check are server configuration and your .htaccess file. Make sure your server is running properly then check your .htaccess file as a bad rule can force some types of PHP to malfunction. As #RiggsFolly stated, it is also possible that the problem is some very poorly written PHP which can be tested by replacing it with a simple program like:
<?php
echo "test";
?>
SOLUTION: In my case the problem of 500 error was the upgrade from php 5.x to 7; BUT: I imagine this error can come from many other reasons, so if it does not apply, good luck finding the other solutions. In this case, it worked - and the solution is to rewrite the code or downgrade to old PHP version until you re-code the incompatible parts.
EXPLANATION / DEBUGGING PROCESS: After several tests to identify what is happening (commenting parts of code, testing functions, reading documentation), I found that deprecated functions from previous versions of PHP will generate a 500 Error.
For example, in a script written for PHP<7 you may still have old mysql queryes like mysql_connect, and once your server is updated to 7 (and you must use mysqli), this script will throw 500 error.
I imagine this happens to any other function that became deprecated.
In your case, my bet is most of the scripts are compatible with 7, one is not.
I am trying to simply use file_get_contents() to get content of http://www.google.com/search?hl=en&tbm=nws&authuser=0&q=Pakistan with same code on 2 different servers. One is getting every thing file while other is getting 403 error. I am unable to know what exactly the reason is. I used phpinfo() on both servers.
One difference I observe is that one use apache2 while other use some other HTTP server named LiteSpeed V6.6. But i don't know how if it affect this file_get_contents() method. For more detail you can see their phpinfo() page link below.
Where file_get_contents getting 403 the phpinfo is; http://zavahost.com/newsreader/phpinfo.php
while where it is working file , here is the phpinfo: http://162.243.5.14/info.php
I will be thankful if someone can tell that what is effecting file_get_contents()? Please let me know if any idea?
403 is an Unauthorized Error. That means you lack sufficient permission to connect to the content at that server. I'm not sure if this could be due to the inability to fetch data from your hosting provider, but it could also be denied based on header information the remote server has flagged as unauthorized.
Try using the answer on this post: php curl: how can i emulate a get request exactly like a web browser? to curl the same data from the server that is getting the 403
am new here - I have been having problems with this $%%$%$ IIS7.5 I have finished developing a wordpress site on my localhost using xampp - so I thought this was gonna be business as usual just copy files to remote- change config and dump sql - boy was I wrong! I think I have done everything I know to do and am still getting this annoying HTTP Error 500.0 - Internal Server Error
This is what I get each time,When I am trying to access the site:
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.
Detailed Error Information
Module
FastCgiModule
Notification
ExecuteRequestHandler
Handler
PHP_via_FastCGI
Error Code
0x00000000
Requested URL
http://mysite.com:80/index.php
Physical Path
E:\HostingSpaces\xxxxxxxxx\mysite.com\wwwroot\index.php
Logon Method
Anonymous
Logon User
Anonymous
Most likely causes: •IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
•IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
•IIS was not able to process configuration for the Web site or application.
•The authenticated user does not have permission to use this DLL.
•The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
Things you can try: •Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
•Check the event logs to see if any additional information was logged.
•Verify the permissions for the DLL.
•Install the .NET Extensibility feature if the request is mapped to a managed handler.
•Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
Links and More Information This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error.
View more information »
Microsoft Knowledge Base Articles:
•294807
Please can anyone just tell me precisely what to do,I cant take it anymore.. please help me.
So my case is hopeless - i cant be helped?
IIS server is not equal to Apache. It uses another type of configs. I think your problem in the web.config file or related to permissions. Your question isn't so subjective. You need to localize problem and describe here more detailed information. Now your question looks like this: "I have PHP application on IIS that doesn't work. I tested it on my xampp. Where is problem?". There are a lot of problems that you can have here...
I has same problem with php 5.6 on iis 6 (windows server 2012 r2)
You should ensure the VC++11 runtime is installed (for me it's Visual C++ Redistributable for Visual Studio 2012 Update 4)
It's probably because the connection string mismatch,check your connection string.
"500 - Internal server error" error message when a user tries to access your Apache or Lighttpd based dynamic php application
Generally, to solve this problem you need to take help of log files located at following location:
=> /var/log/message
=> /var/log/httpd/error_logs (/var/log/lighttpd/error_log or /var/log/httpd/error_log)
This error only occurs because of web server software. However after looking through logs you may not find many details. This problem may be caused by:
A malformed php cgi script
An invalid directive in an .htaccess or other config file
Limitation imposed by file system and server software (for example php log file size set to 10Mb)
Missing php.ini (or cannot read php.ini file)
I am currently using an image manipulation script to do some work on uploaded images and I'm running into a problem in my dev environment. This same code works on my production server.
The error is:
PHP Warning: imagecreatefromjpeg(): php_network_getaddresses:
getaddrinfo failed: Name or service not known in /path/to/script.php
on line 75
The line of code on 75 is:
$this->img = imagecreatefromjpeg(PHPTHUMB."?src=/".$this->image_path);
which creates an image that is loaded from another made by phpThumb, which is used for further manipulation.
Any ideas on how to solve this? Can anyone shed some light on what the error means?
Thank you,
Edit:
Just as a further bit of insight, if i visit PHPTHUMB . "?src=/" . $this->image_path in my browser, the image loads fine
User agent in php.ini did not solve the problem as indicated here
EDIT (SOLUTION): I had to add the INTERNAL 192.168.204.XXX IP into the hosts file, so that http://dev.mysite.com resolved correctly. Trying both 127.0.0.1 and the external IP yielded no result, but the internal works perfectly. Thanks for everyone's efforts,
I'm totally not sure about the cause of that error, but this is my best guess.
There is a particular PHP Setting which enables you to treat URLs as files. Normally imagecreatefromjpeg accepts a filename, I think. Since you are passing a URL, you need to make sure the particular setting is enabled. I believe you can find more info about it here: http://us2.php.net/file
filename
Path to the file.
Tip
A URL can be used as a filename with this function if the fopen
wrappers have been enabled. See
fopen() for more details on how to
specify the filename and List of
Supported Protocols/Wrappers for a
list of supported URL protocols.
Fopen wrappers: http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
Your dev environment may not be setup with this, but your production environment could be.
Edit
This page lists your error:
http://bugs.php.net/bug.php?id=11058
and mentions that a possible fix is by modifying your hosts file to explicitly include the ip/dns of the server you're accessing.
i tryed to reconfigure my named
configuration, without any result, to
fix this. the problem was solved by
adding the following line to my
/etc/hosts:
194.97.55.147 mx.freenet.de
Maybe you can try this?
did you also check that allow_url_fopen is set to On in php.ini?
I saw that they did mention that in the article you referred to in your post.
EDIT: Also, what OS and what PHP version are you running?
Just read this on php.net: "On Windows versions prior to PHP 4.3.0, the following functions do not support remote file accessing: include(), include_once(), require(), require_once() and the imagecreatefromXXX functions in the GD Functions extension."
EDIT2:
I just read what was written in the comments, your allow_url_fopen is set to On, sorry about that.
But OS, PHP version and phpinfo() would help in finding the problem.
The error message suggests something is wrong at a networking level. Thus, if possible, bypass that. Try using the path to the thumbnail generator, instead of a network address.
If that's not an option, try something that will give you more granular error messages. I suggest CURL. At the very least, it should yield a more informative error message.
The simple fact that this is failing is because on your webserver, your DNS resolution is broken.
If you have SSH access to your server, try the following command
dig hostname
where hostname is the host name from PHPTHUMB
This will probably fail.
Assuming that you're using Linux, my suggestion would be to edit your /etc/resolv.conf (as root)
and add the following line before any other lines beginning with "nameserver"
nameserver 4.2.2.2
This should hopefully fix things, though you may have to restart apache (or whatever webserver you're using)!
The issue here is that php fails to resolve the url that you provide as PHPTHUMB as stated in this bug report on php.net. This possibly means that it's the fault of the operating system/web server, in which case you can enter the ip address of the server you are connecting to into your hosts file manually.