WordPress Downloading Update with Fatal Error “Maximum execution time of 60 seconds exceeded”.

When updating WordPress, this error might not be what it seems –

PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\WampDeveloper\Websites\domain.name\webroot\wp-includes\class-http.php on line 1610.

Fix – Disable all modules before doing the upgrade. Lots of errant modules freeze everything when WordPress is upgrading itself.

Other Cause – If an errant module is not the issue, run a phpinfo.php file with <?php phpinfo(); ?> in the website’s webroot (DocumentRoot) folder to see what value of max_execution_time is set at in php.ini.

Check .htaccess, VirtualHost files, php.ini, WP’s wp-config.php for any additional/overriding settings.

Another Cause – Sometimes hard-coded time limits are set in WordPress’s script files.

Run a string search of all *.php files in WordPress’s folder for strings:
A) “set_time_limit” –
looking for set_time_limit(60);
B) “max_execution_time” –
looking for ini_set('max_execution_time', 60);

Changing WampDeveloper’s Default Text Editor and Browser

Is there any way to change the default Text Editor and/or Browser?

I absolutely HATE notepad.
I absolutely HATE Internet Explorer.

Hopefully it can be done!

The user-interface of WampDeveloper opens (outside of it):

  • Via Notepad – text based files such as websites’ VirtualHost files, website access and error log files, Apache/PHP/MySQL error log files, and Apache/PHP/MySQL configuration files.
  • Via IE – websites and their URLs.

For the users that prefer to use another Editor and/or Browser there is a solution.

Website Browser

WampDeveloper will use whichever Browser is set as default on Windows…

You can set the default Browser choice in –

Control Panel > Default Programs

You can usually also set this from within the Browser… For example in Chrome’s menu, select Settings, and in the "Default browser" section, make it so. But if that does not work, you’ll have to set it manually as above.

File Editor

WampDeveloper is configured to use Notepad, as it is the simplest editor for the task at hand (except for the task of opening very large log files).

To change to another editor –
1. Edit file WampDeveloper.xml.
2. In the values group, change the value of the key named editor from "notepad.exe" to the application name of your Editor (no quotes).

Restart WampDeveloper for changes to take effect. If WampDeveloper will not start after making the WampDeveloper.xml edit, the XML structure is not correct – delete file, start WampDeveloper again, and it will re-create this file.

If this Editor’s location is not in the system’s "Path" environmental variable (that holds all the locations to check for the provided file-name), you should be able to place the full path as the value above.

Otherwise, you can also insert the Editor’s folder into the system’s "Path" environmental variable…

1. Control Panel > System > Advanced tab, click Environment Variables.

2. In "System Variables" group, edit the "Path" (or "PATH") variable by adding to the end of its string:

;"C:\Program Files\Editor\exe-containing-folder\"

* The semi-colon (;) separates all the paths from each other by signifying the ending of one path and the beginning of another, and the quotes (") around the path is used when there is a space in that path.

3. Restart system for changes to the Environment Variables to fully propagate and take effect (* this is not always necessary).

How to automatically restart Apache Service on Windows (and recover from crash)

Automatic Service Recovery

Use Windows’ built-in Service Recovery to restart Apache on each crash.

Run services.msc.

Select/open the Apache service.

(WampDeveloper’s Apache service is named “WAMPDev.Apache”)

Under Recovery, select to restart the service on each crash…

First failure: Restart the Service
Second failure: Restart the Service
Subsequent failures: Restart the Service

Reset fail count after: 1 day
Restart service after: 1 minute

(no other options selected)

This will attempt to restart Apache on a crash, after waiting 1 minute.

Limitations

The above Service Manager will only restart a crashed Service if that service crashes with a returned non-zero exit code…

If the service crashes in any other way, such as with a zero value, or such as with no exit code – the Manager will NOT attempt to restart the Service. As that would suggest the crash was completely uncontrolled (i.e., the process blew up / the process did not catch nor handle any of the inner exceptions), and that the issue will continue to persist without further user-intervention.

Note that when Apache exits with error code 255, it is restarting itself automatically due to normal operations (such as when reaching the Recycle workers count), and this does not affect the Windows Services Manager restart counts…

[Sun Oct 30 13:28:15 2011] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Oct 30 13:28:16 2011] [notice] Apache/2.2.20 (Win32) mod_ssl/2.2.20 OpenSSL/0.9.8r configured -- resuming normal operations

