Friday, September 30, 2011

Setting Timezone in PHP

Time zone can be set as:


date_default_timezone_set('America/New_York');


date('Y-m-d H:i',time());


$timezones = array(
'Pacific/Midway'    => "(GMT-11:00) Midway Island",
'US/Samoa'          => "(GMT-11:00) Samoa",
'US/Hawaii'         => "(GMT-10:00) Hawaii",
'US/Alaska'         => "(GMT-09:00) Alaska",
'US/Pacific'        => "(GMT-08:00) Pacific Time (US & Canada)",
'America/Tijuana'   => "(GMT-08:00) Tijuana",
'US/Arizona'        => "(GMT-07:00) Arizona",
'US/Mountain'       => "(GMT-07:00) Mountain Time (US & Canada)",
'America/Chihuahua' => "(GMT-07:00) Chihuahua",
'America/Mazatlan'  => "(GMT-07:00) Mazatlan",
'America/Mexico_City' => "(GMT-06:00) Mexico City",
'America/Monterrey' => "(GMT-06:00) Monterrey",
'Canada/Saskatchewan' => "(GMT-06:00) Saskatchewan",
'US/Central'        => "(GMT-06:00) Central Time (US & Canada)",
'US/Eastern'        => "(GMT-05:00) Eastern Time (US & Canada)",
'US/East-Indiana'   => "(GMT-05:00) Indiana (East)",
'America/Bogota'    => "(GMT-05:00) Bogota",
'America/Lima'      => "(GMT-05:00) Lima",
'America/Caracas'   => "(GMT-04:30) Caracas",
'Canada/Atlantic'   => "(GMT-04:00) Atlantic Time (Canada)",
'America/La_Paz'    => "(GMT-04:00) La Paz",
'America/Santiago'  => "(GMT-04:00) Santiago",
'Canada/Newfoundland'  => "(GMT-03:30) Newfoundland",
'America/Buenos_Aires' => "(GMT-03:00) Buenos Aires",
'Greenland'         => "(GMT-03:00) Greenland",
'Atlantic/Stanley'  => "(GMT-02:00) Stanley",
'Atlantic/Azores'   => "(GMT-01:00) Azores",
'Atlantic/Cape_Verde' => "(GMT-01:00) Cape Verde Is.",
'Africa/Casablanca' => "(GMT) Casablanca",
'Europe/Dublin'     => "(GMT) Dublin",
'Europe/Lisbon'     => "(GMT) Lisbon",
'Europe/London'     => "(GMT) London",
'Africa/Monrovia'   => "(GMT) Monrovia",
'Europe/Amsterdam'  => "(GMT+01:00) Amsterdam",
'Europe/Belgrade'   => "(GMT+01:00) Belgrade",
'Europe/Berlin'     => "(GMT+01:00) Berlin",
'Europe/Bratislava' => "(GMT+01:00) Bratislava",
'Europe/Brussels'   => "(GMT+01:00) Brussels",
'Europe/Budapest'   => "(GMT+01:00) Budapest",
'Europe/Copenhagen' => "(GMT+01:00) Copenhagen",
'Europe/Ljubljana'  => "(GMT+01:00) Ljubljana",
'Europe/Madrid'     => "(GMT+01:00) Madrid",
'Europe/Paris'      => "(GMT+01:00) Paris",
'Europe/Prague'     => "(GMT+01:00) Prague",
'Europe/Rome'       => "(GMT+01:00) Rome",
'Europe/Sarajevo'   => "(GMT+01:00) Sarajevo",
'Europe/Skopje'     => "(GMT+01:00) Skopje",
'Europe/Stockholm'  => "(GMT+01:00) Stockholm",
'Europe/Vienna'     => "(GMT+01:00) Vienna",
'Europe/Warsaw'     => "(GMT+01:00) Warsaw",
'Europe/Zagreb'     => "(GMT+01:00) Zagreb",
'Europe/Athens'     => "(GMT+02:00) Athens",
'Europe/Bucharest'  => "(GMT+02:00) Bucharest",
'Africa/Cairo'      => "(GMT+02:00) Cairo",
'Africa/Harare'     => "(GMT+02:00) Harare",
'Europe/Helsinki'   => "(GMT+02:00) Helsinki",
'Europe/Istanbul'   => "(GMT+02:00) Istanbul",
'Asia/Jerusalem'    => "(GMT+02:00) Jerusalem",
'Europe/Kiev'       => "(GMT+02:00) Kyiv",
'Europe/Minsk'      => "(GMT+02:00) Minsk",
'Europe/Riga'       => "(GMT+02:00) Riga",
'Europe/Sofia'      => "(GMT+02:00) Sofia",
'Europe/Tallinn'    => "(GMT+02:00) Tallinn",
'Europe/Vilnius'    => "(GMT+02:00) Vilnius",
'Asia/Baghdad'      => "(GMT+03:00) Baghdad",
'Asia/Kuwait'       => "(GMT+03:00) Kuwait",
'Europe/Moscow'     => "(GMT+03:00) Moscow",
'Africa/Nairobi'    => "(GMT+03:00) Nairobi",
'Asia/Riyadh'       => "(GMT+03:00) Riyadh",
'Europe/Volgograd'  => "(GMT+03:00) Volgograd",
'Asia/Tehran'       => "(GMT+03:30) Tehran",
'Asia/Baku'         => "(GMT+04:00) Baku",
'Asia/Muscat'       => "(GMT+04:00) Muscat",
'Asia/Tbilisi'      => "(GMT+04:00) Tbilisi",
'Asia/Yerevan'      => "(GMT+04:00) Yerevan",
'Asia/Kabul'        => "(GMT+04:30) Kabul",
'Asia/Yekaterinburg' => "(GMT+05:00) Ekaterinburg",
'Asia/Karachi'      => "(GMT+05:00) Karachi",
'Asia/Tashkent'     => "(GMT+05:00) Tashkent",
'Asia/Kolkata'      => "(GMT+05:30) Kolkata",
'Asia/Kathmandu'    => "(GMT+05:45) Kathmandu",
'Asia/Almaty'       => "(GMT+06:00) Almaty",
'Asia/Dhaka'        => "(GMT+06:00) Dhaka",
'Asia/Novosibirsk'  => "(GMT+06:00) Novosibirsk",
'Asia/Bangkok'      => "(GMT+07:00) Bangkok",
'Asia/Jakarta'      => "(GMT+07:00) Jakarta",
'Asia/Krasnoyarsk'  => "(GMT+07:00) Krasnoyarsk",
'Asia/Chongqing'    => "(GMT+08:00) Chongqing",
'Asia/Hong_Kong'    => "(GMT+08:00) Hong Kong",
'Asia/Irkutsk'      => "(GMT+08:00) Irkutsk",
'Asia/Kuala_Lumpur' => "(GMT+08:00) Kuala Lumpur",
'Australia/Perth'   => "(GMT+08:00) Perth",
'Asia/Singapore'    => "(GMT+08:00) Singapore",
'Asia/Taipei'       => "(GMT+08:00) Taipei",
'Asia/Ulaanbaatar'  => "(GMT+08:00) Ulaan Bataar",
'Asia/Urumqi'       => "(GMT+08:00) Urumqi",
'Asia/Seoul'        => "(GMT+09:00) Seoul",
'Asia/Tokyo'        => "(GMT+09:00) Tokyo",
'Asia/Yakutsk'      => "(GMT+09:00) Yakutsk",
'Australia/Adelaide' => "(GMT+09:30) Adelaide",
'Australia/Darwin'  => "(GMT+09:30) Darwin",
'Australia/Brisbane' => "(GMT+10:00) Brisbane",
'Australia/Canberra' => "(GMT+10:00) Canberra",
'Pacific/Guam'      => "(GMT+10:00) Guam",
'Australia/Hobart'  => "(GMT+10:00) Hobart",
'Australia/Melbourne' => "(GMT+10:00) Melbourne",
'Pacific/Port_Moresby' => "(GMT+10:00) Port Moresby",
'Australia/Sydney'  => "(GMT+10:00) Sydney",
'Asia/Vladivostok'  => "(GMT+10:00) Vladivostok",
'Asia/Magadan'      => "(GMT+11:00) Magadan",
'Pacific/Auckland'  => "(GMT+12:00) Auckland",
'Pacific/Fiji'      => "(GMT+12:00) Fiji",
'Asia/Kamchatka'    => "(GMT+12:00) Kamchatka",
);

