Posts Tagged ‘installed’

Adding multiple VirtualHosts hosting on fresh installed Debian GNU / Linux

Monday, September 10th, 2012

Nowdays most of my new (fresh) Linux server configurations are installed with Debian Linux.

Through the years I worked with most major GNU / Linux distributions. Though intalling Apache for multiple domain VirtualHost-ing is almost equally easier to set up on all distros I tried, (Slackware, Redhat, Fedora) etc., I found Debian to be most convenient in terms of freqeuent easy updates and general security.

Every time I configure a new host which is supposed to host a dozen of websites with Apache webserver and a DB backend, it is of course necessery to enable the server to have support multiple domain VirtualHosts.

I thought there are people out who look to configure Multiple domains on fresh installed Apache webserver and this how this short post get born.

I will explain hereby in short how I configure VirtualHosts on new Debian Linux servers with fresh installed Apache.

All required to have a working many domains hosted VirtualHosts on Debian is:

1. Have installed Apache serve package

# apt-get --yes install apache2

This would install all packages necessery for VirtualHost-ing.
After apache2 installed the system should have at least this packages present.

# dpkg -l |grep -i apache2
ii apache2-mpm-prefork 2.2.16-6+squeeze7 Apache HTTPServer - traditional non-threaded model
ii apache2-utils 2.2.16-6+squeeze7 utility programs for webservers
ii apache2.2-bin 2.2.16-6+squeeze7 Apache HTTPServer common binary files
ii apache2.2-common 2.2.16-6+squeeze7 Apache HTTPServer common files
ii libapache2-mod-php5 5.3.3-7+squeeze14 server-side, HTML-embedded scripting language (Apache 2 module)

Nowadays, having enabled mod_rewrite is necessery in almost any website, so the next thing I usually do is enable mod_rewrite webserver module.

# ln -sf /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
# apache2ctl -k restart

By default there is an index.html page containing the annoying phrase It Works!

I really dislike this default page and many times I start configuring a server, I wonder how to remove it; if you’re like me before doing anything other I advice you edit /var/www/index.html to change it to Coming Soon or just substitute the file with some nice looking Coming Soon page (custom page) …

Once this is done, I proceed adding as many Virtualhosts as I need with the respective Virtualhost names. To Do so on Debian, just create new Vhost config files in files /etc/apache2/sites-available/yoursite.com, /etc/apache2/sites-available/yoursite1.com etc.br />
Before creating any other VHosts, I usually edit the main webserver VirtualHost which is located in /etc/apache2/sites-available/000-default, there in the VirtualHost section normally need to add proper:

ServerName and ServerAlias variables as well as change DocumentRoot to whatever the default server host Virtualhost directory will be.

An example of 000-default Vhost config I do looks like so:

<VirtualHost *>ServerName server-main-host-name.com
ServerAlias www.server-main-host-name.com server-main-host-name.com
DocumentRoot /var/www
....
</Virtualhost>

Onwards add the same ServerName server-main-host-name.com as a new line in /etc/apache2/apache2.conf config

Now for those not too unfamiliar with VirtualHost types, it is useful to say there are two ways of VirtualHosts:

  • IP Based VirtualHost
  • and

  • Host Based VirtualHosts

IP Based VirtualHosts are added by using Apache directive syntax:

<VirtualHost 192.168.0.2:80>
ServerName ....
ServerAlias ....
</VirtualHost>

whether Host Based VirutalHosts are added by using in config file, the IP address on which the respective Vhost will reside:

<VirtualHost *>
ServerName ....
ServerAlias ....
</VirtualHost>

Host Based VirtualHosts directive syntax can be either in form:

a)Virtualhost *
or
b) Virtualhost port_number (Virtualhost 80, VirtualHost 90) etc.

If a host is configured with directive <VirtualHost *>, this means it will listen for incoming connections on any port Apache is configured to listen on, whether if used with a concrete port number it will only enable VirtualHosts for whole Apache server on the concrete port.

Based on the configuration, VirtualHost 80 or Virtualhost *, the variable which will enable globally on the Apache server multiple VirtualHosts has to be modified e.g.:
Whether VirtualHost with port number is configured <VirtualHost 80>, NameVirtualHost 80 should be used or otherwise NameVirtualHost *

Once you choose the type of Virtualhost-ing, just continue on adding the VirtualHosts …
In the first created VirtualHost config file, let’s say /etc/apache2/sites-available/first-virtualhost.com

NameVirtualHost * has to be added as first line in file; in other words the file content should look similar to:

NameVirtualHost *
<VirtualHost*>
ServerAdmin hipo_aT_www.pc-freak.net AddDefaultCharset UTF-8 DocumentRoot /var/www/ ServerName www.pc-freak.net ServerAlias www.pc-freak.net....
</VirtualHost>

