NewbieTux

Newbie guides for *nix users, newbie system admin

How-to: Install squid on ubuntu

What is squid?

Squid is a caching proxy of web which supports HTTP, HTTPS, FTP and many more. It can be used to reduce bandwidth (in term reduce the internet bill to some extend ) , improve response time. It has many features like access control. Can also server the purpose of server accelerator.

In this article we will see how to install Squid on Ubuntu 8.04 (desktop edition) and configure some parameters so squid can server as basic proxy.

With Ubuntu 8.04 (desktop edition) squid does not gets installed by default as the purpose of the Ubuntu desktop edition is to setup and use the OS as your desktop.

Now to install squid on your Ubuntu 8.04 box please use the below command which will install squid and it’s decencies


$ sudo apt-get install squid

Once you issue above command it will fetch squid and squid-common package and install them on the system, configure them with defaults and tries to start them, but fails in some cases with the below error:


Preconfiguring packages ...
Selecting previously deselected package squid-common.
(Reading database ... 95877 files and directories currently installed.)
Unpacking squid-common (from .../squid-common_2.6.18-1ubuntu3_all.deb) ...
Selecting previously deselected package squid.
Unpacking squid (from .../squid_2.6.18-1ubuntu3_i386.deb) ...
Setting up squid-common (2.6.18-1ubuntu3) ...
Setting up squid (2.6.18-1ubuntu3) ...
Creating squid spool directory structure
FATAL: Could not determine fully qualified hostname. Please set 'visible_hostname'
Squid Cache (Version 2.6.STABLE18): Terminated abnormally.

Or

Squid Cache (Version 2.6.STABLE18): Terminated abnormally.
CPU Usage: 0.016 seconds = 0.008 user + 0.008 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Aborted
FATAL: Could not determine fully qualified hostname. Please set 'visible_hostname'
Squid Cache (Version 2.6.STABLE18): Terminated abnormally.
CPU Usage: 0.020 seconds = 0.004 user + 0.016 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Aborted
[fail]

The above error means that the hostname is not set properly set.
To resolve the above error you can set value for “visible_hostname” in squid.conf and restart squid with below command.


/etc/init.d/squid start

In the next blog we will see how-to configure basic squid for small office.

How-to: Configure caching only name server (caching DNS) for your small office / home on Centos / RHEL4

Configure caching DNS server for your small office so save turn around time of your networks dns quries:
1) Install bind if already not installed from your installation CDs
rpm required as below:
bind-9.2.4-2
bind-chroot-9.2.4-2
caching-nameserver-7.3-3

[root@redhat-testmac1 ~]# rpm -Uvh bind-9.2.4-2.i386.rpm bind-chroot-9.2.4-2.i386.rpm caching-nameserver-7.3-3.noarch.rpm

Or
use GUI to install DNS server from Add remove programs as below screen shots:

1.a)

1.b) select the DNS server from list as below:

2)once you have bind installed for redhat it gives a preconfigured named.conf file you can rename it to named.conf.old as below

[root@redhat-testmac1 ~]# mv /etc/named.conf /etc/named.conf.old

open a new file /etc/named.conf (in your favourite editor)and type below contains to it so it.

options {
forwarders { xx.xx.xx.xx; }; # replace xx.xx.xx.xx with your ISP DNS server IP


forward only;
};

3) save the file and restart named service:


[root@redhat-testmac1 ~]# service named restart

or

[root@redhat-testmac1 ~]# /etc/init.d/named restart

4) Check that resently configured caching only DNS server is working:
replace nameserver ip with the ip of the box in /etc/resolv.conf save the file and quit.
do nslookup from promt.

[root@redhat-testmac1 ~]# nslookup
> tldp.org
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name: tldp.org
Address: 152.46.7.81

Take backup with dump

You have joined as system administrator in some Company, you see that there is no full backup of /home taken, now you want to start taking backup but you will be taking full backup first( as standard procedure). In this case you can use dump command line utility to take full backup of /home.
Dump is the standard backup utility. to take the full backup we should use -0( zero) option.
Which means full backup, -u means update the /etc/dumpdates files which maintains the backup records, -f means filename or device name where you would like to take backup.

I had one partition empty /dev/hdc4 so i used it to take backup of /home.
in the example systems /dev/hda4 was mounted as /home

Here is how to take backup with dump.

