Difference between revisions of "Mini Servers: Apache 2.2.9 PHP 5.2.6 Portable - MySQL Support"

From The Uniform Server Wiki
Jump to navigation Jump to search
m (Text replace - "sourceforge.net/projects/miniserver" to "sourceforge.net/projects/uniformserver")
m (Text replace - "projects/uniformserver" to "projects/miniserver")
 
Line 138: Line 138:
  
 
=== Download ===
 
=== Download ===
Download this server from SourceForge [http://sourceforge.net/projects/uniformserver/files/MiniServer/MiniServer_%20Apache%202.2.9%20PHP%205.2.6%20Portable%20-%20MySQL%20Support/ Project Page] save the file '''mini_server_8.exe''' to any folder of your choice.
+
Download this server from SourceForge [http://sourceforge.net/projects/miniserver/files/MiniServer/MiniServer_%20Apache%202.2.9%20PHP%205.2.6%20Portable%20-%20MySQL%20Support/ Project Page] save the file '''mini_server_8.exe''' to any folder of your choice.
  
 
'''''Note'':''' Check out the mini server's [[Mini Servers: Support and download|support and download page]] detailing how to obtain full binaries for Apache and PHP.
 
'''''Note'':''' Check out the mini server's [[Mini Servers: Support and download|support and download page]] detailing how to obtain full binaries for Apache and PHP.

Latest revision as of 16:11, 17 October 2012

Mini Servers:  Introduction | Support | Server 1 - Portable | Server 2 - Service | Server 3 - Portable Authentication | Server 4 - Portable Authen. SSL | Server 5 - SSL Standalone | Browsers dislike self-signed certificates | Server 6 - PHP 5.2.6 Portable | Server 7 - PHP 5.2.6 Service | Server 8 - MySQL Support | Guest Book | Server 9 - Perl 5.2.6 Portable | Server 10 - Perl 5.2.6 Service | Server 11 - MySQL 5.0.67 Portable | Server 12 - MySQL 5.0.67 Service | Server 13 - MySQL 4.1.22 Portable | Server 14 - MySQL 4.1.22 Service | phpMyAdmin - Mini support | MySQL - General problems

Mini Servers:
Compact but fully functional.
Apache 2.2.9

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.

Top

Specification

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.

Top

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.

  1. 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
  2. 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
  3. 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!

Top

libmysql.dll Errors

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:

Top

Not found

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."

Uc libmysql error 1.gif

Top

Incompatible version

A version of libmysql exists however it is not compatible with the version of PHP currently being used

"The procedure entry point mysql_server_end could not be located in the dynamic link library LIBMYSQL.dll" Uc libmysql error 2.gif

Top

Problem

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.

Top

Solution

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:

Configuring Apache

httpd.conf located in folder: *\udrive\usr\local\apache2\conf Comments

# ==================================================
# Modules
# ==================================================
 LoadModule authz_host_module modules/mod_authz_host.so
 LoadModule dir_module modules/mod_dir.so
 LoadModule log_config_module modules/mod_log_config.so
 LoadModule mime_module modules/mod_mime.so
 LoadModule php5_module "/usr/local/php/php5apache2_2.dll"
 Loadfile "/usr/local/php/libmysql.dll"

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

Top

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.

  • Currently shown logging into mini-server 11
  • To login to Uniform Server use port 3306
  • Note: Password in both cases is root (default download)


If you do not require the power of phpMyAdmin this is an
ideal alternative. It removes the clutter allowing you to
concentrate on SQL commands.

Uc phpminiadmin login.gif

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.

Top

Support files

Each mini server is complete and zipped into a single self-extracting archive file.

Download

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.

Top

Extract files

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:

Top level folder mini_server_8 contains two files:
1) server_start.bat - Double click to start the
2) server_stop.bat - Double click to stop server
program folder: Uniform Server's programs that make the server portable
tmp folder: Stores temporary files such as sessions
apache2 folder: Contains all files associate with the Apache server
php folder: Contains files that make up the PHP core
www folder: This is where you put your web site or sites
Test sites: guestbook, test1 and test2 are test sites these are included to

provide an idea of the servers capability's. Delete these folders and
copy your sites into this folder (Referred to as the document root folder)

Uc mini server 8 dir.gif

Top


Test

Testing is straight forward.

Test 1:

  1. Start the server by double clicking on server_start.bat (automatically detects free drive letter creates new virtual drive and runs the server.)
  2. Start a web browser.
  3. Type http://localhost:8088/ into the browser address bar.
  4. An index page is displayed, check out test sites test1, test2 and guestbook.
  5. Stop the server by double clicking on server_stop.bat

Test 2:

  1. Start mini-server 11
  2. Start mini-server 8
  3. Start a web browser.
  4. Type http://localhost:8088/ into the browser address bar.
  5. Click link: PHP Mini SQL Admin - Connects to a MySQL server
  6. In the login box type the following:
      User name: root
      Password: root
      MySQL host: localhost
      port: 3311 Note: Uniform server uses 3306 and mini-server 12 uses 3312
      DB name: leave blank
      Charset: -default-
      Click: Apply
  7. You are now connected to a MySQL server (mini-server 11) where you can issue SQL commands.
  8. Stop both servers.

Top

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.

e.g. http://localhost:8086/somepage.html

Top

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:

  1. Start the server using a drive parameter for example: server_start.bat z this forces the server to use drive z
  2. 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

Top

Change server default port

  • Open file: httpd.conf (Located in folder: \mini_server_8\udrive\usr\local\apache2\conf)
  • Locate the lines:
    Listen 8088
    ServerName localhost:8088
  • Change to:
    Listen 8080
    ServerName localhost:8080

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

Top

Multi Servers

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.

Top

Summary

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.

Top


Uc small logo.gif Ric