17 August, 2011

setup lamp server on debian/ubuntu || the easiest & the best way


The LAMP server is the commonly abbreated for Linux Apache MySql PHP server. This is a platform where web pages can be build/test/run using linux.

So setting up your LAMP server includes installing all those above said packages and configuring them to work together.

You can use either terminal or synaptic package manager to install these packages [and should have a working internet connection]. Anyway we may have to use the terminal for configuring them. So better move with the Terminal [Applications > Accessories > Terminal] itself.

1. Install Apache server

------------------------------
Below command will install apache server in your system


$ sudo apt-get install apache2

when the installation finishes, test weather it's working by pointing your web browser[firefox / chrome . . . ] to the following web address.
http://localhost/  

You should see a folder entitled apache2-default/. Open it and you will see a message saying something like > "It works!"

2. Install PHP

- - - - - - - - - - - - -

copy-paste the command given below onto a terminal and hit the enter key.


$sudo apt-get install php5 libapache2-mod-php5

While PHP installation finishes, restart the apache web server to make it compatible with apache using the following command.


$ sudo /etc/init.d/apache2 restart

testing PHP

To ensure there are no issues with PHP let's give it a quick test run.

Step 1. In the terminal copy/paste the following line:



$ sudo gedit /var/www/test.php

This will open up a file called test.php.

Add the following line into the test.php, save and close the file.


  <?php
      phpinfo();
  ?>


Now open you're web browser and type the following into the web address:



http://localhost/test.php


Note : You can change the location of the Document root [by default it is /var/www/] by reading this article.

Install MySQL
- - - - - - - - - - - - - - 

open up the Terminal and then copy/paste this line:


sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql


install phpmyadmin
-------------------------

 

sudo apt-get install phpmyadmin

Now just restart Apache and you are all set!



sudo /etc/init.d/apache2 restart


That's enough! your LAMP server  is ready, and now you can can move up with your pretty codes >>
Read rest of entry

07 July, 2011

Change the DocumentRoot of Apache webserver (/var/www) in Debian / Ubuntu

The document root (also called as the web root) of the Apache web server is located at the /var/www directory by default. Document root is the place where we find all the web pages and server scripts. These files are loaded on the browsers when we type in a particular url to point to that server. 

The /var/www directory doesn't allow access for a user who doesn't have the root permission. It's a headache task to switch to the root mode by typing in the root password everytime even though you know the password, since you may have to change your webpages or scripts during its development stage  very frequently. So a better idea to avoid this problem is to change the default Document root directory to some other location which doesn't require root permission for access.


Change it dude !!!
- - - - - - - - - - - - - - - - - -#

Inorder to change the document root,

#1. Make a directory somewhere inside your home directory to use as the Document root. (not necessarily be home... you can make it anywhere). I named it 'www'

$ mkdir /home/jo/www

#2. Now we have to edit the one of the configuration file of the Apache webserver. The file is located @  /etc/apache2/sites-available/default (requires root permission to edit it).

$ sudo gedit /etc/apache2/sites-available/default

The file will be opened up in the gedit text editor. Now you have to edit the DocumentRoot directive in this file. Replace the /var/www with the /path/to/your/new/document/root in the lines 4 and 9 as shown in the figure below.


#3. Restart the apache webserver.

$ sudo /etc/init.d/apache2  restart



Now test it !!!
- - - - - - - - - - - - - - - - - -#

#1. Create a html/php file inside the Document Root directory (mine is @ /home/jo/www).

#2. Take the terminal and navigate to the Document Root directory (using cd command). Use chmod command given below to allow read+write+execute permission to all.

$ chmod 777 *

#3. Take your web browser and type in http://localhost and hit the enter key! The apache server will load the contents of your Document Root directory as in the figure.


Hope you have done it right!!!


Read rest of entry

14 May, 2011

Does your Gmail account hacked yesterday ??? who knows


You knows !!! Gmail is considered as one among the best email services today, so people are using it for both business and personnel usage. Then comes the issue of security that protects the mails in your inbox. Make sure that your gmail account is safe and open to you only. Google offers activity information mechanism for finding weather your gmail account is hacked or not. Its simple.., you don't need to be a geek. This post will help you to identify weather someone else is accessing your inbox.



Navigate to the bottom side of the gmail inbox. I just pinned the snapshot of mine here. Check for the line starting with the sentence 'Last account activity : x hours ago at IP x.x.x.x'. There you can find a link labeled 'Details'. Click their to see the log information on your gmail inbox and make sure that you are the only one used that account.



Make sure that the IP addresses listed are the same ones that you used. Check the country, date, time and access type also, and identify weather it matches with your usage. Once i have seen a log from a different ip address on my gmail's log. It appeared to be one from Aisanet's network. (That was a my first experience of being hacked). Later i found it was not an accidental one. This unwanted access was from an  internet cafe once i used 2-3 days before the hazard, and what really happened was i really forgot to logout from my gmail account when i quit the cafe. If you feels the same, then understand this is the right time to change your google account's password. Do it  now itself, else you may be the next victim. Changing the passwords frequently is always refered as the best methode to escape from hacks and unwanted access to your personals kept on internet...

