Archive

Archive for the ‘Home Server’ Category

WAMP: MySQL Import Problems & Solutions

January 3rd, 2008 Stephen No comments

I struck 2 errors when trying to import database backup files into newly created SQL databases for my WAMP. This is how I fixed them.

One error was pretty straight forward, saying something like an error occurred (gee, thanks, that really pointed me in the right direction). I discovered that was because the file was too large.

But the other was one of the most ridiculous error messages I have come across in a long time. It just said something like “the server has gone away.” After I stopped laughing, and checked that my home server was indeed still where I last left it, I got down to sorting out the issues.

Both were solved by increasing size limits in php.ini and in my.ini

In php.ini, this is the key offender:

upload_max_filesize

However, changing this line alone won’t help with importing a large database. Here are the other settings you have to change as well.

Look for these:

post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

Then up the limits to these:

post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M

And in MySQL’s my.ini make sure this is added:

max_allowed_packet = 200M

Categories: Home Server Tags:

Quickly Setup a Home Server on Windows

July 7th, 2007 Stephen No comments

The scenario: quickly setup either a home web server, or a little home intranet, or both, on Windows XP.

Software:

Apache
MySQL
PHP
phpMyAdmin
Joomla

The following is my recommended way to install these programs. The order does matter. Apache should be installed before PHP.

Apache 2.2

Download Apache 2.2

Download and install Apache from http://httpd.apache.org/download.cgi. Look for the “Win32 Binary (MSI Installer)” version.

The file will be something like apache_2.2.4-win32-x86-no_ssl.msi You could even install an earlier version if you want to. Many people still prefer to use 1.3 versions.

Install Apache

To install simply double click the msi file:

You can install it where you like, such as in a “Server” directory. Somewhere special or more convenient is probably better than putting it in “Program Files” with everything else. So, for example, my Apache will go to C:\Server\Apache2

You’ll be prompted to fill out some basic “Server Information.” You can easily change it later. Now, since your just going to be installing for a local network, you can name it anything you want to. It can even be just a single word.

Network Domain: myplace.net

Server Name: myplace.net

Admin Email: your email address

On the next setup message, check the box for All Users, on Port 80, as a Service

After installing, Apache2 will be reading to go.

Start Apache

Look for the icon in the System Tray. Right click on that to start Apache or else bring up the “Monitor Apache Servers” and start using that. The little icon should turn green when it has started.

If you get “The requested operation has failed!” error while starting Apache, use the “Test Configuration” shortcut in the Start Menu to find the error. You’ll see any error in a command terminal. Often people get that when that tinker with the httpd.conf file.

Test Apache

You have at least 3 or more ways to test. Open a browser and type in: http://127.0.0.1/ or http://localhost/

You can even try http://your_computer_name/ or http://your_computer_ip_address_on_network/ (I’ll cover the fifth way–using the domain name or myplace.net you invented–below.)

If your browser shows “It works!” everything is fine.

Configure Apache

The file that loads and says “It works!” is located in the C:\Server\Apache2\htdocs directory. That directory is the default for all of your web pages. However, you can select another location. To do this, just open C:\Server\Apache2\conf\httpd.conf with a text editor. What you need to change is DocumentRoot. Once you have done that, find the <Directory “C:\Server\Apache2\htdocs”> reference and change that to the same location as DocumentRoot.

To get apache to automatically look for an index.php, search httpd.conf for DirectoryIndex and add the files you want apache to look for when a directory is loaded.

<IfModule dir_module>

DirectoryIndex index.php index.html default.html main.php

</IfModule>

There is more to do with the httpd.conf file, but that will do for now. Restart apache for the changes to take effect. Always remember to restart Apache after you edit httpd.conf or you will have a frustrating and perhaps confusing time trying to get things to work.

MySQL 5

Download MySQL 5

You can download and install MySQL from http://www.mysql.org/downloads/mysql/5.0.html Just make sure you get a Windows Essentials (x86) binary version.