Saturday, September 24, 2011

Retrive utf8 character encoding from mysql table in Php

Before executing Mysql Query just these lines in the php code which helps to get utf8 character from mysql database
    mysql_query('SET character_set_results=utf8');
mysql_query('SET names=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_results=utf8');
mysql_query('SET collation_connection=utf8_general_ci');

All these lines are important just put as it is.

Adding 1 Hour to PHP Time

Here i am writing an example for adding 1 hour to any time. for this we need to convert the time or date to UNIX time like as in this code
<?php
$starttime = strtotime('09:00AM');
$endtime = strtotime('05:00PM');
while ($endtime >= $starttime) {
echo date('ga', $starttime).'<br>';
$starttime = $starttime + 3600;
}
?>

in the above code i am adding 3600 to $starttime which is equal to 1 Hour(60*60), So the way you want to make any increment just add that much seconds.

Wednesday, September 21, 2011

MySql Date Format

DATE_FORMAT(date,format)

Formats the date value according to the format string.

The following specifiers may be used in the format string. The “%” character is required before format specifier characters.

SpecifierDescription
%aAbbreviated weekday name (Sun..Sat)
%bAbbreviated month name (Jan..Dec)
%cMonth, numeric (0..12)
%DDay of the month with English suffix (0th, 1st, 2nd, 3rd, …)
%dDay of the month, numeric (00..31)
%eDay of the month, numeric (0..31)
%fMicroseconds (000000..999999)
%HHour (00..23)
%hHour (01..12)
%IHour (01..12)
%iMinutes, numeric (00..59)
%jDay of year (001..366)
%kHour (0..23)
%lHour (1..12)
%MMonth name (January..December)
%mMonth, numeric (00..12)
%pAM or PM
%rTime, 12-hour (hh:mm:ss followed by AM or PM)
%SSeconds (00..59)
%sSeconds (00..59)
%TTime, 24-hour (hh:mm:ss)
%UWeek (00..53), where Sunday is the first day of the week
%uWeek (00..53), where Monday is the first day of the week
%VWeek (01..53), where Sunday is the first day of the week; used with %X
%vWeek (01..53), where Monday is the first day of the week; used with %x
%WWeekday name (Sunday..Saturday)
%wDay of the week (0=Sunday..6=Saturday)
%XYear for the week where Sunday is the first day of the week, numeric, four digits; used with %V
%xYear for the week, where Monday is the first day of the week, numeric, four digits; used with %v
%YYear, numeric, four digits
%yYear, numeric (two digits)
%%A literal “%” character
%xx, for any “x” not listed above

