Speed up MyBB on IIS installations

If you do run MyBB on a Windows Server with the built-in IIS webserver you might notice that MyBB is slower on IIS installations than on Apache.

The reason is in the database connection of the default installation of MyBB. The default value for the database server is localhost which is correct for most installations. On IIS, setting localhost as database server will cause a DNS lookup in the system. This DNS lookup takes some time and slows down your MyBB on every single database connection start.

The lookup can be prevented which saves you up to two seconds on each pageload if you do not set localhost as database server but use the IP of the database server. In most cases, you’ll have the database on the same – local – server and the IP will be 127.0.0.1.

Use the IP 127.0.0.1 instead of the localhost on MyBB installation for IIS. If you have already installed MyBB, you can still switch to the IP based database server location. To do that download the following file via FTP:
/your-mybb-path/inc/config.php

Open it with a text editor like notepad++ and find the line 14 which should look like this:
$config['database']['hostname'] = 'localhost';
Replace it with this line:
$config['database']['hostname'] = '127.0.0.1';
If you do have a different IP for your database host, use the different IP adress.

Save the file and reupload it to your mybb folder, overwriting the old existing file.

Your MyBB should work with the new connection directly. If everything is fine you are done. You should now notice that your MyBB pages are loaded much faster on the IIS webserver.

The solution has been tested on Windows Server 2012 and 2012 R2 with MyBB 1.8. Other software configurations should work just as well.

Leave a Reply

Your email address will not be published. Required fields are marked *