The file will be something like mysql-essential-5.0.41-win32.msi You could even install an earlier version if you want to. Although I’m not sure how that will affect PHP. MySQL 5 seems fine to me.

Install MySQL

To install simply double click the msi file.

As with Apache, you can install it where you like, such as in a “Server” directory. For convenience, I put mine in the same directory where Apache is located. So, for example, my MySQL will go to C:\Server\MySQL.

You’ll be prompted to choose a few settings. If you want to change the directory choose the Custom Setup. The rest are as follows:

- Skip Sign-Up
- Select “Configure the MySQL Server now”
- Select “Detailed Configuration”
- Select “Server Machine”
- Select “Multifunctional Database”
- Select “InnoDB Tablespace Settings” – leave everything default
- Select “Decision Support (DSS)/OLAP”
- Make sure “Enable TCP/IP Networking” is checked and leave the port number at 3306
- Select “Multilingual” (if you think you need it)
- Select “Install As Windows Service”
- Enter your root password and leave “Enable root access from remote machines” unchecked
- Select “Execute” and installation will be complete.

Test MySQL

This step can be done after installing PHP. We’ll download phpMyAdmin and use that for a quick test.

PHP 5

Download PHP 5

Download and install PHP from http://www.php.net/downloads.php. Grab the newest 5.x.x Windows Binary zip package.

The file will be something like php-5.2.3-Win32.zip.

Install PHP

To install simply unzip the file, then copy the \php directory to where you like, such as in a “Server” directory. For convenience, I put mine in the same directory where Apache and MySQL are located. So, for example, my PHP will go to C:\Server\PHP

Rename e:\php\php.ini-dist to php.ini

Configure PHP

Open php.ini with a text editor and search for doc_root. Change the pathing of that to point to your Apache DocumentRoot dircectory. Now search a little further down for the extension_dir. Change the pathing to the \ext directory in your \php directory, i.e. C:\Server\PHP\ext. Next, search for ;extension=php_mysql.dll and remove the ; in front of that line.

That’s all I’ve needed to do with php.ini.

Configure Apache for PHP

There are a number of ways to run PHP in Apache. Some people install it as a module, but I’ve had problems with that. Instead I use the following method, which, like the module install, is described in the PHP install.txt file.

I installed it as a CGI binary by inserting these three lines into Apache’s httpd.conf. I put each of these lines where other ScriptAlias, AddType and Actions are to keep things consistent.

ScriptAlias /php/ “c:/php/”
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php/php-cgi.exe”

Warning

By using the CGI setup, your server is open to several possible attacks. Please read our CGI security section to learn how to defend yourself from those attacks.

If that warning is of concern to you, then perhaps install PHP as a module. However, if you just going to run a local network, or you going to put other checks in place, don’t worry about it.

At this point, we might as well sort out CGI as well. If it isn’t there already in <IfModule alias_module> (where you should have put ScriptAlias /php/ “c:/php/”), put this:

ScriptAlias /cgi-bin/ “C:/Server/Apache/cgi-bin/”

Now look for this section in httpd.conf and add a PHP Directory instruction, like this:

  1. “C:/Server/Apache/cgi-bin” should be changed to whatever your ScriptAliased
  2. CGI directory exists, if you have that configured.

<Directory “C:/Server/Apache/cgi-bin”>

AllowOverride None
Options None
Order allow,deny
Allow from all

</Directory>

<Directory “C:/Server/php/”>

AllowOverride None
Options None
Order allow,deny
Allow from all

</Directory>

Restart Apache to see if you get any errors.

Test PHP

You could load phpMyAdmin now, but for a quick test first, open a new text document and copy in these lines:

<?php

phpinfo();

?>

Call the file phpinfo.php and save it to Apache’s htdocs directory. Now, try http://localhost/phpinfo.php. It will be obvious to you if it is working or not. If you now want to do a quick test of MySQL and PHP together, copy this into a new text file and call it phpsql.php. Edit the login info. accordingly.