Ranges for the month and day specifiers begin with zero due to the fact that MySQL permits the storing of incomplete dates such as '2014-00-00'.

The language used for day and month names and abbreviations is controlled by the value of the lc_time_names system variable (Section 9.7, “MySQL Server Locale Support”).

DATE_FORMAT() returns a string with a character set and collation given by character_set_connection and collation_connection so that it can return month and weekday names containing non-ASCII characters.
mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');
        -> 'Sunday October 2009'
mysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');
        -> '22:23:00'
mysql> SELECT DATE_FORMAT('1900-10-04 22:23:00',
    ->  '%D %y %a %d %m %b %j');
        -> '4th 00 Thu 04 10 Oct 277'
mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00',
    ->  '%H %k %I %r %T %S %w');
        -> '22 22 10 10:23:00 PM 22:23:00 00 6'
mysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');
        -> '1998 52'
mysql> SELECT DATE_FORMAT('2006-06-00', '%d');
        -> '00'

Source: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

PHP date format

string date ( string $format [, int $timestamp = time() ] )

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().

format
The format of the outputted date string. See the formatting options below. There are also several predefined date constants that may be used instead, so for example DATE_RSS contains the format string 'D, d M Y H:i:s'.

The following characters are recognized in the format parameter string
format characterDescriptionExample returned values
Day------
dDay of the month, 2 digits with leading zeros01 to 31
DA textual representation of a day, three lettersMon through Sun
jDay of the month without leading zeros1 to 31
l (lowercase 'L')A full textual representation of the day of the weekSunday through Saturday
NISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)1 (for Monday) through 7 (for Sunday)
SEnglish ordinal suffix for the day of the month, 2 charactersst, nd, rd or th. Works well with j
wNumeric representation of the day of the week0 (for Sunday) through 6 (for Saturday)
zThe day of the year (starting from 0)0 through 365
Week------
WISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)Example: 42 (the 42nd week in the year)
Month------
FA full textual representation of a month, such as January or MarchJanuary through December
mNumeric representation of a month, with leading zeros01 through 12
MA short textual representation of a month, three lettersJan through Dec
nNumeric representation of a month, without leading zeros1 through 12
tNumber of days in the given month28 through 31
Year------
LWhether it's a leap year1 if it is a leap year, 0 otherwise.
oISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)Examples: 1999 or 2003
YA full numeric representation of a year, 4 digitsExamples: 1999 or 2003
yA two digit representation of a yearExamples: 99 or 03
Time------
aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
BSwatch Internet time000 through 999
g12-hour format of an hour without leading zeros1 through 12
G24-hour format of an hour without leading zeros0 through 23
h12-hour format of an hour with leading zeros01 through 12
H24-hour format of an hour with leading zeros00 through 23
iMinutes with leading zeros00 to 59
sSeconds, with leading zeros00 through 59
uMicroseconds (added in PHP 5.2.2)Example: 654321
Timezone------
eTimezone identifier (added in PHP 5.1.0)Examples: UTC, GMT, Atlantic/Azores
I (capital i)Whether or not the date is in daylight saving time1 if Daylight Saving Time, 0 otherwise.
ODifference to Greenwich time (GMT) in hoursExample: +0200
PDifference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)Example: +02:00
TTimezone abbreviationExamples: EST, MDT ...
ZTimezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.-43200 through 50400
Full Date/Time------
cISO 8601 date (added in PHP 5)2004-02-12T15:19:21+00:00
r» RFC 2822 formatted dateExample: Thu, 21 Dec 2000 16:01:07 +0200
USeconds since the Unix Epoch (January 1 1970 00:00:00 GMT)See also time()

