Configuring Linux Websites

You have a linux server. You want to add a website. Here's how. Connect to your server with telnet and then try the following:

1. Verify that the name is registered.

You can do this by telnetting to your server and typing:

whois myname.com

The computer will check the NIC database. If there is no reply they you need to apply to get the name registered. If the name comes up registered to someone else, you are out of luck. You are going to have to choose another name.

2. Verify that the name has been set up and works.

Here's how to test:

nslookup myname.com

The computer will come back and tell you the IP adress of that name.

If you do not get an ip address back, then you need to do name server configuration. If you get back the wrong address, it may take several days to undo the damage because the server caches the names. Try to make sure you do it right the first time as this will save huge headaches.

Two DNS setups are included with T1 or server colocation at Brand X. For those those two just let us know what you want and we will help at no charge. After that it's $50 per name, or you can set up your own name server.

3. How to do name server configuration:

Note: these instructions relate to the traditional DNS configuration. There is a new version of "named", the DNS program, that is distributed with the latest versions of Linux. It has slightly different configuration files.

Telnet to the server that is going to do DNS. Login and do the "su" command with the password to become superuser. Now change directory to /etc (cd /etc) and list the files using the ls command. You should see the file named.boot. Look inside it using the pico program. You are going to have to make some additions here. Look at the section down below. Follow the model to add a line to refer to the domain you want to add. Basically you are going to type "pico named.boot" to open the file and then add a line that looks like:

primary      axium.com     axium.db.
Try and leave things looking neat; a comment or two and neat columns will be a nice touch.

When you are done type ^o to save the file and type ^x to exit the pico program.

This will change the file. Now we need to create a .db file. You should copy one that already works and then change the names in it. I'm going to make three of them today. Type:

cp /etc/namedb/marketingnet.db /etc/namedb/cybrport.com
cp /etc/namedb/marketingnet.db /etc/namedb/axium.com
cp /etc/namedb/marketingnet.db /etc/namedb/comspan.com

Fine. Now lets have a look.

Change directories by typing "cd /etc/namedb" and then list the files using the ls command. You should find your new files. Edit them. Here's what one of the files looked like before I edited it:

@       IN      SOA     brandx.net. hostmaster.brandx.net. (
                                9510031 ; Serial number
                                172800  ; Refresh every 2 days
                                3600    ; Retry every hour
                                1728000 ; Expire every 20 days
                                86400 ) ; Minimum 1 day
                IN      NS      ns1.brandx.net.
                IN      NS      ns2.brandx.net.
                IN      MX      10 brandx.net.
                IN      A       204.140.224.2
;
; Local loopback host
localhost       IN      A       127.0.0.1
;
; Canonical Names
www             IN      CNAME   marketingnet.com.
ftp             IN      CNAME   marketingnet.com.

Edit the above file and you get

@       IN      SOA     brandx.net. hostmaster.brandx.net. (
                                9511221 ; Serial number
                                172800  ; Refresh every 2 days
                                3600    ; Retry every hour
                                1728000 ; Expire every 20 days
                                86400 ) ; Minimum 1 day
                IN      NS      ns1.brandx.net.
                IN      NS      ns2.brandx.net.
                IN      MX      10 brandx.net.
                IN      A       204.140.224.5
;
; Local loopback host
localhost       IN      A       127.0.0.1
;
; Canonical Names
www             IN      CNAME   cybrport.com.
ftp             IN      CNAME   cybrport.com.