(WampDeveloper’s path to log file is C:\WampDeveloper\Logs\Apache\httpd.host.errorlog.txt)

Windows Tasks

You can setup Windows Tasks to monitor and restart the Apache service via either a Batch file or a PHP script.

A script can also check your websites, and restart the Apache service if no response arrives.

Note that all Tasks need to be elected to run with elevated privileges since a Service is being controlled.

Batch File

The simplest possible Task is to just keep starting Apache every X minutes. If the service is already running, the command will be ignored…

net start WAMPDev.Apache

For more advanced options, check –
StackOverflow’s How to check if a service is running via batch file and start it, if it is not running?
SuperUser’s Automatically restart Windows service if it is not running.

PHP Script

Instead of a bat/batch file, you can also schedule a PHP script to execute via an independent/stand-alone PHP process…

Use run path:

C:\WampDeveloper\Components\Php\php.exe -n -f "C:/path/to/script.php"

The “-n” switch tells PHP not to load php.ini: no extensions, default settings. This would be ideal for simple scripts.

Application Monitoring

If the native Windows Task Recovery does not work, and/or for more advanced options, you would need an application to monitor and restart the service such as ServiceProtector or AlwaysUp.

Running Apache and MySQL side-by-side with IIS (or WebMatrix and Web Platform)

Only 1 process can bind to an interface (IP:port) on a system. And the first Service that takes the specific IP:port will prevent the other Services, that use the same IP:port, from starting…

Both Apache and IIS will try to take ports 80 (HTTP port) and 443 (HTTPS port) – on “0.0.0.0”.

And MySQL will try to take port 3306 – on either “0.0.0.0” or “127.0.0.1”.

“0.0.0.0” specifies binding to all IP addresses the system has (including 127.0.0.1). And “127.0.0.1” is the standard localhost IP, and it is used to bind services for local-access only.

To run multiple servers side-by-side (on the same system), 3 options are available (from the very simple to the more complicated):

A) Run Only 1 Platform at a Time

Stop IIS, start Apache. And vice-versa.

With multiple MySQL instances, run 1 at a time.

When using both MySQL and SQL Server, you can run both at the same time as they use different ports (and they will not conflict).

B) Keep Listeners Bound to the Default IP(s), But On Different Ports

This is only a valid solution for local use and local development.

Select each website in IIS (including the Default Website), change the binding properties from *:80 and *:443 to other ports such as 8080 and 8443.

Update Web Platform’s MySQL’s my.ini file to change “port = 3306″ to another port such as 3307.

Update URLs to Use New Ports

With the above re-binding, all IIS websites will now be reachable from URL:

http://domain.name:port/

How URLs Work

By convention, all web-servers use the same standard ports (for HTTP and HTTPS)…

When a request is made from your Browser to http://domain.name/path/, it resolves the domain name to an IP address, and the request is automatically sent to that IP on port 80 (and to port 443 for HTTPS traffic).

In effect, all standard URLs (i.e., without a user specified port) are short-hand for:

http://domain.name:80/
https://domain.name:443/

Update Database Connections

Webapp configuration files, other script files, and any programs that connect to Web Platform’s MySQL, will need to be updated to reflect the new port number to use.

This includes phpMyAdmin (phpmyadmin\config.inc.php).

C) Keep Default Ports, But Bind Listeners On Separate IP Addresses

Your system will likely have:

  • 1 Public IP
  • 1 LAN IP (such as 192.168.0.1 – which is accessible from all LAN connected systems and devices)
  • 1 localhost/loopback IP 127.0.0.1 (only locally reachable)
  • Many IPs in the range of 127.0.0.xx (that are only locally reachable)

It is best to have WampDeveloper’s Services include the use of IP 127.0.0.1 – otherwise you’ll have to use an editor to do an auto-search for all instances of 127.0.0.1 (and some variations that can be picked up with string “127”) in WampDeveloper’s folder to update the local configuration structure for use of another local IP.

Bind Apache from the default of “0.0.0.0” to specific IPs (including IP 127.0.0.1). And Web Platform’s IIS to another specific IP. And perform the same for multiple MySQL servers…

For Apache

Edit file – C:\WampDeveloper\Config\Apache\httpd.conf
Replace these two lines (one is at the beginning, the other at the end) –

Listen 80
...
Listen 443

With –

Listen ip.address.here:80
...
Listen ip.address.here:443

Preferably also include Listen 127.0.0.1:80 and Listen 127.0.0.1:443.

For Web Platform

Select all websites (including Default Website) in IIS and change their bindings to the other IP.

If another instance of MySQL was installed (via Web Platform), edit its “C:\Program Files\MySQL\MySQL Server\my.ini” file and change bind-address = 127.0.0.1 to the other IP.

If you have to keep Web Platform’s MySQL server on 127.0.0.1, bind WampDeveloper’s MySQL to something other than 127.0.0.1:

Edit file – C:\WampDeveloper\Config\Mysql\my.ini
Update line bind-address = 127.0.0.1.

Edit file – C:\WampDeveloper\Tools\phpMyAdmin\config.inc.php
Update all instances of “127.0.0.1” (that is used for the connection IP and in the access control list).

ProxyPass

You can run multiple servers at the same time and use the ProxyPass feature to have Apache act as the front-end, transparently proxying requests back-and-forth for specific URLs and websites.

This way you can have 1 public-facing server (Apache on port 80) serving all requests, and multiple back-end servers such as IIS and Tomcat running websites and scripts that use ASP.NET and Java.

Using Dropbox To Host or Backup Websites and Database Folders on Windows

There are two options to host and/or backup your local development environment’s (such as WAMP) Websites and Database folders with Dropbox.

Keeping Folders Outside Dropbox Folder

Create NTFS “Junction Points” (folder links) between sub-folders in your Dropbox folder, and WAMP’s \Websites and \Database folders…

mklink /j C:\path-to\Dropbox\Websites C:\WampDeveloper\Websites
mklink /j C:\path-to\Dropbox\Database C:\WampDeveloper\Database

Note that according to DropBox, this type of set up will only sync when the DropBox service or the computer is restarted (i.e., changes before a restart will not be backed-up)…

Dropbox will follow Windows junction points (Windows Vista or later) and sync the files or folders they link to. However, any changes to those files or folders made from the Windows operating system will not sync again until the Dropbox desktop application is restarted.

The reason this is so is because Windows only creates file-system events on the real end of a Junction Point, and not on all the paths.

Keeping Folders Inside Dropbox Folder

The other option is to move everything into the Dropbox folder –

1. After the creation of a website, move its Websites\domain.name\ folder into Dropbox\.

Then, in its original place create an NTFS Junction Point into Dropbox\Websites\domain.name\.

mklink /j C:\WampDeveloper\Websites\domain.name C:\path-to\Dropbox\Websites\domain.name

2. Move the Database\ folder into Dropbox\, and either:

A) create NTFS Junction Point in its original place into Dropbox\Database\.

mklink /j C:\WampDeveloper\Database C:\path-to\Dropbox\Database

B) or update all Config\Mysql\my-*.ini files to use the Dropbox path.

datadir = "C:\path-to\Dropbox\Database\mysql-data-*"

(and any other “\Database\” paths)

For WampDeveloper, note to reflect the accompanying MySQL version in “*”.

Notes and Limits

1. The mklink command will create the source folder as a Junction Point / Directory, with the link being made into the target folder…
A. The source folder must not exist, or has to be already deleted (mklink command will neither reform nor delete it).
B. The target folder has to already exist (mklink command will not create it).

2. Only Administrators can use mklink. Open command-line via “Run as admin”.

3. Junction Points can only point to folders and volumes.

4. Junction Points can only link across local volumes.

Disabling SSLv3 in Apache By Setting SSLProtocol (be aware of VirtualHost issue)

After doing some testing and debugging, it looks like there is a long-standing issue in openssl/mod_ssl that prevents changes to the SSLProtocol value made per VirtualHost from taking effect…

The value of SSLProtocol will be set permanently from the first SSL Virtual Host loaded by Apache. And further changes to the value in other SSL Virutal Hosts will not work and will fail silently (i.e., with no messages recorded in the error log).

It is unclear whether this is a openssl/mod_ssl bug or a general re-negotiation issue (related to SNI).

Correctly Disable SSLv3 Protocol

Edit the first VirtualHost loaded by Apache.

For WampDeveloper Pro this is –

C:\WampDeveloper\Config\Apache\extra\wampd-httpd.host.ssl.vh.conf

Update the SSL Protocol (SSLProtocol) to remove SSLv3 –

SSLProtocol all -SSLv2 -SSLv3

SSLCipherSuite