<?php

// hostname or ip of server (for local testing, localhost should work)
$dbServer=’localhost’;// username and password to log onto db server
$dbUser=’root’;
$dbPass=”;

// name of database

$dbName=’test’;
$link = mysql_connect(”$dbServer”, “$dbUser”, “$dbPass”) or die(”Could not connect”);

print “Connected successfully<br>”;

mysql_select_db(”$dbName”) or die(”Could not select database”);

print “Database selected successfully<br>”;
// close connection

mysql_close($link);

?>
Now, try http://localhost/phpsql.php

You could install ActivePerl, if you wanted to and configure that to work with Apache as well, but that’s beyond the scope of this brief setup. And besides, it isn’t necessary.

Configure Server

This brief how-to assumes that you are running your home server from one machine and your home intranet from another. If you want to put both on the same machine, search for information of running virtual hosts with Apache. I presume that’s how it’s done. You will also have to decide which of the two networks will have the default web port 80. The other one then have to run from a different port.

Home web server

Your home web server is probably working right now. To see if it is, type in your IP address and your should see the same thing as when you type in http://localhost/. If you would like a free domain name to use, follow this brief instruction.

In httpd.conf we already have the ServerName = myplace.net. You need to change that to the domain you select to use.

Home intranet server

In httpd.conf we already have the ServerName = myplace.net. If you have a web server running on another machine using port 80, then we need to use, for example, ServerName = myplace.net:8080. Don’t forget to change the listen instruction: Listen 8080

You can either rename your computer name to myplace.net or do this to use myplace.net as a URL:

Edit your “hosts” file located at C:\Windows\System32\drivers\etc. You will see this line in the file:

127.0.0.1. localhost

Under that, add this line:

127.0.0.1 myplace.net

Assuming that on machine with Apache has a local network address of 192.168.1.111, put that in the “hosts” files of all other network machines.

192.168.1.111 myplace.net

Now test it by running http://myplace.net or http://myplace.net:8080

Security

To restrict access to your network to certain machines modify the follow section in httpd.conf:

<Directory “C:/Server/Apache/htdocs”>

. . .
Order deny,allow
Deny from all
Allow from localhost
Allow from 192.168.1

</Directory>

Use the Allow instruction to specify IPs, or a part thereof for a range of IPs, as I did in the example.

phpMyAdmin

Install phpMyAdmin

Download and install phpMyAdmin from http://www.phpmyadmin.net/home_page/downloads.php. Unzip it to C:\Server\Apache2\htdocs. To install, follow the install instructions at the official wiki, which is here: http://wiki.cihar.com/pma/Quick_Install. The quickest way is to perhaps create a /config directory in your . . ./htdocs/phpmyadmin. Then run http://localhost/phpmyadmin/scripts/setup.php.

When it’s installed, just run http://localhost/phpmyadmin.

In preparation for the next stage, create a new SQL database. For our example, we’ll install Joomla, so create a database called joomla. Once that is done, you’ll need to set the permissions or nothing will work. From the main phpMyadmin page, select permissions, and then select either root or a user you might have set up. Choose the database you created and check the permissions for that user. The easiest thing is to just “Check All.”

Security

Remember that the rest of the world can now see your server. You’ll need security to protect people from accessing phpmyadmin and creating havoc for you. In your httpd.conf file, add this to lock everyone out:

<Directory “C:/Server/Apache/htdocs/phpmyadmin”>

AllowOverride None
Options None
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1

</Directory>

Restart Apache.

Joomla

Install Joomla (or PHP Fusion or Wordpress, or whatever).

Joomla, which began as an Australian project called Mambo, is perhaps one of the best open source CMS or content management systems you can get. It is found at http://www.joomla.org/. Just grab the latest zip package: http://joomlacode.org/gf/download/frsrelease/111/262/Joomla_1.0.12-Stable-Full_Package.zip. Unzip it into your . . ./htdocs directory, for example, or into into . . ./htdocs/joomla.

