Make a Web Server, Under 100 Dollars

I am going to show you how to Create a Web Server using an awesome technology called Plug Computing This website is powered byWordpress and a Ubuntu LAMP server. I built it using a Marvell Sheeva plug.

Plug Computing is a new term coined by Marvell to describe a new form of server. The idea behind plug computing is to have a small, low power, always on server that connects to the local network and provides the user access to central services. To promote the new concept, Marvell created the SheevaPlug development kit. The “computer” itself is housed in a 4″x2.5″x2″ wall wart that plugs directly into any typical household AC outlet. The SheevaPlug was built with the following hardware:

  • Kirkwood series SoC with an embedded Marvell Sheeva (88F6281) CPU core running at 1.2Ghz.
  • 512 Mbytes of DDR2 memory.
  • 512 Mbytes of NAND Flash memory use for system boot and the OS filesystem.
  • USB 2.0 (480Mbps) running as HOST.
  • Gigabit ethernet connection to the cpu.
  • SDIO interface capable of using SDHC type SD memory cards.
  • Dual serial port for JTAG interface (used by openOCD and OS serial output)

The Sheeva Plug development kit comes with the following software and documentation:

  • U-Boot
  • Linux Support Package (LSP)
  • Ubuntu and Gentoo File System
  • Host Software Support Package for Linux and Windows
  • Schematics & Bill of Materials

The product brief is available here.

This is what I did:

I added an 8GB SD Chip formatted as swap space.

I also added a 20GB Jump Drive that I setup in the FSTAB to mount as /var/www/

There are a few ways of connecting to this device, you can connect via a Serial Connection or SSH

I plugged the machine into my network and it received its IP via DHCP

I could have logged into the router to see what IP it received but instead I ran this command

bebe@genesis:~$ sudo arp-scan -l

arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network.

Once the scan provided me with an IP address I fired up putty and logged in.

the first command I ran was

bebe@genesis:~$ sudo tasksel install lamp-server

Your machine is now a LAMP server.

Now itś time to setup Virtual Host so you can run multiple sites from the one Plug

Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in /etc/apache2/sites-available. By default, there is one site available called default this is what you will see when you browse to http://localhost or http://127.0.0.1. You can have many different site configurations available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/. To do this, we must create a new site and then enable it in Apache2.

To create a new site:

  • Copy the default website as a starting point. sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
  • Edit the new configuration file in a text editor “sudo nano” on the command line or “gksudo gedit”, for example: gksudo gedit /etc/apache2/sites-available/mysite
  • Change the DocumentRoot to point to the new location. For example, /home/user/public_html/
  • Change the Directory directive, replace <Directory /var/www/> to <Directory /home/user/public_html/>
  • You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites
  • Save the file

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

bebe@genesis:~$ sudo a2dissite default && sudo a2ensite mysite

I also recommend

bebe@genesis:~$ sudo a2enmod mod_rewrite

Finally, we restart Apache2:

sudo /etc/init.d/apache2 restart

If you have not created /home/user/public_html/, you will receive an warning message

To test the new site, create a file in /home/user/public_html/:

echo '<b>Hello! It is working!</b>' > /home/user/public_html/index.html

Finally, browse to http://localhost/

Set mysql bind address

Before you can access the database from other computers in your network, you have to change its bind address. Note that this can be a security problem, because your database can be accessed by others computers than your own. Skip this step if the applications which require mysql are running on the same machine.

type:

nano /etc/mysql/my.cnf

and change the line:

bind-address           = localhost

to your own internal ip address e.g. 192.168.1.20

bind-address           = 192.168.1.20

If your ip address is dynamic you can also comment out the bind-address line and it will default to your current ip.

If you try to connect without changing the bind-address you will recieve a “Can not connect to mysql error 10061”.

Set mysql root password

Before accessing the database by console you need to type:

mysql -u root

At the mysql console type:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

A successful mysql command will show:

Query OK, 0 rows affected (0.00 sec)

Mysql commands can span several lines. Do not forget to end your mysql command with a semicolon.

Note: If you have already set a password for the mysql root, you will need to use:

mysql -u root -p

Create a mysql database

mysql> CREATE DATABASE database1;

Create a mysql user

For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

For creating a new user with fewer privileges (should work for most web applications) which can only use the database named “database1”, at mysql prompt type:

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';

yourusername and yourpassword can be anything you like. database1 is the name of the database the user gets access to. localhost is the location which gets access to your database. You can change it to ‘%’ (or to hostnames or ip addresses) to allow connections from every location (or only from specific locations) to the database. Note, that this can be a security problem and should only be used for testing purposes!

To exit the mysql prompt type:

mysql> \q

Since the mysql root password is now set, if you need to use mysql again (as the mysql root), you will need to use:

mysql -u root -p

and then enter the password at the prompt.

Backup-Settings

Please, let’s say something in which directories mysql stores the database information and how to configure a backup

Alternatively

There is more than just one way to set the mysql root password and create a database. For example mysqladmin can be used:

mysqladmin -u root -p password yourpassword

and

mysqladmin -u root -p create database1

mysqladmin is a command-line tool provided by the default LAMP install.

So now you can download WordPress, Joomla, Drupal or create a site using any way you know how and place it in the /home/user/public_html/ folder
now all thatś left is to buy a domain name and point your website to your IP Address @ home and don´t forget to forward the ports on your router or modem to your switches IP..
Now you are good to go.

Leave Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.