Make sure that you do not remove SSLv3 (with !SSLv3) from the SSL Cipher Suite (SSLCipherSuite) as it is used inside TLSv1.0…

You can verify that openssl uses/links the SSLv3 cipher inside the TLSv1 protocol with this command –

openssl ciphers -v "TLSv1" | sort
ADH-AES128-SHA      SSLv3 Kx=DH       Au=None Enc=AES(128)  Mac=SHA1
ADH-AES256-SHA           SSLv3 Kx=DH       Au=None Enc=AES(256)  Mac=SHA1
ADH-CAMELLIA128-SHA      SSLv3 Kx=DH       Au=None Enc=Camellia(128) Mac=SHA1
...
SRP-RSA-3DES-EDE-CBC-SHA SSLv3 Kx=SRP      Au=RSA  Enc=3DES(168) Mac=SHA1
SRP-RSA-AES-128-CBC-SHA  SSLv3 Kx=SRP      Au=RSA  Enc=AES(128)  Mac=SHA1
SRP-RSA-AES-256-CBC-SHA  SSLv3 Kx=SRP      Au=RSA  Enc=AES(256)  Mac=SHA1

Disabling the SSLv3 protocol fixes the POODLE vulnerability… The SSLv3 ciphers are not related to any vulnerabilities.

Test SSLv3 Vulnerability

You can test your configuration locally by running a manual openssl connection to check if the SSLv3 handshake fails…

openssl s_client -connect www.example.com:443 -servername www.example.com -ssl3

You can also check if the SSLv3 cipher is available (it should be)…

openssl s_client -connect www.example.com:443 -servername www.example.com -cipher SSLv3

Browser Compatibility Issues

While disabling the SSLv3 Protocol will prevent the POODLE attack, and mitigate on other security issues and vulnerabilities, it will also break SSL connections made by IE 6 (on Windows XP or older).

And if you follow the PCI requirements of also disabling TLSv1.0, this can break IE 10, 9, and 8 compatibility (when released they did not have TLSv1.1 nor TLSv1.2 enabled by default).

Automatically Backup MySQL Databases on Windows (WAMP)

The best way to create and automate backups of MySQL databases is to:

1. Use the Windows Task Scheduler to automatically run a backup task every day or week.

2. Have the task run a BATCH file containing the “mysqldump” and “makecab” commands to export and compress the databases.

3. For additional recovery, use MySQL’s Binary Log files to record transactions between backup jobs (to rebuild the database to the last transaction recorded).

This solution will work for everything from Windows 10, down to XP, and Server 2003. No external tools are required.

Backup MySQL Databases with Batch File

Create a mysql-backup.bat file to export all the databases (or only select databases), using a DATE-TIME file-name stamp, and compress the SQL file…

@ECHO OFF

set TIMESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REM Export all databases into file C:\path\backup\databases.[year][month][day].sql
"C:\path-to\mysql\bin\mysqldump.exe" --all-databases --result-file="C:\path-to\backup\databases.%TIMESTAMP%.sql" --user=username --password=password

REM Change working directory to the location of the DB dump file.
C:
CD \path-to\backup\

REM Compress DB dump file into CAB file (use "EXPAND file.cab" to decompress).
MAKECAB "databases.%TIMESTAMP%.sql" "databases.%TIMESTAMP%.sql.cab"

REM Delete uncompressed DB dump file.
DEL /q /f "databases.%TIMESTAMP%.sql"

Make sure to update all the paths used, and the MySQL’s username (root) and password (if no password is used, leave the “--password” switch out).

Why use CAB instead of ZIP?…

MS-CAB files have almost 50% better compression ratios over ZIP (especially for single files), and the MAKECAB/EXPAND commands exist on all Windows versions.

Scheduled MySQL Backup Task

Create a Windows Task to run the above BATCH file every day or every week.

Make sure that:

1. The user has rights to Log on as a batch job.

2. If the drive/path you are exporting to is a mapped drive, to use the UNC path.

3. If the drive/path is a shared folder, the user the task is ran on has the correct permissions.

Use MySQL Binary Log

Verify that my.ini has the Binary Log enabled, set to either a MIXED or ROW mode, and does not expire between backup tasks (make it 2x the frequency of the backup task schedule +1 day).

log-bin=mysql-bin
binlog-format=MIXED
expire_logs_days=15

This way you can restore to the last transaction recorded by replaying the log over the last backup job.