You have already set up a database, so now simply got to http://localhost/ and follow the install instructions.

In the configuration.php file, you can use myplace.net or myplace.net:8080 at the live_site name.

I don’t think I left anything out but please let me know if I have.

- Skip Sign-Up
- Select “Configure the MySQL Server now”
- Select “Detailed Configuration”
- Select “Server Machine”
- Select “Multifunctional Database”
- Select “InnoDB Tablespace Settings” – leave everything default
- Select “Decision Support (DSS)/OLAP”
- Make sure “Enable TCP/IP Networking” is checked and leave the port number at 3306
- Select “Multilingual” (if you think you need it)
- Select “Install As Windows Service”
- Enter your root password and leave “Enable root access from remote machines” unchecked
- Select “Execute” and installation will be complete.

Categories: Home Server Tags:

My Linux Home Server

February 22nd, 2007 Stephen No comments

This one of my old PIII servers, which I still have for backup and for my webcams, but that is definitely not my monitor, so no abuse please.

I had two Pentium IIIs. But I had to get rid of the clutter with the arrival of my new Dell Optiplex 745 and UltraSharp wide screen. I sold them to one of these guys in open back trucks who cruise around apartment complexes in Seoul, advertising that they’d buy old computers. We contacted one of them and he came over. The monitor you see in the picture went for around $3! The PIII not picture went for $2. I made the grand sum of $5 on the deal. It was a bit of a shock to discover how little they were worth on the market. And what does the guy do with them? He sends them to the Philippines.

I ordered my Dell Optiplex through Dell Korea and was very satisfied with the service. I did it over the phone to an English speaking Korean, rather then online, because there were a few things I wanted to have clarified. The machine was built quicker than expected, and I was kept up to date every step of the way. Moments after the machine was delivered to the guard at our apartment building, my wife received a phone call about it, and around the same time, I received an email from Dell.

Within a few days, I’d converted my Dell to a dual boot system by partitioning the disk and allotting half of it to Ubuntu Linux—the 64bit version with the 2.6.20-8-generic kernel. I then set about configuring it to work as a server.



OPTIPLEX 745

Processor – Intel® Core™ 2 Duo Processor E6600 (2.40GHz, 4M, 1066MHz FSB)

Chipset – Intel® Q965 Express with ICH8

Operating System - Ubuntu Linux 64bit 2.6.20-6-generic; Microsoft® Windows® XP Professional SP2,

Video - 256MB ATI Radeon X1300PRO, Dual Monitor DVI or VGA (TV-out), FHA)

Memory - 2GB DDR2 Non-ECC SDRAM,800MHz, (2 DIMM)

Networking - Integrated Broadcom 5754 Gigabit Ethernet LAN solution 10/100/1000 Ethernet Remote

Standard I/O Ports - 9 USB 2.0 (2 front, 6 rear, 1 internal), Line-in, 1 Microphone-in, 1 Speaker/Line-out, 1 Headphone (front)

Hard Drive SATA 3.0 Gb/s HDD: 160GB

Chassis - Minitower:
16.2 x 7.3 x 17

Flat Panel Display - UltraSharp 20” 2007FPW TFT Flat Panel

Keyboard - Dell USB Entry QuietKey Keyboard, Dell USB Enhanced Multimedia, Keyboard, Dell

Speakers - Dell AS501PA Flat Panel Speakers (Sound Bar)

Removable Media Storage Devices - – USB Floppy Drive, CD-RW/DVD Combo

Click for a larger view

The hard disk is bottom left, sitting in a very easy slide-in-and-out slot. The large black object in the middle is the fan, which hums along very quietly. I’ve been really please at how quiet the Dell is regardless of the strain it is put under. Quite a contrast to my old Pentium IIIs.

Categories: Hardware, Home Server, Operating Systems Tags: