LOGO

Portable Web Server with Server2Go - A How-To Guide

March 23, 2011
Portable Web Server with Server2Go - A How-To Guide

Testing Websites Locally: The Need for a Local Server

For bloggers and web designers, website maintenance and enhancement represent a continuous process. The ability to preview modifications, whether to a template or specific code, before deployment is invaluable.

Numerous WYSIWYG applications facilitate the creation and previewing of static HTML pages. However, websites built on PHP, such as those utilizing WordPress, require a more robust solution.

The Requirements of a PHP-Based Website

A functional local environment for PHP-based sites necessitates a web server capable of processing both PHP and MySQL. This ensures accurate emulation of the live environment.

Previously, MakeUseOf has explored various methods for establishing a local web server, including reviews of Linux web server software and XAMPP for Windows.

Server2Go: A Portable Solution

While these solutions are effective for dedicated development machines, a portable option is desirable for those who work on the go. Imagine being able to test website changes from a USB drive or portable hard drive, regardless of internet connectivity.

Server2Go, though currently unavailable, offered a streamlined and easily deployable solution for creating a portable PHP web server.

This allowed developers to maintain a consistent testing environment across multiple computers without complex installations.

It provided a convenient way to verify changes before publishing them to a live web server.

The portability aspect was particularly beneficial for individuals who frequently travel or work remotely.

Deploying a Functional Web Server on Portable Media

The simplicity of installing and operating Server2Go on a portable drive is remarkable, especially when contrasted with the complexities of traditional web server configurations. This solution proves particularly valuable for developers like myself, who require a safe environment to implement design modifications to a blog template without risking disruption to the live site. Consequently, I undertook a trial of Server2Go to assess its capabilities.

Upon downloading and extracting the Server2Go files, you’ll observe a directory structure mirroring that of a standard web server, with "htdocs" designated as the public directory for your web pages. Notably, no installation process is necessary.

portable-test-web-server-server2go-2.jpg

Simply transferring these files and directories to your portable drive is all that’s required. If your intention is solely to test a website constructed using HTML or PHP, the setup is complete. Copy your site’s files into the htdocs directory, launch the web server by executing Server2Go.exe, and access it via http://127.0.0.1:4001/ – the default localhost IP address defined in pms_config.ini.

This streamlined approach provides a readily available web server for testing any website, anytime, anywhere. However, what if you need to deploy a complete PHP site incorporating a backend SQL database?

Server2Go was initially designed to function from a read-only CD, meaning that database modifications are not saved by default. To enable the server to retain your settings, you must modify pms_config.ini, setting LocalMirror=0, OverwriteLocalMirror=0, and DeleteDatabaseFiles=0.

Ensure this modification is performed before proceeding, as failure to do so will result in the loss of your configurations. Following this adjustment, access phpMyAdmin by navigating to http://127.0.0.1:4001/phpmyadmin/ and logging in as root without a password.

portable-test-web-server-server2go-3.jpg

Proceed to create your database, ensuring the name matches that used by your live website. For a Wordpress blog, this will correspond to the database name specified in your wp-config.php file.

portable-test-web-server-server2go-4.jpg

Next, create a new user with the same credentials as your live Wordpress blog. This can be accomplished in phpMyAdmin by entering the following SQL commands:

"CREATE USER 'my_id'@'localhost' IDENTIFIED BY 'your_password';"

"GRANT ALL PRIVILEGES ON *.* TO 'my_id'@'localhost' WITH GRANT OPTION;"

"CREATE USER 'my_id'@'%' IDENTIFIED BY 'your_password';"

"GRANT ALL PRIVILEGES ON *.* TO 'my_id'@'%' WITH GRANT OPTION;"

With the database now configured, transfer a complete copy of Wordpress to your portable web server by copying all Wordpress files into the htdocs directory.

portable-test-web-server-server2go-5.jpg

Remember to edit wp-config-sample.php, inputting your database and user information, and then rename the file to wp-config.php. Access "http://127.0.0.1:4001/wp-admin/install.php" to initiate the installation process, and you should encounter the following screen.

portable-test-web-server-server2go-6.jpg

You now have a fully functional local installation of Wordpress! The subsequent step involves exporting your database from the live site and importing it into this local instance. Numerous backup procedures have been detailed on MUO, with Dean’s database backup plugin being a particularly recommended option for seamless data transfer.

It’s important to note that while the database backup will migrate posts and comments, the theme and formatting will not be transferred. To replicate these elements, copy the entire wp-content directory from your online blog to the corresponding directory in your local installation. Activate the necessary plugins and configure the theme to mirror your online setup, resulting in an exact local replica of your website or blog.

Below is a local instance of my own blog, running on Server2Go.

portable-test-web-server-server2go-7.jpg

This allows me to refine the template and experiment with new plugins and widgets before deploying them to the live website. Having previously experienced website downtime due to widget modifications, this approach offers a significantly safer testing environment.

We encourage you to try Server2Go on your own portable drive and share your experiences. What innovative applications can you envision for such a portable and rapidly deployable web server? Please share your ideas in the comments below.

Image Credit : El Frijole

#Server2Go#portable web server#web server#testing#development#localhost