Finding ip adress of your machine

If you dont want to go technical just visit the website tracemyip to know your ip address and related details.  



If you are a unix guy, use the ifconfig command on the terminal to know your ip. The field shown as 'inet addr' corresponding to your mode of connection (eth, wlan, ppp) is the ip.





and, If you are windows guy, use the dos command ipconfig in the command prompt window to view your ip. 


Note :
  • Ip address may not be the same for every time you connects, if you are not using a static connection.. 
Read rest of entry

22 April, 2011

How to change dns address in Windows

 The domain name servers plays a big role in the case of world wide web. It converts the human understandable URLs or host names such as google.com or yahoo.com into machine understandable IP addresses. It is very important to select the best DNS server from a list of available ones since the right selection will reflect in the browsing speeds. Actually when an internet user types some url and hit the enter key, the  role of dns server (usually provided by the correspponding internet service provider for example bsnl or vodafone ) comes into effect. 

The dns server converts the hostname to the corresponding IP address and returns the IP back to the browser.Usually the dns server uses tables to store the hostname and ip, also a domain naming system is also implemented as a distributed system. 

Leave the theories ... lets findout the best dns server that suits you and change the your default dns value to the best one that is more fast and reliable using the following steps...

Before that, the public and free dns address available are 

google public dns
8.8.8.8
8.8.4.4
opendns
208.67.220.220
208.67.222.222

dns advantage

156.154.70.1
156.154.71.1

others
209.244.0.3
209.244.0.4





1. Use the ping command to find the dns server with less average RTT (round trip time).

Take the command prompt and use the average value of round trip time in the ping command to spot the best dns address. Check the figure.

  > ping <dns address here>

  

2. Replace the default dns address with the new one



Take 'Network and Sharing Center' from the control panel. Select the 'Manage Network Connections' from the left side panel. Select the connection and right click to select the 'Properties' from the menu.


Select the TCP/IPv4 under the Networking tab and click the 'properties' button to change its properties. 


Inside the TCP/IPv4 properties click on the 'Use following DNS server' and add the DNS server address there as shown in the image below.

If the connection is already active you may have to restart the connection to make the changes take into effect. 




That's all about the configuration. From my personal experience google's public dns addresses are fast and reliable than the others. Almost a lion's share of time i spend on internet is usually with google related sites such as google search engine, analytics, blogger... The method for changing the dns address in Ubuntu linux is explained in the post linked here
Read rest of entry

27 January, 2011

python urllib library : the basics

               urllib and urllib2 are Python modules for fetching URLs. It offers a very simple interface, in the form of the urlopen function which is capable of fetching URLs. It also offers a  slightly more complex interface for  handling features like basic authentication, cookies, proxies and soon.

urllib2 supports fetching URLs for many URL schemes  such as ftp, http -- for example “ftp” is the URL scheme of “ftp://python.org/“

Fetching URLs : urlopen()
 
