Ubuntu Server 12.04

All posts tagged Ubuntu Server 12.04

Ubuntu server comes default with a Command line interface. Of course we can install GUI in Ubuntu Server if we find command line troublesome. Here are the steps.

First navigate to the “etc/apt” directory and open a file named “sources.list.d” using the command “vi sources.list.d”. 

ugui1

Then check whether software from “universe” ad “multiverse” repositories are allowed.

ugui2

Then type the command “sudo apt-get update” to update all repositories.

ugui3

 

After updating is finished, type the command “sudo apt-get upgrade”.

ugui4

 

Then type the command “sudo apt-get install ubuntu-desktop”. It will take some time to finish all the processes.

ugui5

 

After the installation is finished, restart the server to see your GUI interface.

ugui6

 

In this article, we are going to see how to set up a web server in Ubuntu Server. Before that, I want to give  credit for this article to Mike of www.funwithlinux.net. I learnt how to install the web server from this article, made some mistakes initially but finally successful.

What is a web server? It is a server which hosts websites. Each and every website has a  server. Most web servers are set up on Linux for the primary reason that it is free. I am going to set up my web server on Ubuntu Server 12.04.

To set up a web server we are going to install four components, Apache (server software), PHP (scripting language used to create webpages), MYSQL (database), PHP-MYSQL (MySQL support in PHP ). Login as root into Ubuntu server.

In the terminal type “apt-get install apache2″ to install Apache package. Type ‘Y’ when system prompts you to continue.

uws1

 

To check whether apache packages have been installed or not type the command “wget localhost index.html” in the terminal. This will download the index.html file to the local directory. Type “ls” to see if the file has been downloaded or not. If it is present, apache has been correctly installed.

uws2

The apache2 config file is located at “/etc/apache2/”. In this same directory we have a directory named ‘conf.d’. Configuration files( files with the suffix .conf ) in this directory will be parsed by apache2 during startup.  If we intend to run multiple sites from the same server, we need to put our config files here. Let’s create a file name “shunya.com.conf”.

uws3

In the file shunya.com.conf, add the following text and save the file. The first line tells  Apache to  listen on port 80. The second line shows the ServerAdmin and is optional. The third line shows our web server’s root directory. The fourth line is host header Apache2 will listen for, as sent by the end user’s browser. The fifith line is the file used for logging errors. This line is also optional but is very helpful.  The settings not configured under <VirtualHost> tags will be inherted from apache2.conf or other configuration files. Close the file by typing “:wq”.

uws4

 

As we created the config file of our host, we need to create our root directory referenced in the config file i.e “/var/www/shunya.com”. Navigate to the directory by typing “cd /var/www/”. Create new direcory named ‘shunya.com’ by typing “mkdir shunya.com”. Make the root user the owner of the directory by typing the command “chown root:www-data /var/www/shunya.com -R”. Make this directory readable and executable by typing the command “chmod 550 /var/www/shunya.com -R”.

uws5

 

Create a file named index.php in our root directory shunya.com.

uws6

 

Edit the file as below. We will echo some Archimedes in our index.php file. Save and exit the file.

uws7

 

Next, we have to install PHP. Type the command “apt-get install php5″. Type Y at appropriate prompts.

uws8

 

Reload the apache config file by typing “service apache2 reload”. Then restart the apache service using “service apache2 restart”.

uws9

 

Let’s see if our website is working. From a remote machine which has access to ur web server open the browser and type the IP address of the web server. If we get “Eureka Eureka” displayed, then our server is working.

uws10

 

Install Mysql server by typing “apt-get install mysql-server”. 

uws11

 

The system will prompt you to set a root user password for MYSQL. Set the password and confirm it again.

uws12

 

uws13

Type the command “apt-get install php5-mysql” to install Mysql support for PHP.

uws14

 

We have set up our web server successfully.