Building LAMP on Ubuntu Part 2

Posted on 18. Aug, 2009 by in Server, Web Servers

Print This Post Print This Post

VN:F [1.6.3_896]
Rating: 6.7/10 (3 votes cast)

This is part 2 of Building LAMP on Ubuntu.  This sections covers the initial setup of the server following the Ubuntu OS install covered in Installing Ubuntu Operating System

Set Root Password

At this point in the installation the root password is blank, and therefore there is no way to log in as root. Although most administrative tasks can be performed using the sudo command, it makes things easier to have the ability to become root.

Log in to the console using the user account created in part one and type the following command and press Enter:

sudo passwd root

Ubuntu 64-bit-2009-08-18-13-55-28

You will first be prompted to enter your current user password (the one you just logged in with). Next you will be asked to enter a new password for the root account, and type it again to confirm. When complete you should see a message indicating that the root password was successfully updated.

Ubuntu 64-bit-2009-08-18-13-53-56

To become root, type the su command and press enter:


Ubuntu 64-bit-2009-08-18-13-57-38

Enter the root password you just created and press enter

Ubuntu 64-bit-2009-08-18-13-57-50

Configure Static IP Address

During the installation in part one, the system automatically configured the IP address of the server using DHCP. However, since this will be a web server, it is a good idea to set a static IP address.

To see the current ip address type the following command and press enter:

ifconfig -a

Ubuntu 64-bit-2009-08-18-13-58-20

Current network configuration is displayed. Notice the ip address set for your nic card (probably eth0)

Ubuntu 64-bit-2009-08-18-13-58-28

The following shows how to edit the network interface configuration file using the vi editor. Make sure you are still logged in as root and enter the following:

vi /etc/network/interfaces

Ubuntu 64-bit-2009-08-18-14-00-33

The file will be opened by vi. Notice that the network card is set to dhcp and there is no address defined.

Ubuntu 64-bit-2009-08-18-14-00-42

If you have never used vi before, be forewarned that it takes some getting used to. If you make a mistake, just remember the following sequence to escape and not save changes:

ESC :q! ENTER (press escape key, type colon, lowercase q and an exclamation mark, and press ENTER)

Use the arrow keys to move the cursor up/down/left/right. Position the cursor underneath the d of dhcp.

Ubuntu 64-bit-2009-08-18-14-01-13

Press the x key four times to delete the word dhcp

Ubuntu 64-bit-2009-08-18-14-01-24

Press the i key to start insert mode (when in insert mode you can insert text. to escape insert mode press ESC). You will know you are in insert mode because it says INSERT at the bottom of the screen.

Ubuntu 64-bit-2009-08-18-14-01-32

Type the word static and press ENTER to go to the next line

Ubuntu 64-bit-2009-08-18-14-01-47

Next enter address and the server’s static ip address, netmask and the subnet mask, and gateway and the server’s gateway/router

Ubuntu 64-bit-2009-08-18-14-03-44

Once finished, press the ESC key to escape from insert mode and enter the following command to save and exit:

:x! (colon, lowercase x, and an exclamation mark)

Ubuntu 64-bit-2009-08-18-14-04-48

Changes are saved

Ubuntu 64-bit-2009-08-18-14-04-57

We will follow the same procedure to edit DNS. Enter the following command to open the dns configuration file:

vi /etc/resolv.conf

Edit the IP address following nameserver to your primary DNS server, and optionally add a second nameserver line with your secondary name server

Ubuntu 64-bit-2009-08-18-14-06-26

Enter the following command for the networking changes to take effect

/etc/init.d/networking restart

Ubuntu 64-bit-2009-08-18-14-07-48

Verify that your changes took effect by once again typing ipconfig -a

Ubuntu 64-bit-2009-08-18-14-08-11

You should see your new ip address for the primary network card

Ubuntu 64-bit-2009-08-18-14-08-19

After you complete the setup, you should also review part 3:

Getting to know Ubuntu LAMP Server

If you have questions or problems with this build doc please leave a comment below.

VN:F [1.6.3_896]
Rating: 6.7/10 (3 votes cast)

Tags: , ,

Print This Post Print This Post

Leave a reply