Tuesday, August 31, 2010

Hosting multiple websites with Apache2

There are many different ways you can configure Apache to host multiple sites, ranging from the simple to the complex. Here we're only going to cover the basics with the use of the NameVirtualHost directive. The advantage of this approach is that you don't need to hard-wire any IP addresses, and it will just worktm. The only thing you need is for your domain names to resolve to the IP address of your webserver.

For example if you have an Apache server running upon the IP address 192.168.1.1 and you wish to host the three sites example.com, example.net, and example.org you'll need to make sure that these names resolve to the IP address of your server.

(This might mean that you need example.com and www.example.com to resolve to the same address. However that is a choice you'll need to make for yourself).

Since we'll be hosting multiple websites on the same host it makes a lot of sense to be very clear on the location of each sites files upon the filesystem. The way I suggest you manage this is to create a completely seperate document root, cgi-bin directory, and logfile directory for each host. You can place these beneath the standard Debian prefix of /var/www or you may use a completely different root - I use /home/www.

If you've not already done create the directories to contain your content, etc, as follows:

root@irony:~# mkdir /home/www

root@irony:~# mkdir /home/www/www.example.com
root@irony:~# mkdir /home/www/www.example.com/htdocs
root@irony:~# mkdir /home/www/www.example.com/cgi-bin
root@irony:~# mkdir /home/www/www.example.com/logs

root@irony:~# mkdir /home/www/www.example.net
root@irony:~# mkdir /home/www/www.example.net/htdocs
root@irony:~# mkdir /home/www/www.example.net/logs
root@irony:~# mkdir /home/www/www.example.net/cgi-bin

root@irony:~# mkdir /home/www/www.example.org
root@irony:~# mkdir /home/www/www.example.org/htdocs
root@irony:~# mkdir /home/www/www.example.org/logs
root@irony:~# mkdir /home/www/www.example.org/cgi-bin

Here we've setup three different directory trees, one for each site. If you wanted to have identical content it might make sense to only create one, and then use symbolic links instead.

The next thing to do is to enable virtual hosts in your Apache configuration. The simplest way to do this is to create a file called /etc/apache2/conf.d/virtual.conf and include the following content in it:

#
# We're running multiple virtual hosts.
#
NameVirtualHost *

(When Apache starts up it reads the contents of all files included in /etc/apache2/conf.d, and files you create here won't get trashed on package upgrades.)

Once we've done this we can create the individual host configuration files. The Apache2 setup you'll find on Debian GNU/Linux includes two directories for locating your site configuration files:

/etc/apache2/sites-available

This contains configuration files for sites which are available but not necessarily enabled.
/etc/apache2/sites-enabled

This directory contains site files which are enabled.

As with the conf.d directory each configuration file in the sites-enabled directory is loaded when the server starts - whilst the files in sites-available are completely ignored.

You are expected to create your host configuration files in /etc/apache2/sites-available, then create a symbolic link to those files in the sites-enabled directory - this will cause them to be actually loaded/read.

Rather than actually messing around with symbolic links the Debian package includes two utility commands a2ensite and a2dissite which will do the necessary work for you as we will demonstrate shortly.

Lets start with a real example. Create /etc/apache2/sites-available/www.example.com with the following contents:

#
# Example.com (/etc/apache2/sites-available/www.example.com)
#

ServerAdmin webmaster@example.com
ServerName www.example.com
ServerAlias example.com

# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/www/www.example.com/htdocs/

# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.example.com/cgi-bin/

Options +ExecCGI



# Logfiles
ErrorLog /home/www/www.example.com/logs/error.log
CustomLog /home/www/www.example.com/logs/access.log combined


Next create the file www.example.net:

#
# Example.net (/etc/apache2/sites-available/www.example.net)
#

ServerAdmin webmaster@example.net
ServerName www.example.net
ServerAlias example.net

# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/www/www.example.net/htdocs/

# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.example.net/cgi-bin/

Options +ExecCGI



# Logfiles
ErrorLog /home/www/www.example.net/logs/error.log
CustomLog /home/www/www.example.net/logs/access.log combined


Finally create the file www.example.org:

#
# Example.org (/etc/apache2/sites-available/www.example.org)
#

ServerAdmin webmaster@example.org
ServerName www.example.org
ServerAlias example.org

# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/www/www.example.org/htdocs/

# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.example.org/cgi-bin/

Options +ExecCGI



# Logfiles
ErrorLog /home/www/www.example.org/logs/error.log
CustomLog /home/www/www.example.org/logs/access.log combined


Now we've got:

* Three directories which can be used to contain our content.
* Three directories which can be used to contain our logfiles.
* Three directories which can be used to contain our dynamic CGI scripts.
* Three configuration files which are being ignored by Apache.

To enable the sites simply run:

root@irony:~# a2ensite www.example.com
Site www.example.com installed; run /etc/init.d/apache2 reload to enable.

root@irony:~# a2ensite www.example.net
Site www.example.net installed; run /etc/init.d/apache2 reload to enable.

root@irony:~# a2ensite www.example.org
Site www.example.org installed; run /etc/init.d/apache2 reload to enable.

This will now create the symbolic links so that /etc/apache2/sites-enabled/www.example.org, etc, now exist and will be read.

Once we've finished our setup we can restart, or reload, the webserver as the output above instructed us to do with:

root@irony:~# /etc/init.d/apache2 reload
Reloading web server config...done.
root@irony:~#

Sunday, August 29, 2010

Download Manager Untuk Ubuntu - FatRat

fatrat linux download manager

FatRat is the big brother of SlimRat (or is it fat brother?) which we previously covered HERE. So what is it? Well, it's an open source download manager for Linux but not an ordinary one. Read on!


FatRat comes with many very interesting options. For one, it can download from HTTP(S)/FTP, RapidShare free and even YouTube. But FatRat can also download torrents, (it has BitTorrent support) has RSS feed support + special functions for TV shows and podcasts, support for SOCKS5 and HTTP proxies and even remote control via Jabber and a web interface and of course, a scheduler. FatRat has way to many options to list them here so check it out for yourself by installing FatRat (instructions further down).

fatrat webui
(FatRat WebUI)



The RapidShare support doesn't just include downloads, but also verifying links, decoding links and exract files from a RapidShare.com folder.

fatrat download dialog


FatRat also comes with plugin support and for now there are 3 plugins available: integration with OpenSubtitles.org - easy subtitle searching, CZshare.com download and upload support and unpack or pipe RAR (and ZIP optionally) archives inside the application. You can check out these plugins, HERE.


I've seen lots of download managers for Linux, but I must say I am impressed by FatRat: it is very easy to use, lightweight and still has lots of really nice features.


Install the latest FatRat version in Ubuntu

FatRat is available in the Ubuntu official repositories, but that's not the latest version (not even in Lucid) so to be able to easily install the latest FatRat 1.2.0 in Ubuntu Karmic and Lucid, I've uploaded it to the WebUpd8 PPA.

To install FatRat, you must firstly add the PPA (note: make sure you check out the packages in the PPA first as there are some SVN packages there, such as VLC 1.1.0, etc.):

sudo add-apt-repository ppa:nilarimogard/webupd8



And then install FatRat:

sudo apt-get update && sudo apt-get install fatrat



If you're not using Ubuntu, download FatRat from HERE.

Wednesday, August 25, 2010

How to view hidden passwords without using any software.

You must have seen and used softwares which are capable to show all the passwords hidden behind Asterisks on a webpage but downloading,installing and using a software is always boring and time taking job so finding an another way will be beneficial.

Recently i came across a cool javascript that can show all the passwords hidden behind Asterisks what you need to do is to just simply copy and paste the javascript to the address bar and the hidden password will be shown to you.Isn’t this a cool and easy way to show and view hidden password rather than using a software.

First of all open up the webpage on which you wanna show the hidden passwords and then Just copy and paste the following JavaScript into the address bar of the browser and you are done.


javascript:(function(){var%20s,F,j,f,i;%20s%20=%20%22%22;
%20F%20=%20document.forms;%20for(j=0;%20j<F.length;%20++j)
%20{%20f%20=%20F[j];%20for%20(i=0;%20i<f.length;%20++i)
%20{%20if%20(f[i].type.toLowerCase()%20==%20%22password%22)
%20s%20+=%20f[i].value%20+%20%22\n%22;%20}%20}%20if
%20(s)%20alert(%22Passwords%20in%20forms%20on%20this
%20page:\n\n%22%20+%20s);%20else%20alert(%22There%20are
%20no%20passwords%20in%20forms%20on%20this
%20page.%22);})();



After copying and pasting the JavaScript given above press the enter key and hidden passwords will be shown to you.

Following is the screenshot of hidden password that is shown the JavaScript given above.

Note : I have tested this javascript in IE,Firefox and Opera and it is working perfectly

Thursday, August 19, 2010

Ubuntu LAMP Server Guide – Configure Apache, mySQL, and cgi-bin

By Sam Davis on Aug 21, 2007 filed under Featured, Guides, Tips, Ubuntu

Ubuntu LogoIn a previous post, I shared step-by-step instructions for setting up a Ubuntu LAMP (Linux, Apache, mySQL, PHP) server on your local area network (LAN). I also showed how you could customize the server installation to include all of the niceties of Ubuntu’s Desktop GUI. If this installation was successful, you should be able to view the default site served by Apache (actually an index of the default site) using any machine on your LAN. Type the server’s IP address (or alias if you added the server to your /etc/hosts file) in your browser’s address bar or, if you are browsing on the server itself, type 127.0.0.1 or localhost. If an error occurs, then you will have to edit the apache2.conf file to ensure that Apache can fully resolve the server’s name. Out of good measure you should do this anyway, even if everything seems to be working. Use your favorite text editing program (I use vi here) and open the file.
sudo vi /etc/apache2/apache2.conf

Add the following line somewhere:
ServerName localhost

and restart Apache.
sudo /etc/init.d/apache2 restart

If the default site loads then you are ready to configure Apache to serve your own sites. This configuration process may not be familiar to you if someone else hosts your websites. Here I walk you through the necessary steps. Additionally, I show you how to install phpMyAdmin to administer mySQL databases and how to configure a cgi-bin directory to run CGI programs.

Step 1: Create a new Apache site

To create a new site, first create a directory where you want to keep files associated with this site. I like to keep sites in my home directory so (using my user name of sam) I create a /home/sam/public_html directory. The configuration files for all sites available to Apache are stored in the /etc/apache2/sites-available/ directory. Create a configuration file for your new site (here called zaphu) by copying the configuration file for the default site.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/zaphu

Open the new configuration file.
sudo vi /etc/apache2/sites-available/zaphu

You will notice that there is a lot of stuff between tags. You have to edit some of this. Change the DocumentRoot path to point to the newly created site directory.
DocumentRoot /home/sam/public_html

In a similar fashion, change one of the Directory directives (it looks something like this)


to be consistent with your site path.


After making these changes, disable the default site using the Apache disable site script.
sudo a2dissite default

Next, use the Apache enable site script to activate the new site.
sudo a2ensite zaphu

Finally, restart Apache.
sudo /etc/init.d/apache2 restart

Create a simple index.html file and save it in /home/sam/public_html/ to test your new site. Something simple like

Ubuntu Hardy Heron is Here

Browse (preferable on another machine) to your new site to test the configuration.
Step 2: Install phpmyadmin and create root mySQL user

In order to make mySQL database administration easy, many hosts provide phpMyAdmin. You can easily install this tool on your Ubuntu LAMP server too using the built in package management software. At the command prompt type
sudo aptitude update
sudo aptitude install phpmyadmin

You will have to insert the Ubuntu install CD to complete this installation. During the installation the script will ask which version of Apache to automatically configure. If you installed apache as per this previous post then select apache2 (with space bar) and continue. After the install completes, the phpMyAdmin script should be in the /usr/share/directory and (after restarting Apache; see above) it should resolve in your browser when you type localhost/phpmyadmin (or xxx.xxx.xxx.xxx/phpmyadmin). If it doesn’t, you must add the following alias and include to the bottom of the apache configuration file apache2.conf in /etc/apache2/.
Include /etc/phpmyadmin/apache.conf
Alias /phpmyadmin /usr/share/phpmyadmin

You can log in by using root as your username and the root password configured during the mySQL installation (if you decided not to enter a mySQL password or were not prompted for a password then the password field is blank by default). Once logged on to phpMyAdmin, you can set a new root password by navigating to the privileges page, clicking the icon that looks like a pencil next to each root account (there may be more than one), and entering a password in the appropriate field of the page that loads.
Step 3: Configure a cgi-bin directory

Configuring Apache to allow CGI program execution is pretty easy. Create a directory to be used for CGI programs (here I create /home/sam/public_html/cgi-bin) and add the following to the site configuration file (again between the tags).
ScriptAlias /cgi-bin/ /home/sam/public_html/cgi-bin/

Options ExecCGI
AddHandler cgi-script cgi pl


The first line creates an alias that points to the directory in which CGI scripts are stored. The final line tells Apache that only files that end with the *.cgi and *.pl extensions should be considered CGI programs and executed.

Congratulations! Your new site is configured. It is worth mentioning that if you are going to be granting computers on the wide area network access to your new Ubuntu LAMP server, you should take some time to learn how to properly secure Apache. Check out these other sites for more information on configuring Apache under Ubuntu. Ubuntu Community, Apache2.2 Documentation

If you liked this guide, show support by leaving comments and visiting our sponsors.

Wednesday, August 18, 2010

Installing Joomla 1.5.X On Ubuntu

* Home
* About
* Subscribe to Posts

Installing Joomla 1.5.X On Ubuntu

* Posted by ubun2Junky
* 19 May 2009


Creating professional looking web sites has greatly improved with the emerging number of CMS tools. CMS have come along way! CMS (Content Mangement System) allows a community or group of people to manage the content of a web site. This becomes a very powerful tool, as it empowers all members of the community to keep their data updated. The need to constantly place request to the web admin are over. Users can now manage their own piece of the pie!

I’ll go over the basic steps of installing and configuring Joomla.

Steps

* Install dependencies
* Download Joomla software
* Modify Permissions
* Install Joomla
* Install Dependencies

Like always we’ll need to install some pre-requisite software before we can even start. In order for Joomla to effectively work, we need to install the following software.

* Apache2
* PHP5
* MySQL
* VSFTP (Very Secure FTP)

Using terminal type the following:

sudo apt-get install apache2 php5 mysql-server php5-mysql unzip


During the installation you will be prompted to enter a password for the ‘root’ user in MySQL. Pick any password and enter it. Remember the password since you are going to need to reference it later. In my example I’m going to use mysqlPass.

MySQL Password

Now we need to install VSFTPS. In order to have Joomla import and export files into the web server it’s going to need an FTP connection in order to accomplish that. We’re going to install VSFTP it’s a straight forward FTP daemon and easy to configure.

sudo apt-get install vsftpd

Now we need to configure VSFTP:

* sudo nano /etc/vsftpd.conf

* Change ‘anonymous_enable = YES’ to ‘anonymous_enable = NO’

* Change ‘#local_enable = YES’ to ‘local_enable=YES‘(remove the # sign).

* Change ‘#write_enable = YES’ to ‘write_enable=YES‘(remove the # sign).
* Ensure that local_umask is uncommented and looks like ‘local_umask=077‘

Save your changes: [ctrl + X], Save Modified Buffer [Y], Press [Enter] to the default file name.

NOTE: To uncomment ensure that there is NO ‘#’ sign at the beginning of the line.

In order to be able access the FTP site we’re going to need to create a dedicated user that will be able to access the joomla site.

sudo useradd joomlaUser

sudo passwd joomlaUser

for our example we’re going to assign this password to be ftpPass

sudo mkdir /var/www/joomla

sudo ln -s /var/www/joomla /home/joomlaUser

Last dependency file that we’re going to configure will be php.ini

* sudo nano /etc/php5/apache2/php.ini

* We need to find ‘display_errors = On’ and change it to ‘display_errors = Off’

* Next we need to change ‘;session.save_path = /var/lib/php5‘ to ‘session.save_path = /var/lib/php5‘ (simply remove the ‘;’)

save your changes and exit.

Download Joomla Software

Now we’re ready to download Joomla. At the time of this writing, version 1.5.15 was the latest version. Please check www.joomla.com for the latest version.

cd /var/www

sudo wget http://joomlacode.org/gf/download/frsrelease/11396/45610/Joomla_1.5.15-Stable-Full_Package.zip

sudo unzip Joomla_1.5.15-Stable-Full_Package.zip -d /var/www/joomla

Modify Permissions

Now that we have Joomla downloaded and unzipped in the directory that we wish to use, we’ll need to modify permissions so that Joomla can write to it.

sudo chmod 777 -R /var/www/joomla

Install Joomla

Now we’re ready to actually start installing and configuring Joomla!

Before we start we’re going to restart all our services.

sudo /etc/init.d/apache2 restart

sudo /etc/init.d/vsftpd restart

If you’re using ubuntu server with command line like I am, you are going to need the ip address of your server so you can access the joomla web interface.

ifconfig

eth0 Link encap:Ethernet HWaddr 00:0c:29:c9:86:84
inet addr:192.168.0.237 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec9:8684/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46210 errors:0 dropped:0 overruns:0 frame:0
TX packets:28816 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59888493 (57.1 MB) TX bytes:2798305 (2.6 MB)
Interrupt:17 Base address:0×1400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:85 errors:0 dropped:0 overruns:0 frame:0
TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6880 (6.7 KB) TX bytes:6880 (6.7 KB)

In my case I get something like the above. My ip address for my server is at 192.168.0.237

Open up a web browser and type in the following (of course substitute your IP address for mine!):

* http://192.168.0.237/joomla

You should now see joomla’s installation site and it should be prompting you for the default language. Select your language and click on ‘next’.

Language Selection

Language Selection

The second screen should now run a diagnostics pre-installation test. The top window should have all YES and the bottom window should have all OFF if we did everything correctly. If everything looks like the below image select ‘next’.
Preinstallation Configuration

Preinstallation Configuration

The next screen simply shows you the GPL (General Public License). Once you’ve finished reading it select ‘next’.
General Public License

General Public License

We are now ready to enter our configuration information for our MySQL database into Joomla.

* Database type should be MySQL by default.

* Host name should be localhost unless you have a different machine hosting the database. Username should be root.

* Password should be the password you assigned root when you installed MySQL. I’m going to user mysqlPass.

Database name should be joomla. (You can assign any name you like, I just chose Joomla)
MySQL Configuration

MySQL Configuration

If everything is going well, we should be seeing the FTP configuration screen.

* Enable FTP file system layer should be YES

* FTP User should be joomlaUser

* FTP Password should be the password you assigned to the joomlaUser. I’m going to use ftpPass.

* Click on ‘Autofind FTP Path’ the ftp root path field should now be populated with ‘/var/www/joomla’

* At the bottom select YES for save FTP password.

FTP Configuration

FTP Configuration

We are now on the main configuration page. This is the last page before we finish!

* Site name is the name you want to call your web site. I choose ‘My Site‘

* Enter your email here to receive notifications for the super admin group

* The password you enter here is the password that you will later on have to use to enter the administration back end tool. I’m going to use joomlaPass

* Select Install sample data if you would like to include the sample data into your joomla installation. I would recommend this if this is your first time dealing with Joomla. Good way to see were everything goes.

Main Configuration

Main Configuration

If everything went alright we should now be at the finish. The warning you see on the right side means that we must remove the installation directory on joomla so we don’t accidently run the installation process once again.
Complete

Complete

To wrap things up we’ll remove the installation directory

Once again using terminal:

* sudo rm -r /var/www/joomla/installation

* We can now click on the top right button of the finish page where it says ‘Admin‘

* The new page should now be prompting us for a username and password. The default username is admin and the password is the password you set earlier. I’m going to use joomlaPass.

Backend Login

Backend Login

You are now ready to create and modify your very own Joomla site! To access the frontend of the site you can type in http://yourserverip/joomla

Enjoy!