Mini Servers: Apache 2.2.9 PHP 5.2.6 Portable - MySQL Support
Compact but fully functional.
Mini Server 8 using Apache 2.2.9 and PHP 5.2.6 Core MySQL support
This mini server is based on mini-server 6 its main purpose to show how to enable MySQL server support. Its not difficult and as an added bonus I have included a mini version of phpMyAdmin.
Downloading a working version of this server is the easy option however I trust you will have a go at manually updating server 6 you will learn so much more. I have included detailed information along with some common pitfalls and the type of error messages reported.
I have assumed you have taken the opportunity to downloaded a full version of PHP this allows you to pick up PHP extensions the required.
Note: Check the support files section for server download details.
The server has the following specification:
- Server shall be portable
- Static HTML and Dynamic PHP pages shall be served.
- The server shall log all web requests.
- All unused modules shall be disabled.
- MySQL support shall be provided.
PHP MySQL Support
Enabling MyQL support in PHP is extremely easy uncommenting the appropriate line in php.in and make sure you have the appropriate extension in the extensions folder.
- Edit php.in located in folder \mini_server_6\udrive\usr\local\php
Locate the line (679) ;extension=php_mysql.dll (uncomment to enable)
Change to: extension=php_mysql.dll
- Create a new folder in folder php named extensions
Note: You can use any name for this folder so long as the line (541) extension_dir = "/usr/local/PHP/extensions/" matches the name chosen
- From the full PHP download copy file php_mysql.dll from the ext folder to the extensions folder.
That’s all there is to enabling MySQL, if you require other extensions copy these across and uncomment the appropriate line in php.ini.
Quick test, start the server with luck you will have killed Apache!
I purposefully excluded one crucial step to highlight the problem of either not finding libmysql or finding an incompatible version. Possible errors you will receive will be similar to these:
If you have never installed a program requiring MySQL support libmysql.dll will not be found. You will be greated with this error message when starting the server:
"This application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem."
A version of libmysql exists however it is not compatible with the version of PHP currently being used
The first error is self explanatory libmysql.dll was not installed hence cannot be found.
The second error is a little more interesting Apache has picked up the wrong version of libmysql certainly not clear from that error message. There are two causes for this, libmysql is from an older installation (I used a MySQL4 version) or it is the correct version number but not compiled alongside the existing version of PHP.
Apache searches the system paths (C:\windows and C:\windows\system) and then looks in its own installation folder to find libmysql. It will use the last one found, if you have previously installed any software that uses libmysql and removed that software the chances are libmysql is not removed. If you forget to locate the new version of libmysql in the correct folder say during a manual installation the wrong version will be picked up.
When faced with this problem you first need to choose the correct version of libmysql. There are two possible candidates the one that comes with PHP or the one from MySQL. With luck you will find these are identical if not use the one from the full PHP download.
Where to place it? Do not place it in the system path otherwise you loose portability. You can copy it from PHP to the Apache bin folder and it will be picked up. The only problem with this when upgrading PHP will you remember to copy it across!
My preferred solution is to force Apache to download the binary from the PHP folder.
Add the following line: Loadfile "/usr/local/php/libmysql.dll" to the end of the module list as shown below:
|httpd.conf located in folder: *\udrive\usr\local\apache2\conf||Comments|
LoadModule php5_module: Module required to handle PHP5 pages.
Note: The order is important Loadfile occurs before LoadModule php5_module
If you have not already done so copy the file libmsql.dll from the full download to folder PHP.
Quick test, start server and check the server error_log file contains no errors.
I thought it worth detailing the above because libmysql has caused numerous problems in the past. Before looking at the support section I would like to introduce PHP Mini SQL Admin
PHP Mini SQL Admin
On Source Forge I discovered an interesting little project PHP Mini SQL Admin by Oleg Savchuk because of its small size makes an Ideal companion for the mini-server series.
I have included this in the download it is easy to use and very small, a single page weighing in at 23K.
Image to the right shows PHP Mini SQL Admin's login in page.
It may have a small footprint however it supports some very powerful features:
- Simple login interface allows logging into any database.
- Perform any SELECT statements and instanly view results.
- View all tables in Database and export these
- INSERT/UPDATE/DELETE/DROP also supported time tracking
- Click a link EXPLAIN table MySQL statement provides you with more detail
- You can easily obtain CREATE TABLE information for any table
It is a versatile script allowing you to explore and beak a few mini-servers. Like Uniform Server if you break one delete it and install a fresh copy and start again.
Each mini server is complete and zipped into a single self-extracting archive file.
Download this server from SourceForge Project Page save the file mini_server_8.exe to any folder of your choice.
Note: Check out the mini server's support and download page detailing how to obtain full binaries for Apache and PHP.
Double click on mini_server_8.exe, starts the extraction process.
No need to change the folder destination, click extract, this creates a new folder mini_server_8 containing the following:
Testing is straight forward.
- Start the server by double clicking on server_start.bat (automatically detects free drive letter creates new virtual drive and runs the server.)
- Start a web browser.
- Type http://localhost:8088/ into the browser address bar.
- An index page is displayed, check out test sites test1, test2 and guestbook.
- Stop the server by double clicking on server_stop.bat
- Start mini-server 11
- Start mini-server 8
- Start a web browser.
- Type http://localhost:8088/ into the browser address bar.
- Click link: PHP Mini SQL Admin - Connects to a MySQL server
- In the login box type the following:
User name: root
MySQL host: localhost
port: 3311 Note: Uniform server uses 3306 and mini-server 12 uses 3312
DB name: leave blank
- You are now connected to a MySQL server (mini-server 11) where you can issue SQL commands.
- Stop both servers.
Your web site
Open the folder www located in folder *mini_server_8\udrive\www (Note * is the path to the folder you extracted the server files) delete everything in www and copy your site into it.
Note: Make sure one of your pages in folder www is named index.html, index.htm or index.php, otherwise you will need to type a page name in every time to access your site.
Change Virtual Drive
The server automatically detects the first free drive letter and uses that to run the server on. You can override this in one of two ways:
- Start the server using a drive parameter for example: server_start.bat z this forces the server to use drive z
- Edit server_start.bat, locate the following line:
rem set Disk=w
Remove the rem and replace w with the letter you want to use for example:
set Disk=x Forces the server to use drive letter x
Change server default port
- Open file: httpd.conf (Located in folder: \mini_server_8\udrive\usr\local\apache2\conf)
- Locate the lines:
- Change to:
This moves the server to the standard secondary web server port
Note: Type http://localhost:8080 into a browser to view the site.
If port already in use try any value above 2000
If you wish to run several mini servers at the same time create a new folder for each server and copy contents of mini server 8 into each of these.
Change the server port for each server to be unique. The servers may be started in any order.
Note: You can run the mini servers alongside Uniform Server 3.5-Apollo however you must start Uniform Server first.
I have covered how to enable MySQL support this along with PHP allows you to access a MySQL server and produce dynamic web sites. Learning SQL phpMiniAdmin provides a very neat clean interface.
Apache with PHP makes for a very powerful dynamic page server, if you prefer to explore using Perl the next mini server has this covered.