Wednesday, September 7, 2011

Useful commands for ubuntu

For read apache error log

tail -f /var/log/apache2/error.log

get apptitude

sudo apt-cache search aptitude

sudo apt-get install aptitude

sudo aptitude search rewrite

enable rewrite engine

sudo a2enmod rewrite

Monday, September 5, 2011

Setting up Virtual Hosts with XAMPP running on Windows XP


Setting up virtual hosts with XAMPP is very straight forward and could be done in less than 5 minutes. Although, your local XAMPP server will still work even if virtual hosts are not configured. You might want to ask, is there a need for my local XAMPP setup to configure virtual hosts? Apparently, virtual hosts are needed when

  • your on multiple domains
  • your need to test your projects with same configuration with the server
  • test your projects without touching your public server
  • your just organizing your projects into groups
  • or setup a local copy of your blog or website
What do we need?
This document assumes that you are working with Windows XP with XAMPP. If you don't have XAMPP, get it at their XAMPP for Windows download page. Just execute the exe file and follow the onscreen instructions.

Configuring Windows XP to accept hosts
Hosts is a file under Windows XP that is used to map IP addresses to a custom list of hosts or maybe domain names. The IP address should be placed in one line. The first column should contain the IP address and on the second column its corresponding hostname. The IP address may be separated by a space or by a tab. You can place comments by prepending your line this symbol '#' (pound sign). Initially the first line is added. Now lets add our domain tildemark.com

127.0.0.1       localhost
127.0.0.1       www.tildemark.com
127.0.0.1       tildemark.com

you can check your work by doing a ping to your configured host.


Configuring XAMPP to accecpt Virtual Hosts
  1. Got to your Apache folder in XAMPP and locate the conf files. The are usually located at <<local path>>\xampp\apache\conf\extra
  2. Open the file named httpd-vhosts.conf with a text editor
  3. If posible read the instructions so may have the idea on what you are doing
  4. Now paste the following code at the bottom of the file without touching the document.

    NameVirtualHost 127.0.0.1:80
    <VirtualHost 127.0.0.1:80>
      DocumentRoot E:/xampp/htdocs/    # change this line with your htdocs folder
      ServerName localhost
    </VirtualHost>
  5. Edit the line DocumentRoot with your own document root folder
  6. For each domain you are to configure paste the following lines below, just replace my domain name your corresponding domain:
<VirtualHost www.tildemark.com>
  DocumentRoot "E:\www\www.tildemark.com"
  ServerName www.tildemark.com
  ServerAlias www.tildemark.com

  CustomLog "E:\www\www.tildemark.com\www.tildemark.com-access_log" combined
  ErrorLog "E:\www\www.tildemark.com\www.tildemark.com-error_log"

  <Directory "E:\www\www.tildemark.com">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Tuesday, August 30, 2011

CodeIgniter – No input file specified error – .htaccess – PHP5 – Apache 2

simply i used following .htaccess code


RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]


difference of below code and codeigniter documentation code is "?" of third row. i highlighted it.


How to setup virtual host in ubuntu

Step 1: setup a virtual domain
open /etc/hosts and add a virtual domain with a specific local IP. In this file it contains ip and domain name separated by a space. You can also add the port using a colon with the IP. Lets assume that our virtual domain name is “domain.local” – and It will listen to the ip “127.0.0.1″

so we will add the following line to our /etc/hosts file
127.0.0.1 domain.local

now whenever you point to http://domain.local – your browser will actually open http://127.0.0.1

Step 2: configure virtual host with apache

here we will configure our newly added virtual domain against apache as a virtual host, and did I forget to say, with mod_rewrite enabled :)
goto /etc/apache2/sites-available and create a file named “domain.local” – I recommend to keep it the same name as your virtual domain.
sudo gedit /etc/apache2/sites-available/domain.local
write the following contents inside. but please note to create the appropriate directory before linking your virtual host with that, for example we’ve create a folder named “/var/www/domain” and linked that directory as my document root in the following configuration file.

<VirtualHost *:80>
ServerName domain.local
DocumentRoot " /var/www/domain"
DirectoryIndex index.html index.php

<Directory " /var/www/domain">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

now create a symbolic link of this file to /etc/apache2/sites-enabled directory as “domain.local”
sudo ln -s /etc/apache2/sites-available/domain.local /etc/apache2/sites-enabled/domain.local

Step 3: restart apache (or reload)
simple, either one of the followings
sudo /etc/init.d/apache2 restart
or
sudo /etc/init.d/apache2 reload
and you are done! now you can point your browser to http://domain.local


Wednesday, March 30, 2011

How to Install Firefox 4 in Ubuntu Linux


Earlier today, we reported that Firefox 4 has just been released. Why do you need instructions to install the newest Firefox in Ubuntu? If you go into your Ubuntu Software Center, you’ll see that you more than likely have Firefox 3.6 installed, and it’s “up to date”. Naturally, they don’t add programs to the Software Center as soon as they are released. That would be foolish if there was something wrong with the new version. I don’t blame them for waiting at least a few days for the adventure seekers to provide some feedback.
There are three ways that I know of to add the newest Firefox to Ubuntu.
firefox 4

Method 1: Download Bzipped Package

You can go to the Firefox download page, download the TAR.BZ2 package and manually install it. The advantage of that method is that you won’t lose the current version 3.6 of Firefox. However, you’ll have to unpack the BZ2 file to a folder somewhere, locate the “firefox” executable file, then double click to launch it. If you’d like to, you can also create your own launcher link on the desktop or add it to a panel.

Method 2: Command Line Install

You can add the Firefox “Stable” repository and install the latest version from the command line in a terminal window. That’s actually the easiest method for most linux users. Here are the three simple commands you need to enter into the terminal.
sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get upgrade

Method 3: Software Center Install

Open your “Ubuntu Software Center” and click “Edit” > “Software Sources” then click the ‘Other Software’ tab. Add the PPA as shown below. When you exit the “Software Sources” applet, your Software Center will reload the repositories and it may even automatically find the updated Firefox for you.
ppa:mozillateam/firefox-stable
add firefox stable ppa to the software center




Sunday, March 27, 2011

Ubuntu Linux Configure DNS Name Server IP Address ( DNS Client )

Type the following command, enter:
sudo gedit /etc/resolv.conf

Append your ISP name server or free fast dns nameservers IP address as follows:
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 202.51.5.52



or
Use Google DNS


8.8.8.8
8.8.4.4

Wednesday, March 23, 2011

.htaccess & .htpasswd Files not Working in ubuntu

My solution to solve this is change /etc/apache2/sites-available/default

sudo vi /etc/apache2/sites-available/default
or
sudo nano ....
depending on your preference


You see something like:
Code:
<directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>

Change this to:
Code:
<directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
and restart apache (sudo /etc/init.d/apache2 force-reload) and you see the .htaccess file is read and you are required to enter a username/password