(I just switched marketingnet to cybrport, and changed the address to 204.140.224.5 Also, you *must* change the serial number to reflect the new date. 95 is the year. 11 is the month. 22 is the date. 1 means this is the first edition of the day. Updating this serial number is necessary or the name server update will not propogate to other system. Dumb system, but that's what you ahve to do to make it work.)

Now we need to restart the name server. You can do this by rebooting the computer, but there are easier (faster ways) Find the process number:

Brand X % ps -ax | grep named
 7982 ??  Ss     8:09.55 /usr/sbin/named
28033 p0  S+     0:00.03 grep named

OK, the process number is 7982 (you may get a different answer). Now we restart the name server:

Brand X % kill -1 7982

The next step is to verify that the computer knows where to find your domains

Brand X % nslookup comspan.com
Server:  brandx.net
Address:  198.147.97.1

Name:    comspan.com
Address:  204.140.224.7

This looks right, it's the address I wanted. Our address is set up. Next, we're going to do some mail server configuration. It's pretty easy. Note that it is very important to get the right address.

4. MAIL SERVER CONFIGURATION

Note: this applies to the version of sendmail that we are using at Brand X. The verion you have may be different.

You have the name working (I hope). Open the mail config file by typing "pico /etc/sendmail.cw" and then add your domain to the bottom of the list. Very easy. So easy it's not even worth taking the space to show you what this file looks like.

5. IP ADDRESS CONFIGURATION

To add an address you have to add a little file for each ip address you want the server to answer to.

Look in the directory /etc/sysconfig/network-scripts. You will find some files with names like:

[root@echavez network-scripts]# ls
ifcfg-eth0  ifdown-post  ifup          ifup-plip  ifup-routes
ifcfg-lo    ifdown-ppp   ifup-aliases  ifup-post  ifup-sl
ifdown      ifdown-sl    ifup-ipx      ifup-ppp   network-functions
[root@echavez network-scripts]#
Here's the contents of the file ifcfg-eth0 (which sets the base IP address of this server:

[root@echavez network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=209.55.67.37
NETMASK=255.255.255.0
ONBOOT=yes
[root@echavez network-scripts]#
We are going to take the file ifcfg-eth0 and make a copy which we will call ifcfg-eth0:0.

[root@echavez network-scripts]# cp ifcfg-eth0 ifcfg-eth0:0
Now edit the new file using pico. Once we are done it should look like this:

DEVICE=eth0:0
BOOTPROTO=static
IPADDR=209.55.67.72
NETMASK=255.255.255.0
ONBOOT=yes
Note that we have changed in two places: line1 (eth0:0) and line 2 (the new address.) At Brand X we have a web page where we keep track of all the assigned IP addresses. If you have a server you will be assigned some addresses and it will be up to you to keep track.

When you restart the server it will have the new address added. You can verify this by using the ifconfig command.

[root@echavez network-scripts]# /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:60:08:3B:63:9E
          inet addr:209.55.67.37  Bcast:209.55.67.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20386952 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35577 errors:0 dropped:0 overruns:0 carrier:0
          collisions:25 txqueuelen:100
          Interrupt:10 Base address:0xc000

eth0:0    Link encap:Ethernet  HWaddr 00:60:08:3B:63:9E
          inet addr:209.55.67.72  Bcast:209.55.67.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:10 Base address:0xc000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:3924  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0

[root@echavez network-scripts]#
You can create more files, one for each new ip address, with names that end in eth0:0,eth0:1, etc.

6. WEB SERVER CONFIGURATION

This will be almost an anticlimax. Use Pico to open the file /etc/httpd/conf/httpd.conf. On some servers you may find this file in a different location. If you can't find it use the "locate" command to find httpd.conf. If you look in the file you will see that there is an introductory section with general configurations and then a short paragraph for each virtual server. Copy the pattern for your new site. Make sure you have set different addresses for everything.

Change the domain name to the nw domain name of the virtual host you are creating.

Change the option labelled "documentroot" to the name of the directory that this virtual host should go to.

Here's an example of the addition made to this file to support one virtual host, for marketingnet.com:

Sample:

#
#ServerAdmin webmaster@host.some_domain.com
#DocumentRoot /www/docs/host.some_domain.com
#ServerName host.some_domain.com
#ErrorLog logs/host.some_domain.com-error_log
#TransferLog logs/host.some_domain.com-access_log
#
Make it look like this:

NameVirtualHost 209.55.67.37


ServerAdmin callerconnect@theworld.net
DocumentRoot /home/http/www/callerconnect
ServerName www.callerconnect.com
ErrorLog /home/callerconnect/logs/error.log
TransferLog /home/callerconnect/logs/access.log

http://209.55.67.72/manual/

Explanation: servername is the place to point the URL. Serveradmin is an email of whoever is responsible for this site. Documentroot is the physical location of the site on cellini.

You will probably need to restart the server to make this work.

Find out the process number of the httpd process:

cellini % ps -ax | grep httpd
  213  ??  Ss     2:15.40 /usr/contrib/bin/httpd
 4918  ??  I      0:01.62 /usr/contrib/bin/httpd
 5000  ??  I      0:01.28 /usr/contrib/bin/httpd
 5654  ??  I      0:00.29 /usr/contrib/bin/httpd
 5674  ??  I      0:00.50 /usr/contrib/bin/httpd
I actually got about fifty lines when I tried this, but the first one is the one we are interested in. The Process ID (PID) is 213. Now use this information to restart the process, by typing "kill -1 PID", where PID is the PID number we just found.

7. Testing

Have a look through Netscape and make sure the web site loads. If it does, then you are done.