Unrecognized characters in the format string will be printed as-is. The Z format will always return 0 when using gmdate().

Tuesday, September 20, 2011

Configuring PHP Development Environment in Windows

Apache HTTP Server



  1. Download the Apache2 HTTP server.

  2. Run the installation file .msi. The installation wizard starts. Follow the instructions.On Microsoft Vista, do not install the Apache Server to the default location, which is in Program Files. All files in Program Files are write-protected.

  3. When the installation is completed, restart the Apache server.

  4. To check that the installation is successful, run the browser and enter the following URL:
      http://localhost/

    The Apache welcome test page opens:
    Apache web server test page indicates that Apache is running


Troubleshooting


By default, the Apache server listens to port 80. This port can be already used by other services, for example Skype. To solve the issue, change the port which the server listens to:

  1. Open the Apache web server configuration file httpd.conf. By default the file is located in C:\Program Files\Apache Software Foundation\Apache<version>\conf\

  2. Locate the line Listen 80 and change the port number, for example 8080. Save the file.

  3. Restart the Apache web server.

  4. To check that the web server works, run the browser and enter the URL and specify the port number explicitly: http://localhost:8080


You can also stop the processes that possibly listen to port 80. In the Task Manager, select the relevant file name and click End Process.

Find more information on installing and configuring the server here.