Now it is the time to play off the theories. The simplest way to use urllib2 to open urls is as follows:
  import urllib2
  response = urllib2.urlopen(’http://python.org/’)
  html = response.read()
You can use the above method to store the complete contents of a file into a variable without writing it to a local file... 

Sending Data along with url 
                Sometimes you want to send data to a URL (often the URL will refer to a CGI script or other web application). With HTTP, this is often done using  a GET/POST request. This is what your browser does when you submit a HTML form that you filled in on the web. In the common case of HTML forms, the data needs to be encoded in a standard way, and then passed to the Request object as the data argument. In python encoding is done using a function from the urllib library.

  import urllib
  import urllib2
  url = ’http://www.someserver.com/cgi-bin/register.cgi’
  values = {’name’ : ’Michael Foord’,
                             ’location’ : ’Northampton’,
                             ’language’ : ’Python’ }
  data = urllib.urlencode(values)
  req = urllib2.Request(url, data)
  response = urllib2.urlopen(req)
  the_page = response.read()

This can be done manually as follows :

  import urllib2
  import urllib
  data = {}
  data[’name’] = ’Somebody Here’
  data[’location’] = ’Northampton’
  data[’language’] = ’Python’
  url_values = urllib.urlencode(data)
  print url_values
  name=Somebody+Here&language=Python&location=Northampton
  url = ’http://www.example.com/example.cgi’
  full_url = url + ’?’ + url_values
  data = urllib2.open(full_url)

Fetching files : urlretrieve()

We can use urllib's urlretrieve function to download a file over internet and save it in a new name. We can download text / image / video files using this function if the source file is available as a url.

 import urllib
 url=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAEaU33AHSR1u5v4ulLwW6ll9sIy5j7GbCoFQkC6bXbnl8EQrf8NPjlVbeC_6OShG00vi0R6sT_GTXkueNsXUnZEkq2IcLwyRmIQke2JzeKrh7lWd9YR5Sjob3a9AZsfuh4ENpmt1MT8Wy/s104/ubuntu.png 
 urllib.urlretrieve(url, new_image.png) 
Hope you have enjoyed the basics of the urllib library of python...

Read rest of entry

22 November, 2010

Basic javascript programs


 1. A javascript to implement variable usage
<html>
<title>Variable Using Script</title>
<body>
<script>
      var greetings;
      greetings='Hi, How are you?';
      alert(greetings);
</script>
</body>
</html>

2. A javascript to implement the pop-up boxes 
<html>
<title>Script for prompt</title>
<script>
var username;
var greeting;
username = prompt("What is your name?");
username=username.toUpperCase();
greeting="Hi, "+username;
alert(greeting);
</script>
</body>
</html>
</script>
</html>

3.Implementing the eval() function in javascript

          In javascript every input is read as string. We need to convert it to numbers for processing if the input is a number 
<html>
<title>Sum of Two Numbers</title>
<script>
var num1,num2;
var sum;
var msg;
num1=prompt("Enter the first number: ");
num1=eval(num1);
num2=prompt("Enter the second number: ");
num2=eval(num2);
sum=num1+num2;
msg="Sum= "+sum;
alert(msg);
</script></html>

4.  Using switch case in javascript.
<html>
<title>Switch Case</title>
<body>
<script>
       var num,day;
       num=prompt("Enter an integer: ");
       switch(num%7)
       {
              case 1: day="Sunday";break;
              case 2: day="Monday";break;
              case 3: day="Tuesday";break;
              case 4: day="Wednessday";break;
              case 5: day="Thursday";break;
              case 6: day="Friday";break;
              case 0: day="Saturday";break;
              default: day="Invalid Day Number!!\n";
       }
       alert("Day: "+day);
</script>
</body>
</html>

5. Implementing for loop in javascript
<html>
<title>For Loop</title>
<body>
<script>
       var i;
       for(i=0;i<10;i++)
       {
              alert("This is the message no: "+i);
       }
</script>
</body>
</html>

6. Generating local information from the browser using javascript
<html>
<title>Information</title>
<body>
<script>
       document.bgColor="blue";
       alert("Background: "+document.bgColor);
       alert("Domain: "+document.domain);
       alert("URL: "+document.location);
       alert("Last Modified: "+document.lastModified);
       alert("Last Page: "+document.referrer);
       alert("Title: "+document.title);
</script>
</body>
</html>

7.Writing dynamic javascript contents on to html page to display in browser 
<html>
<title>Dynamic Write</title>
<body>
<script>
       var name;
       name=prompt("Enter your name: ");
</script>
        Hi how are you?
<script>
       document.write(name);
</script>
</body>
</html>

8. Implementing onclick events and functions within a form using javascript
<html>
<title>Script for Form Variable Changing</title>
<body>
<script>
       function changebuttonValue()
       {
               document.myForm.button.value="changed";
       }
       function changeText()
       {
               document.myForm.text1.value="Enter you name";
       }
</script>
<form name=myForm>
<input type=text name=text1 onMouseOver='changeText();'>
<br>
<input type=button name='button' value=Enter onClick='changebuttonValue();'>
</form>
</body>
</html>

9. opening a new browser window using javascript
<html>
<title>Open a New Window</title>
<body>
<input type=button value="Show New Window" onClick="newWindow();">
<input type=button value="Close Window" onClick="closeWindow();">
<script>
       var new1;
       function newWindow()
       {
              //document.write("Hi");
              new1=window.open("frame1.html","Name","height=450,width=450");
              new1.focus();
       }
       function closeWindow()
       {
              new1.close();
       }
</script>
</body>
</html><hr align="left" size="1" width="100%">


Read rest of entry

30 September, 2010

How to install traditional language fonts in Ubuntu


The multi-language support by operating systems offer a way to type in and read contents of the even traditional languages. Yet there are still some problems persist when you need to install new fonts in your traditional languages. The main problem causes when you visit a website which is in traditional language. Most probably the browser will display junk characters which are unreadable. Here is a how to about installing traditional languages in your Ubuntu machine.

1. First download the font on to your machine, let it be font.ttf

2. Take the terminal and copy this font.ttf to  the Fonts  directory in Ubuntu as root (usually /usr/share/fonts).

 $ sudo cp ~/Downloads/font.ttf  /usr/share/fonts

Relogin to the system to make the changes come into effect.

If you do not have the root permission, please do the following steps.

Copy the font.ttf font to a directory.

Change to that direcroty and run the following  commands.

Run ttmkfdir > fonts.dir
Run ttmkfdir > fonts.scale
/usr/X11R6/bin/xset fp+ <font directory>
/usr/X11R6/bin/xset fp rehash

Open the browser and change the character encoding to “User Defined”

Installing new fonts in windows


In windows you have to copy the fonts in to the C:/Windows/fonts directory.
  


 
Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger