Saturday, June 2, 2012

How to make a website (Linux)

The internet is a hard subject to grasp if you do not understand networking. All it is is a system of servers connected by an internet service provider, which give you access to all of these servers. There is nothing special about a server, either. It is just a computer like the one you are using. You too can set up a website to use locally and over the internet. Here is how to do it in any variant of Gnu/Linux that has Apache and Kompozer (optional).

This article assumes that you have no knowledge of HTML (The Hypertext Markup Language), which is what websites are technically written in. Instead we will use a program called kompozer that is generates HTML similar to how blogger does.

Run these two commands to get started:

sudo apt-get install apache2
sudo apt-get install kompozer

The first command installs the server software and the second installs kompozer, the editor we will be using. After you install apache2, a directory named "www" will be created in /var. This is where you will place the file named "index.html".

You can link to other pages from the main one by making a link with the name of a file in /var/www or any other file on the computer.

Write the Webpage
 Run kompozer with root privileges. (sudo kompozer). You are going to be saving the file in /var/www which is a protected directory by default. Now, all you have to do is... write. Kompozer has all of the tools you will need to make your basic web page. Add text, links, bold text, italicized text, pictures, or whatever you need. If you need mroe power you can edit the HTML directly from the "source" tab if you must. When you are done writing your web page, save it.

The first dialog that will come up will ask you for a title. Name it whatever you want the name of this page to be. This will appear in tabs and on some window lists. Hit okay, and save it as "index.html" in /var/www.

Viewing
You now have a website available on your machine to the world wide web and to your local network. Find your ip address by typing

ifconfig

into the terminal. The wlan address is your IP address. Your local network can access the webpage from this address. To view it from anywhere in the world, you need to port forward your router. To do so, look up your router's manual on port forwarding. My router has an "advanced" dialog at 192.168.0.1, so that may be a good place to start looking. After the forwarding has been set up, you can go to http://your_public_ip to see your website. Typing "ip" into a google search will show you your public IP to use.

No comments:

Post a Comment