WordPress in a nutshell: WT-NMP
Some of us might want to run WordPress in a sandbox, where the meaning of “sandbox” is, a nearly closed environment or a replaceable medium like an USB stick.
One solution can be using Instant WordPress and install WordPress on an USB stick. Instant WordPress uses Apache, PHP and MySQL, but there are a few drawbacks. Normally the bundled version of WordPress is very old and you can not change it. The PHP- and MySQL Versions were also fixed and cannot be changed. All in all, Instant WordPress is a pretty package but not very useful with its old software versions which are not replaceable.
Another solution could be a self-made package with Nginx. Nginx became some time ago very popular because of its speed. So I downloaded it and tried to install it, but there were some conflicts with my already installed XAMPP. And by the way, it is not very easy to configure Nginx. There are several tutorials, but most of them are out of date or hard to understand.
As long as there is no other server software (like XAMPP or a standalone Apache server) installed, it is possible to use Nginx in a self-made package. Much more comfortable would be a ready-made package with Nginx, PHP and MySQL.
I found WT-NMP and I was excited about it. WT-NMP is something between XAMPP and Instant WordPress. It includes a configured Nginx server, PHP and MySQL. You can download an installer or a zip archive, which can be installed in a directory on the hard disk or on a replaceable medium like an USB stick. But WT-NMP can do more: it configures itself wherever you installed it. Even if you move the already installed package, it will reconfigure itself after moving.
It does not includes WordPress, but I see this as advantage, because I can decide which version of WordPress I like to bundle with it. If you use the zip archive, it is possible to create your own packages and you can decide which PHP- or MySQL-version, which WordPress version or other software will be included.
How to …?
You need WT-NMP, WordPress and 5—10 minutes of your time.
Extract the zip archive of WT-NMP in a directory on your hard disk (or an USB stick or wherever you want it). In the example below I will use the hard disk
D:/ and the directory
WT-NMP. Then you have to configure some things. In the newly created directory you can see some sub-directories.
WWW is your document root, and as you might expect, it’s the directory for your web projects. If you open this directory, you will see three other directories:
The directories starting with
project, can be deleted. They are just examples. In the
tools directory are some useful tools, you can add your own tools there. If you open the
index.php inside the
WWW directory, you will find instructions on how to add your own tools.
The next step is to extract WordPress into your document root (the
WWW directory). In this example, I extract WordPress in the directory
wordpress. You could also create another WordPress installation (e.g. a WPMU installation) by extracting WordPress in a second directory.
At this point, we are ready for a first test run. Navigate to your
WT-NMP directory, and start the WT-NMP manager (
wt-nmp.exe). If the installation was successful, you will see the number of processes beside of each component. If the server does not start, navigate to
WT-NMP/bin/nginx-[version]/logs and open the file
error.log. Ok, it’s not very logical because there is another
WT-NMP/logs. In the first one (
WT-NMP/bin/nginx-[version]/logs) you will find startup errors. In the other one, you will find errors occurring during operating.
If the server and the components were started successfully, start your browser and open
http://localhost. You will see the start page of WT-NMP, listing all your web projects and tools. As we are already here, we can also set the database for WordPress. It’s a matter of taste if you will use Adminer or HeidiSQL. Click on Adminer and add a database for your WordPress installation. Click on the Create new database link in the top, enter a name for the database (e.g.
wordpress) and hit Save. Now you would create a new user for your new database. Click on the Privileges link (the one beside the key icon), then on Create user link under the table of users. Enter a name and password, check the All privileges and Grant option checkboxes and hit Save at the bottom of the page. That’s all.
Now it’s a good idea to adjust some settings in the
php.ini. This step is recommended but optional. There is only one really important setting you have to change, all other settings are good enough for a basic setup.
In the next steps we only need files from the
config directory. Please only edit the files in the
config directory. Do not edit the files in other folders except the
WWW folder. The reason is, the other files are templates when WT-NMP will be installed or moved to another directory. So, if you want to edit the
config/php.ini and not
php/php.ini as you might expect.
Lets start with the adjustment:
- Go to line 19, it’s the one which starts with
disabled_classes. Remove all entries from this option (
disabled_classes =). WordPress uses SimplePie, and SimplePie needs these classes. If you leave the classes disabled, SimplePie won’t work and throw a lot of errors.
- Check the entries in line 18 (
disabled_functions). Normally you would not use the sandbox in a production environment, so you can trust yourself and active the “dangerous” functions. Some of these functions are very helpful during development. So you might like to activate them.
- (optional but recommended) Raise the
memory_limitfrom 64M to 128M (or more, depending on your system and your needs)
- (optional but recommended) Disable
short_open_tag = off)
- (optional but recommended) Activate XDebug
- If you need caching, activate Xcache and/or OPcache. There are some pitfalls when using this caching mechanism, please refer to the WT-NMP homepage for more details.
- On my Windows7 64bit system, I have to enable the MySQL extension (not the already activated MySQLi extension), because WordPress is a little bit … late. If WordPress cannot connect to the database, try to activate the MySQL extension.
That’s all for PHP.
Your own server
If you don’t want to use
http://localhost/wordpress/ as domain name, you have to setup your own server in the
nginx.conf. Open the file, and just copy the already existing default server. Paste it after the default server and change this:
- Remove the
- Change the server name from
localhostto your domain
- Adjust the path to the document root after the
That’s all for Nginx. This is a very basic server setup but enough for the beginning. If you use Nginx intensively, please read some tutorials on how to setup a Nginx server for WordPress. You can find some good tips in the Nginx documentation or in the WordPress codex.
I don’t have to adjust any settings in the
mysql.ini. But it could be useful to raise the timeouts (
connect_timeout) if WT-NMP is installed on a slow USB stick.
And finally do the famous five-minute install of WordPress. Edit/create your
wp-config.php or just open your new WordPress blog in your browser and let WordPress do the job.
If you wish to install other PHP versions (maybe you need PHP 5.2 because it’s the minimum requirement of WordPress), it is as easy as all the steps before. Just download the zip-archive of the PHP version you need (maybe visit the PHP museum). You need the NTS (non thread safe) version because Nginx uses the CGI mode of PHP. After downloading the zip archive, extract it into the
bin directory of your WT-NMP installation. WT-NMP will list the new PHP version in the WT-NMP manager.
If you want to use XDebug, you also need a suitable version of the XDebug library. Just copy the library into your new PHP folder.
In my opinion, WT-NMP is the best package to build sandboxes with or without WordPress. It is easy to install, to maintain and to configure. It’s even easy to move a sandbox from one place to another (e.g. hard disk to USB stick).
The ability to use more than one PHP version with WT-NMP makes development a bit easier. And last but not least, Nginx is a lightweight, scalable server with high performance. We will see more Nginx servers in the near future, so it’s always good to know how to configure WordPress for another server than Apache.