dump -0u -f /dev/hdc4 /dev/hda4

The above command will take a full backup of /dev/hda4 which is home to /dev/hdc4, once the backup is done you can create your own backup policies and implement them for all the servers in your company. There are some examples of weekly and daily backup in man page for dump.

Note: dump can only handle ext2/3 file systems.

In the next post we will see how to restore backup which is taken with dump command line utility

Lighttpd + PHP + MySQL on Ubuntu 8.04

lighttpd known as “lighty” is a web server, Designed to be secure, fast, flexible, optimized for speed, light for CPU and memory. very sutiable for servers where are load problems, for serving static media separately from dynamic content.

Good for Freelancers, admins, Developers, testers who want to install web server on there Desktops (where memory and CPU would be lesser then the production servers) to code PHP application , try / test some PHP & CGI scripts before actually implementing them to production environment.

Some of the sites like The Pirate bay, Mininova, ISOHunt which gets More then 1000 hits per second uses lighttpd as there webserver. Even Some of popular sites like Youtube, Wikipedia, meebo uses lighttpd as there Webserver.

In this post we will see how-to install Lighttpd + PHP + MySQL + phpmyadmin on Ubuntu.

In This tutorial assumes that you have already installed ubuntu on your, I have used server name as “mydomain.com”
and IP as 10.40.2.201 you can changed that for your needs

1) Installing MySQL

Let’s install mysql-server, mysql-client with the below command

me@my-desktop:~$ sudo apt-get install mysql-server mysql-common \ mysql-client

Please say “y” when asked to install above packages with all dependicies.
Now once the installer downloads all the packages and onces install them it will show you screen like below to enter root password for mysql.

Click on image to Enlarge

2) Installing lighttpd:
Let’s install lighttpd with below command, before executing below command make sure you don’t already have Apache installed and running.Once done by default on ubuntu lighttpd serves a default home page. When Installer asks “you Do you want to continue [Y/n]?” please say “y” to continue.

me@my-desktop:~$ sudo apt-get install lighttpd

Once you have installed the package lighttpd you can view the default page by accessing your web server from browse,which would look like below:

Click on the image to Enlarge

Click on the image to Enlarge

3) Installing php5-cgi:
Let’s install PHP5-cgi, as fast-cgi is required for running php based site/apps on lighttpd.

me@my-desktop:~$sudo apt-get install php5-cgi
you can create a test.php in the DocumentRoot of the web server which is by default “/var/www/” and try to access it, I have contains like this in test.php file ,
you would get some error page like below;

Click on the Image to Enlarge

Click on the Image to Enlarge

4) Configuration of lighttpd to support PHP
Once we have installed packages on the Ubuntu box we will now move forward configuring lighttpd
so that it can run php it easy as you need to copy a file called “10-fastcgi.conf” from
“/etc/lighttpd/conf-available” to “/etc/lighttpd/conf-enabled” once done, restart your lighttpd instance by running “/etc/init.d/lighttpd restart” can check by running earlier created “test.php” by http://mydomain.net/test.php it should show you phpinfo page.

5) Installing phpmyadmin

Let’s install phpmyadmin so we can manage Mysql-server from browser more easier way :)

me@my-desktop:~$sudo apt-get install phpmyadmin
Now you can access the installed phpmyadmin with your http://yourservername/phpmyadmin. In my case it is http://mydomain.com/phpmyadmin, below is the screen shot of the same.

Please give comments on other ways to do the same setup.

Increase the LV (Logical Volume ) size online.

Let say you have a Logical Volume named users1 which is created under vg0, you had give 100 MB size while creating the same. Now as requirement grows you need to have 500 MB, while increasing the size you can afford to lose data or take the “users1” Logical volume offline.

The LVM system organizes hard disks into Logical Volume (LV) groups. Essentially physical hard disk partitions (or possibly RAID arrays) are set up in a bunch of equal sized chunks known as Physical Extents (PE).

$lvdisplay /dev/vg0/users1

The above command is to verify the size of Logical Volume.

df -h or df -h mounted directory name

With one of the above command you can verify the size on mounted directory:

$lvextend -L+400M /dev/vg0/users1

The above command will extend the size to 400 MB so it will be of total 500 MB.

$ resize2fs /dev/vg0/users1

The above command will bring extended size online.

Now you can verify using lvdisplay and df -h commands