The same steps has to go for all domain names in separate files except the variable NameVirtualHost * should not be added in the rest of new created Vhosts.

Many of the new configured Debian + Apache servers does not require support for SSL, therefore where SSL support is not necessery I prefer disabling it.
To do so it is necessery to comment out everything dealing with Secure Socket Layer in /etc/apache2/ports.conf, as of time of writting lines to comment are:

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>

An absolutely must have installed packages to have a complete Ubuntu / Debian Desktop

Saturday, September 19th, 2009

Every time after installing a plain new Debian or Ubuntu system, I feel ridiculous cause of the fact. That many of the programs I do use in my daily work with my pc ain’t there ready to use. In that manner of thoughts it’s really really irritating for me to try to memorize the whole list of programs I usually use not to mention that I hardly could remember the exact name of the packages containing the programs. Moreover it’s really irritating to type a hundred times
apt-cache search programname;
apt-get install programtoinstall;
.To make my daily life and hopefully my blog readers life easier I’ve decided to make a list of all the packages to install:
here is the one liner command required to install the whole heap of packages
$ apt-get install flashplugin-nonfree gstreamer0.10-plugins-ugly libxine1-ffmpeg vlc mozilla-plugin-vlc mplayer wifi-radar extremetuxracer powermanga supertux chromium kbedic transmission openoffice.org deluge alltray xine-ui dodgindiamond2 zblast-x11 blobwars briquolo kamefu blender inkscape gftp xchat k3b gnochm tecnoballz audacious audacity rezound opencubicplayer virtualbox gnomad2 kino grip xawtv cheese mozilla-helix-player abiword bgoffice-computer-terms sun-java-fonts sun-java6-jdk sun-java6-plugin sun-java6-source sun-java6-jre sun-java6-demo dia gajim mc dpkg-dev amsn elinks lynx iptraf sniffit ettercap wireshark bluefish thunderbird screenlets verse bible-kjv dict-easton gnomesword sword-text-kjv realplayer pidgin ncurses-dev cbedic awn-manager centerim-utf8 apachetop alsa-oss oss-compat iftop
For your convenience I’ve also prepared a small shell script I’ve called desktop-bundle.sh download desktop-bundle.sh here
Just in case if you’re wondering what exactly is the above package bundle installation good for.
Here is a few explanatory notes next to it:

mozilla-plugin-vlc – Allows mozilla to play in embeded player various video files

gftp – Gnome’s FTP client

xchat – IRC Gnome Chat program

cheese – A program to make pictures and suchalike

k3b – kde’s cd burner

kino – video editor

sun-java6-jdk, sun-java6-jre, sun-java6-plugin – allows you to run properly java applications on your Linux system both from the command line and in browser

screenlets – explained in my previous post here

wifi-radar – a gnome wifi detection and connection tool

cbedic – a bulgarian / english console dictionary I heavily use

dia – Diagram drawing software (handy to draw your for instance network diagrams)

kbedic – kde Bulgarian / English dictionary. To make it work properly you’ll need also the bedic data files, which could be downloaded here

verse, bible-kjv, gnomesword – This and the rest bible related packages are a nice packages I use to daily read and research the bible, since I’m an Orthodox Christian

vlc – Nowdays I’m changing in using vlc to watch videos since mplayer is getting more and more old fashioned and it’s behaviour is a bit disappointing sometimes

gnomechm – An app to read Microsoft’s CHM help file

grip – Program to RIP audio files

opencubicplayer – the good old Cubic Player we all enjoyed in MS-DOS and Novell DOS to play various XM, S3M, MOD, IT etc. files, it’s really nice that this version supports MP3 file format

audacity – An application to record sounds, supports songs sound reverse, for example you can use it to listen your mp3 files backwards, let’s say to check if a song contains a satanic message or not 🙂

dosbox – dos emulator to run old school dos games I love this one

inkscape – 2D vector design software

blender – 3D design software

gajim – might need that one in case if you intend to use Jabber

pidgin – the program I use as an ICQ, MSN client

transmission, deluge – nice bittorrent softwares

kompozer, bluefish – editors similar more or less to the famous dreamweaver. kompozer is more advanced and is much closer to dreamweaver

virtualbox – The Sun’s Virtual Machine substitute for VMWare, works okay maybe 20 or 30% slower than VMWare

rezound – again a nice sound editor, like audacity

xine – video player, most people who remember the times before few years should know it

amsn – MSN chat client

avant-window-navigator – A MacOS X like panel for the GNOME Desktop. Features a taskbar behaving similar to Mac OSX’s dock.
There is one drawback it doesn’t support the dock to be positioned anywhere except on the bottom of the screen
chromium, supertux, powermanga etc. – this and many of the rest are nice games I love to play every now and then when I get completely pissed off

Well that’s all for now. Hope this post would be interesting to somebody out there.

END—–