PHP Engine



  1. Download the PHP5 engine.

  2. When the download is complete, run the .msi installation file. The installation wizard starts.

  3. On the Apache Configuration Directory panel, specify the directory where the httpd.conf file is located, the default setting is C:\Program Files\Apache Software Foundation\Apache<version>\conf\. The PHP processing will be enabled automatically.

  4. If you want to use the MySQL database server, choose the Complete installation option or select the MySQL and MySQLi items in the Extensions list.

  5. After the installation is completed, restart the Apache server.

  6. To check that the PHP engine has been installed successfully and PHP processing has been enabled in the Apache configuration:

    • In the Notepad, create a file and type the following text:
      <?php
      echo "PHP has been installed successfully!";
      ?>


    • Save the file in the htdocs folder: C:\Program Files\Apache Software Foundation\Apache<version>\htdocs\test.php

    • Run the browser and enter the following URL: http://localhost:<port>/test.php. The following page opens:
      PHP test page indicates that the PHP engine is enabled




Troubleshooting


If the page does not open:

  1. Restart the Apache server.

  2. Check that the Apache server configuration file httpd.conf contains the following lines:
      AddType Application/x-httpd-php .php
    LoadModule php5_module "c:/php/sapi/php5apache2_2.dll"


  3. If the lines are missing, add them, save httpd.conf, and restart Apache.

  4. Refresh the http://localhost:<port>/test.php page.


Source: http://netbeans.org/kb/docs/php/configure-php-environment-windows.html#installComponentsSeparately

How to install and Configure the Tomcat Server

Steps involved in installation and configuration process for Tomcat 6.0.10 are illustrated below:

Step 1: Installation of JDK:  Don't forget to install JDK on your system (if  not installed) because any tomcat requires the  Java 1.5 (Java 5) and Java 1.6 (Java 6) and then set the class path (environment variable) of JDK.

Step 2: Setting the class path variable for JDK: Two methods are there to set the classpath.

  1. Set the class path using the following command.set PATH="C:\Program Files\Java\jdk1.5.0_08\bin";%PATH%

  2. The other way of setting the class path variable is:


First right click on the My Computer->properties->advance->Environment Variables->path.
Set bin directory path of JDK in the path variable.


Step 3: Now it's time to shift on to the installation process of  Tomcat 6.0.10. It takes various steps for installing and configuring the Tomcat 6.0.
For Windows, Tomcat comes in two forms :  .zip file and the Windows installer (.exe file). Here we are exploring the installation process by using the .exe file.  The directory C:\apache-tomcat-6.0.10 is the  common installation directory as it is pre-specified C:\ as the top-level directory. First unpack the zipped file and simply execute the .exe file.







 The above shown screen shot is the first one shown in the installation process. Just click on the Next button to proceed the installation process.







 click  "I Agree"  button to continue the installation process.







 Click next to go with  the default components choosen. 







Choose the location for the Tomcat files as per your convenience. You can also choose the default location.







Now choose the port number on which you want to run the tomcat server. Tomcat uses the port number 8080 as its default value. But  Most of the people change the port number to 80 because in this case the user is not required to specify the port number at request time. But we are using here the default port number as 8080.  Choose the user name and password as per your convenience. We can change the port number even the installation process is over.  For that,  go to the specified location as " Tomcat 6.0 \conf \server.xml ". Within the server.xml file choose "Connector" tag and change the port number. 

e.g While using the port number 8080, give the following request in the address bar as:

Default Port: http//localhost:8080/index.jsp

In case of port number number 80 just type the string illustrated below in the address bar:

New Port: http://localhost/index.jsp

Note that we do no need to specify any port number in the URL.

Now click on the Next button to proceed the installation process.







The installation process shows the above screen as the next window. This window asks for the location of the  installed Java Virtual Machine. Browse the location of the JRE folder and click on the Install button. This will install the Apache tomcat at the specified location.







To get the information about installer click on the "Show details" button.







After completion of  installation process it will display the window like the above one.







On clicking at Finish button, a window like the above one will display a message printed on the window given below.







After successfully installing, a shortcut icon to start the tomcat server appears in the icon tray of the task bar as shown above. Double clicking the icon, displays the window of Apache Manager for Tomcat. It will show the "Startup type" as manual since we have changed the destination folder for tomcat during the installation process. Now we can configure the other options like "Display name" and "Description" .We can also start, stop and restart the service from here.







If  installation process completes successfully then a window as shown below will appear.







Now , set the environment variable for tomcat :

Step 4: Setting the JAVA_HOME Variable: Purpose of setting the environment variable JAVA_HOME is to specify the location of the java run time environment needed to support  the Tomcat else Tomcat server does not run.  This variable contains the path of  JDK installation directory. Note that  it should not contain the path up to bin folder.

set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_08

Here, we have taken the URI path according to our installation convention

For Windows XP, Go through the following steps:

Start menu->Control Panel->System->Advanced tab->Environment Variables->New->set the Variable Name as  JAVA_HOME and Variable Value as C:\Program Files\Java\jdk1.6.0 and then click on all the three ok buttons one by one. It will set the JDK path.

Source: http://www.roseindia.net/web-application-server/tomcat/install-configure.shtml

sun JDK installation on ubuntu

three steps to install sun jdk on ubuntu


sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk

Friday, September 16, 2011

How to add a new user to Webmin from shell via (bash,sh)

You might search for a way to add a new user to your Webmin without bothering using the Webmin user interface or you simply prefer using shell for adding the new user to Webmin just like I do.

1.In order to manually add a new user to webmin you will have to edit webmin’s /etc/webmin/miniserv.users which is the default miniserv.uesrs location in many Linux distributions, however in FreeBSD or other BSDs the miniserv.users file location would probably be /usr/share/etc/webmin/ or /usr/share/webmin/etc , anyways if you are adding the new user manually open the file and copy paste the line:
root:12ZWQKVLjpihs:0
to a new line, where you will have to modify the line substituting root with newusername , like so:

newusername:12ZWQKVLjpihs:0

Afterwards you will have to also edit the file /etc/webmin/webmin.acl and likewise copy paste the definitions allowing access to all recources to the root user which in webmin.acl by default are:

root: acl adsl-client apache at backup-config bacula-backup bandwidth bind8 burner cfengine change-user cluster-copy cluster-cron cluster-passwd cluster-shell cluster-software cluster-useradmin cluster-usermin cluster-webmin cpan cron custom dfsadmin dhcpd dnsadmin dovecot exim exports fdisk fetchmail file filter firewall frox fsdump grub heartbeat htaccess-htpasswd idmapd inetd init inittab ipfilter ipfw ipsec jabber krb5 ldap-client ldap-server ldap-useradmin lilo logrotate lpadmin lvm mailboxes mailcap majordomo man mon mount mysql net nis openslp package-updates pam pap passwd phpini postfix postgresql ppp-client pptp-client pptp-server procmail proc proftpd pserver qmailadmin quota raid samba sarg sendmail sentry servers shell shorewall smart-status smf software spam squid sshd status stunnel syslog syslog-ng system-status tcpwrappers telnet time tunnel updown useradmin usermin vgetty webalizer webminlog webmin wuftpd xinetd


In my case I wanted to add to the newly created newuser only acl privileges for user crontab modification and htaccess-passwd creation thus I have included in the webmin.acl file only:

newuser: cron webmin htaccess-passwd


You will also be required to change the new user webmin password to some password of your choice, to attain that in Debian Linux execute:

debian:~# /usr/share/webmin/changepass.pl /etc/webmin newusername type_your_password


On Fedora and other RPM (Redhat based linux distros) the webmin changepass.pl user password change script is located in /usr/libexec/webmin/changepass.pl therefore if you’re about to change the password for the new user on Fedora and alike, type:

fedora:~# /usr/libexec/webmin/changepass.pl /etc/webmin/ newusername your_password


In the above change password exapmles you need to substitute newusername with the user chosen to be the new username as explained earlier in the post.
Finally in order for the newly added user with the respectively configured permissions to start working in Webmin, you will have to reload the webmdaemon. In most linux distributions (including Debian), to restart webmin you will have to issue:

linux-shell:~# /etc/init.d/webmin restart


However if you’re looking for a bit more automated way instead of manually editting the miniserv.users and webmin.acl files.
2. Herein is a tiny shell script I’ve written which facilitates the new webmin user creation under a console / terminal / shell

I have written webmin-new-user.sh just for fun, and it could be greatly improved, so don’t expect too much from it it doesn’t do any checks on the input given to the script, so be sure to pass a correct input as required from the dialogs in order to be able to use the script to add new users to your webmin from bash or any other unix shell.
The script is written to work with Debian on Fedora and other rpm based distributions as well as BSD a minor tunings within the script might be necessary to make the script work.

Sources:www.pc-freak.net

Installing Webmin in Ubuntu

Webmin is a web-based interface for system administration for Unix. Using any browser that supports tables and forms (and Java for the File Manager module), you can setup user accounts, Apache, DNS, file sharing and so on.

Webmin consists of a simple web server, and a number of CGI programs which directly update system files like /etc/inetd.conf and /etc/passwd. The web server and all CGI programs are written in Perl version 5, and use no non-standard Perl modules.

Installing Webmin in Ubuntu

You can use the above procedure but if you want to install latest version you can download from webmin site download section

Prerequisites

Perl 5 interpreter and libnet-ssleay-perl

sudo apt-get install perl5 libnet-ssleay-perl

Now you need to download the latest webmin from the above downloadlink

Download ‘webmin-1.560.tar.gz’ (at the time of writing) to some location in your machine ex:- /usr/local/src

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.560.tar.gz

cd /usr/local/src

sudo tar xzvf webmin-1.560.tar.gz

cd webmin-1.560

sudo sh setup.sh

This will start the installation and now it will prompt for several questions answer them as follows

Config file directory [/etc/webmin]:
Leave as default, or change as you wish

Log file directory [/var/webmin]:
Leave as default, or change as you wish

Full path to perl (default /usr/bin/perl):
Leave as default, or change as you wish

Operating system:
Enter ’6′

Version:
Enter ’6′

Web server port (default 10000):

This is where you can start to make webmin more secure then the standard install you get with apt-get, Synaptic, or RPM. Leave as default or change it to what ever port you want.

Login name (default admin):

It is ‘admin’, so you can leave it as that, or put in any name that you like.

Login password:

By creating the user above and giving it a password, you have now made it so you will not need to log into webmin with root.

Password again:

enter your password again

If you did not install ‘libnet-ssleay-perl’ you will get the following message:

‘The Perl SSLeay library is not installed. SSL not available.’ You can continue with the install, but it would be more secure if you install sslrelay.

Use SSL (y/n):y

Choose yes here

Start Webmin at boot time (y/n):y

select here y

At this point it is going to configure things, install things, and create things…

It will then tell you that you can log in to https://hostipaddress:10000 and to accept the certificate.

Webmin User Password Change

If you want to change root password in webmin use this included Perl script:

sudo /usr/share/webmin/changepass.pl /etc/webmin root

MySql-Apache-PHP Installation on Ubuntu server

The way to install a php server with apache & mysql support on ubuntu machine is as follow:

MySql
apt-get install mysql-server mysql-client
New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword

Apache
apt-get install apache2

Php
apt-get install php5 libapache2-mod-php5
/etc/init.d/apache2 restart

check for php-MySql Packages
apt-cache search php5

apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

/etc/init.d/apache2 restart

apt-get install phpmyadmin
Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- No

Note:use sudo where ever required!!!

Reset Mysql Password

Follow these steps for this


mysqld -u root --skip-grant-tables


mysql> use mysql;
mysql> delete from user where user='root';
mysql> insert into user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv,Index_priv, Alter_priv, Super_priv, Create_user_priv) VALUES ('localhost', 'root', PASSWORD('root'),'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
mysql> flush privileges;
mysql> quit;

Thursday, September 15, 2011

How to reset your Firefox default search engine or modify it:


  • Open Firefox browser

  • Type about:config in location bar and press enter

  • Search for configuration key keyword.URL and select it

  • Right click on the configuration key keyword.URL and choose Reset from the shortcut menu.
    If clicking on “reset” nothing happens just write this string:
    http://www.google.com/webhp?hl=en#hl=en&cp=4&gs_id=i&xhr=t&q=

    Otherwise if you like Google’s I’m Feeling Lucky feature you have to write this line:

    http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=

Wednesday, September 14, 2011

Handelling UTF-8 in Webpage

Just add this text in meta of your page, you will be able to get utf-8 charactors

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>