Tag Archives: IIS

The response is not a valid JSON response – Windows IIS

If you’re I presume you’ve already tried some other techniques to fix the “The response is not a valid JSON response” issue with WordPress running on Windows Server and IIS.

In my case, I am running PHP 8.1.8 and the issue was easy to fix.

For me, the error happened while trying to save content to a Widget.

In the log files I noticed the OPTIONS verb being used and a 405 error.

The fix is simple.  Go to HANDLER MAPPINGS, double click your PHP mapping.

Click REQUEST RESTRICTIONS.

Click VERBS

do one or the other.  Add the word OPTIONS to the current list, OR just click ALL VERBS.

Save changes.

Your “The response is not a valid JSON response” should now go away.

 

NOTE:  On IIS WordPress setups, you need to make sure you have a HOSTS file mapping for your website to the local IP address for the website (NOT PUBLIC IP, local machine IP).  This is necessary for the various CRON jobs to work.

 

How to get IMAGICK working under Windows Server IIS

Here is the simple method to get IMAGICK working under Windows Server 2019/2022 and IIS 10.0 and later.

 

  1.  Presuming using PHP 7.4.X (current version is 7.4.27 as of 2/14/22).  NOTE:  This is not working properly under PHP 8.x
  2. Make sure you’ve downloaded the most current 7.4.X version and installed it on your IIS/PHP Manager, which properly sets up the handler mappings.
  3.  download IMAGICK
    1. https://windows.php.net/downloads/pecl/releases/imagick/
    2. Pick the most current, NON “RC” version.  For me, that was 3.7.0
    3. Download the version for PHP 7.4, NTS, vc15, x64
      1. For me, that was -> php_imagick-3.7.0-7.4-nts-vc15-x64.zip
    4. Make sure you have the Visual C 15 runtime installed.  (Google it and download/install if needed)
  4. Extract the archive above to a temporary directory
  5. copy php_imagick.dll to your PHP\ext directory.
    1. MAKE SURE you are in the correct directory, e.g. for me that was php-7.4.27-nts-Win32-vc15-x64\ext
  6. in the archive directory, SORT BY TYPE.
    1. Copy all CORE_RL*.DLL (28 files)
    2. Copy all FILTER*.DLL  (one)
    3. Copy all IM_MOD_RL (134 files)
    4. copy all these to your PHP version’s ROOT directory.  For me, that was 7.4.27-nts-Win32-vc15-x64  (NOT THE EXT DIRECTORY!)
  7.  Go to PHP manager and click on check PHPINFO().  When that comes up, scroll down and make sure you see a section for IMAGICK.
  8.  Note:  If you are using WordPress, please read this post to make sure you don’t get JSON errors.

WordPress There was an error. The response is not a valid JSON response.

If you are running WordPress on IIS and experiencing this issue, another thing you can check is the FastCGI settings to make sure the OPTIONS verb is allowed.

In my case, I am using a brand new setup of WordPress on a Windows Server 2019 IIS 10.0.  When I went to Appearance, Widgets, made a change and clicked “update” I would get the “There was an error. The response is not a valid JSON response.” message.

I looked at all my other settings including SSL, Permalinks, etc. and they all looked good.

THE FIX

On the site with this particular “There was an error. The response is not a valid JSON response.” issue, the fix was easy.

Go to Handler Mappings for the site in question.

Double click the version of PHP that is setup (under PHP Manager)

Go to REQUEST RESTRICTIONS

VERBS

Make sure either “ALL“, or “One of the following” is selected.  If “One of the following” is selected, use this list:

GET,HEAD,POST,OPTIONS

 

Save your changes/close the dialog boxes and retry your save operation.

WordPress 4.x auto updates under windows

If you want your WordPress install to do auto-updates (in a Windows Server based hosting setup), you need to do one simple step.

 

Edit the hosts file.

Put a local IP in there for the domain name of the site.

Save the changes.

 

Example:

10.5.5.5  www.whatever-the-site-is.com

Re-log into WordPress and go to dashboard-updates and in there it should tell you “future updates will be automatically applied”

Why is all of this needed?  WordPress uses PHP CRON and that is reliant on the server being able to find the local website.  Therefore it is necessary to put a hard-coded IP in the hosts file so the CRON job can “see” the wordpress site.  Without the hosts entry the website will resolve to the external IP of the site, and you will have an unreachable IP issue and auto-update won’t work.

Proper FTP setup via IIS using Passive FTP

Since PASSIVE FTP seems to be a relative standard (that I experience), and since most clients don’t understand or want to use “ACTIVE” FTP, here is the easy way to configure your firewall and FTP software on an IIS machine to permit PASSIVE FTP.

Firewall Setup

You’ll need two rules and one “one to one” NAT mapping (this may vary a bit due to your firewall software).

The one to one NAT mapping needs to map the external IP address to the internal IP of the server.  Such as “66.33.123.21” mapped to “10.1.1.21”

One rule to allow the world into TCP port 21, mapped to the specific server in question.  (Allow * from ANY to 10.1.1.21 TCP port 21).

Second rule, specifically for PASSIVE FTP.  Allow * from ANY to 10.1.1.21 on ports range 50000 to 50100.

FTP Server Setup

We normally use Filezilla Server (latest version, of course).

Add a user and setup the standard settings.

Passive settings are as follows (below).

Most importantly, the “X.X.X.X” area below is your PUBLIC IP that is mapped through your firewall.

Click OK and save the settings.

FTP1

 

FTP Client Settings

Nothing fancy here, just check to make sure the settings look like this:

FTP2

Throttling bandwidth on an IIS based site

If you need to throttle (or limit) the amount of bandwidth a specific site on Microsoft Server — this is for you.  This should work with any Microsoft Server OS from 2008 to present. Open IIS. Go to the specific site in question (in the tree to left expand and click on the specific site name).

on the right side panel, click Configure — Limits.

Check “limit bandwidth usage” and type in a number.

Click OK.

limits

eXtplorer does not allow login under PHP 5.6 and IIS Windows Server

Have you deployed out eXtplorer and received this error:

PHP Deprecated:  Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in X:\XXXXXX\WWW.AAAAA.com\www\libraries\JSON.php on line 828

it’s an easy fix.

edit the file

X:\XXXXXX\WWW.AAAAA.com\www\libraries\pear.php

edit line 247

change this:

function isError($data, $code = null)

to this:

static function isError($data, $code = null)

How to prep a Windows 2012 R2 Update 1 server for PHP / WordPress

1) Presuming you have already loaded the OS onto the machine (whether virtual or physical)
2) Join the machine to your business domain
3) windows updates
4) reboot
5) windows updates (again until no more updates)
6) configure role -> Web server and under Application Development, pick .NET Extensibility 3.5
7) once that is complete, run windows updates again
8) probably you’ll need to reboot
9) check windows updates ONE MORE TIME
10) install the Web Platform Installer (version 5.0 as of this post), from here: http://www.microsoft.com/web/downloads/platform.aspx
11) after the WPI is installed, run it and choose the following: PHP 5.6.0 (or later), Windows Cache Extension 1.3 for PHP 5.6, PHP Manager for IIS
12) install those programs, when complete, open the IIS manager
13) verify that you see the following: URL Rewrite, PHP Manager under the main server features panel
14) download the latest version of PHP. (for me, it was 5.6.3)
15) unzip and move it to a new folder under “Program Files (x86)”\PHP\ called v5.6.3 (you should see v5.6 in there).
16) Make a folder called PHP-TEMP on the C:\ root
17) Give it the following permissions, IUSR and IIS_IUSRS to full control
18) Go to the PHP manager and register the new version
19) in the PHP manager, go to Manage all Settings and update the following:
Error Log -> PHP-TEMP directory
Memory_limit = 512mb
Post_Max_size = 10M
upload_max_filesize = 10M
upload_tmp_dir -> PHP-TEMP directory
SMTP->your internal email server IP
session.save_path -> PHP-TEMP directory
==
20) stop the default site
21) create your new site
22) make sure a static IP is assigned to the server for step 21
23) make sure firewall rules are in place to permit traffic to that IP
24) move or deploy the new wordpress site
25) adjust IIS settings-> Logging location and daily roll over, URL Rewrite rules for domain name and wordpress
26) you should have a web.config file from a previous (working) wordpress install. Use that for the above two things.

>more to come<

ASPMAKER v11 Image Resizer not working under IIS

If you are using ASPMAKER by HKVSTORE to build web admin interfaces, and you’ve arrived at this page, it’s likely because the Image Resizer ASP.NET add-on is not working for you.

Does this look familiar to you?

Warning: ASP.NET 2.0 or later is required but ASP.NET script is not executed properly on this server:

see this screenshot:2014-07-08_15-47-49Here is the solution to the issue.

  1. You need to have a HOSTS file entry on the server that will allow the server to resolve the domain name for the website you are using ASPMAKER and the Image Resizer on.  This is because the ASP.NET resizer uses MSXML2.ServerXMLHTTP to locally fetch and resize the image.  If there is no HOSTS file entry on the local server, there is no way for the resizer to work.
  2. Open the HOSTS file and add an entry like this
  3.  X.X.X.X   your.domain.name
  4.  Make sure the upload folder is set properly in ASPMAKER here:file temp
  5.  This path will be relative to the folder you have deployed the ASPMAKER files to on the server.  For example, if the ASPMAKER files are in the directory /123/ then the upload folder (pictured above) will be /123/upload-temp/
  6. set the permissions properly on the /upload-temp/ folder.  this means adding machinename\IUSR and granting full control.
  7. Inside ASPMAKER, make sure the destination folder is correct. Note I had to use “../” to get ASPMAKER to upload to the correct path off the root.  It is NOT necessary to grant this folder any special permissions.correct-path
  8. Make sure the base site itself has a valid application pool assigned.  Here’s what mine looks like (It is not necessary to have an application for the subdirectory where the ASPMAKER app). app
  9. NOTE: depending on your setup, it may be necessary to set the .NET CLR version to v.2.X above.  (I HAD TO USE v.2.X for my setup…)
  10. Adjust the maximum file upload size in ASP.  ASP->Limits Properties ->Maximum Requesting Entity Body Limit.  The default value is 200,000 (200000) which is 200,000 bytes.  I upped mine to 20,000,000 (leave out the commas here).
  11. Launch the ASPMAKER web admin and try uploading an image.  The above should take care of all the issues.

Let me know if this saves you a headache!

 

 

Permission denied error dealing with Classic ASP loadpicture

To solve the following error, which is generated by the loadpicture object

Microsoft VBScript runtime error ‘800a0046’
Permission denied: ‘loadpicture’

set myImg = loadpicture(“C:\aaa\asdf.jpg”)

==

The solution is to simply add this permission as full control

servername\IUSR

to the directory in which this object is going to work…

1 2 3