Sabtu, 31 Oktober 2009
Quick method to change/create ysql root password
Here is a quick tip that will show several methods to change the mysql root password (that is normally empty at mysql initial install).
Method 1: using the SET PASSWORD command:
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Method 2: using mysqladmin
mysqladmin -u root password "newpass"
if there was already a mysql root password set, change this to:
mysqladmin -u root password oldpass "newpass"
Method 3: using UPDATE to directly edit the users table
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
Installing php eAccelerator
Unfortunately, there's no eAccelerator package for Debian Etch in the official repositories, therefore we must compile and install it from the sources. Before we can do this, we need to install some prerequisites:
apt-get install build-essential php5-dev bzip2
Now we can download and install eAccelerator like this (make sure that you get the latest version from the eAccelerator web site):
cd /tmp
wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2
tar xvfj eaccelerator-0.9.5.2.tar.bz2
cd eaccelerator-0.9.5.2
phpize
./configure
make
make install
eAccelerator is now installed. Now we have to tell our PHP installation that it should make use of eAccelerator. On Debian Etch, the configuration files for the various PHP 5 modules are stored in the /etc/php5/conf.d directory, and this directory is referenced in the main PHP5 configuration file /etc/php5/apache2/php.ini, meaning all files in /etc/php5/conf.d are read in whenever Apache is started/restarted. So all we do is create the file /etc/php5/conf.d/eaccelerator.ini:
vi /etc/php5/conf.d/eaccelerator.iniextension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
(You can read up on the various configuration settings on this page: http://www.eaccelerator.net/wiki/Settings.)
As you see, we are using the disk cache directory /var/cache/eaccelerator which we must create now and make it world-writable:
mkdir -p /var/cache/eaccelerator
chmod 0777 /var/cache/eaccelerator
Afterwards, we restart Apache so that our new PHP configuration takes effect:
/etc/init.d/apache2 restart
Afterwards, open info.php again in a browser: http://webserver/info.php
You should now see eAccelerator mentioned on the page which means it has successfully been integrated and is working as expected (I've marked the eAccelerator line in the below screenshot for better visibility):
Rabu, 28 Oktober 2009
Howto untar/tar/bunzip
tar -xvf filename.tar foldername/
-compress a folder ===> tar -pczf web.tar.gz /var/www/html
4-april-2010 on sahabat pc router.
tar -pczf hotpotcontrol2`date +%d_%m_%Y_hour_%H_%M`.tar.gz hotspot-control2/ mysql/ radius/
tar split large file
1. compress the folder/files to .tar.gz
2. tar -cvj /home/zahari/joomla15.tar.gz | split -b 6m -d – “joomla15split.tar.bz.”
eg> tar -cvj /home/zahari/hotspotnet/joomla15.tar.gz | split -b 6m -d - "joomla15split.tar.gz."
to recover as follows:
cat large-files.tar.bz.* > large-files.tar.bz
tar -xvj large-file.tar.bz
tar create file with date and time
tar -pcfz /home/zahari/mysql-backup-tar/mysql_`date +%d_%m_%Y_hour_%H_%M`.tar.gz /home/zahari/mysql-backup/*
rsync from cherasnet to bintangmas host
rsync -v -e ssh zahari@cherasnet.com:~/mysql-backup-tar/* /home/zahari/mysql-backup
Identify the server that initially contains the files (we will call this the SOURCE server), and the serverto which you want to transfer the files (we will call this the TARGET server). Confirm that you can log in to the SOURCE server, that you can log in to the TARGET server, and that while logged into the TARGET server, you can use ssh to login to the SOURCE server using your password.
Step
2
Log into the TARGET server. Execute the command
[mikeular@targethost~]$ ssh-keygen -t dsa
ssh-keygen will ask you where you want to save the key. Accept the default directory, which will be ~/.ssh/id_dsa . Next it will ask you for a passphrase, leave this entry blank.
Your private key file will be saved to ~/.ssh/id_dsa and your public key will be saved to ~/.ssh/id_dsa.pub. Careful! Anyone who obtains a copy of your id_dsa file will be able to login to the SOURCE server as you, without authenticating themselves. Make sure that it's stored securely!
Step
3
Now you will configure the SOURCE server to accept the key. Once this step is complete, anyone with the id_dsa file will be able to log into the SOURCE server without providing a password.
Log into the SOURCE server and create the ssh directory:
[mikeular@sourcehost~]$ mkdir ~/.ssh
[mikeular@sourcehost~]$ cd ~/.ssh
Using vi or another text editor, create a file in ~/.ssh named authorized_keys2 . Now switch over to the TARGET server and copy the contents of the file id_dsa.pub and paste them into authorized_keys2 on the SOURCE server. Save the text file.
Step
4
Make sure that the authorized_keys2 cannot be changed by other users on the SOURCE server:
[mikeular@sourcehost~]$ chmod 644 ~/.ssh/authorized_keys2
Step
5
Now you can test your setup. Go back to the TARGET server and connect to the source.
[mikeular@targethost~]$ ssh username@sourcehost.com
[mikeular@sourcehost~]
Your ssh connection is now working correctly.
Step
6
Test your rsync over ssh connection by copying a file from SOURCE to TARGET. Enter the following command all on one line, being sure to substitute in the correct pathnames, username, and hostname.
[mikeular@targethost~]$ rsync -avz -e/usr/bin/ssh username@sourcehost.com:/home/username/testfile /home/mikeular/
This should copy the file "testfile" from your home directory on sourcehost to your home directory on targethost.
Step
7
move backup from cheasnet.com to kudaspot.homeip.net
rsync -v -e ssh zahari@cherasnet.com:~/mysql-backup-tar/* /home/zahari/mysql-backup
============================================
matahari backup job
1) backup whole harddisk with tar
sudo tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
sudo tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/home/zahari/backup-sda1 --exclude=/mnt --exclude=/sys / &
sudo tar -pcvj /home/zahari/backup-sda1/mybackup.tar.gz | split -b 20M -d - "mybackup-split.tar.gz"
-------------------
split file
tar -pcvj backup.tgz | split -b 30M -d - "backup.tgz."
===========================================================
CHERASNET(mandrake10.2 Productuion server) backup to 20GB external harddisk connected to usb adaptor
the job is to backup partition hda1-->sda1(external usb harddisk) and hda6 to sda6(external usb Harddisk)
[root@myap-1 httpd]# df
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 7.4G 4.2G 3.0G 59% /
/dev/hda6 11G 3.4G 7.2G 32% /home
/dev/sda1 6.8G 4.2G 2.4G 65% /mnt/sda1
/dev/sda6 12G 3.4G 8.0G 30% /mnt/sda6
[root@myap-1 httpd]#
type fdisk -l
Disk /dev/sda: 20.8 GB, 20847697920 bytes
64 heads, 32 sectors/track, 19881 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 7058 7227376 83 Linux
/dev/sda2 7059 19881 13130752 5 Extended
/dev/sda5 7059 7536 489456 82 Linux swap
/dev/sda6 7537 19881 12641264 83 Linux
[root@myap-1 httpd]#
use fdisk to partition the new sda to match the partition of running disk /dev/hda
------------------------------------
mount /dev/sda1 /mnt/sda1
mount /dev/sda6 /mnt/sda6
-------------------------------------
prepare file excludes.cfg
touch /mnt/excludes.cfg, nano /mnt/excludes.cfg and put in the followings
/proc/
/tmp/
/mnt/
/etc/fstab
#/var/cache
/lost+found
/var/cache/httpd/
/usr/local/squid2.7/var/cache/
save and exit nano
start copying now
rsync -avx --exclude-from=/mnt/excludes.cfg --delete // /mnt/sda1 &
rsync -avx --exclude="lost&found" /home/ /mnt/sda6 &
========================================================
using mc to ftp files from sahabat to jebat
F9--->RIGHT--->shell link
jebat@pcrouterjebathotspot.homelinux.com
Buat tiket prabayar wifi
Depending on your operating system, you'll find packages or tarballs to install Net-SNMP :
Linux
Usually every Linux distribution comes with Net-SNMP packages :
RedHat / Fedora / CentOS : install the net-snmp, net-snmp-libs and net-snmp-utils packages
Debian / Ubuntu: install the libsnmp-base, libsnmp5, snmp and snmpd packages
SuSE : install the net-snmp package
Gentoo : simply emerge the net-snmp ebuild.
How to LAMP server on Debian Etch
Apache 2 - Linux Web server
MySQL 5 - MySQL Database Server
PHP5 - PHP Scripting Language
phpMyAdmin - Web-based database admin software.
Requirements
A Debian Etch base installation - Installation HOWTO here.
At least 256MB of RAM installed on your machine.
An understanding of the "apt-get" command.
Pre-Installation
Before proceeding to install, update the necessary packages with Debian with this command.
apt-get update
apt-get upgrade
Installing Apache 2 + PHP5
To install Apache 2 and PHP5, just run the following in a Linux shell.
apt-get install apache2 php5 libapache2-mod-php5
Your Apache 2 configuration file is located at: /etc/apache2/apache2.conf and your web folder is /var/www
Let's check that PHP5 was installed correctly. Run the following command to open up the vim editor and create a new php page called test.php:
vim /var/www/apache2-default/test.php
With this page opened insert the following code into vim:
You can now save the file.
Point your browser to http://example.com/apache2-default/test.php and this should show all your PHP5 configuration and default settings.
Installing MySQL 5 Database Server
Installing the MySQL database server is necessary if you intend on running a database driven web site. The following commands will install MySQL 5 server and MySQL 5 client.
apt-get install mysql-server mysql-client php5-mysql
The configuration file of MySQL is located at: /etc/mysql/my.cnf
Creating users to use MySQL and Changing Root Password
By default MySQL creates a user as root and runs with no password which is a high security risk. You will need to change the root password immediately.
To change Root Password:
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
You must never use your root account and password when running databases. The root account is a privileged account which should only be used for admin procedures. You will need to create a separate user account to connect to your MySQL databases from a PHP script. You can add users to a MySQL database by using a control panel like phpMyAdmin to easily create or assign database permissions for users.
phpMyAdmin Installation
phpMyAdmin is a nice web based database management and administration software and easy to install and configure under apache. Managing databases with tables couldnt be much simpler by using phpmyadmin.
All you need to do is:
apt-get install phpmyadmin
The phpMyAdmin configuration file is located at: /etc/phpmyadmin
To have access to phpMyAdmin on your website (i.e. http://example.com/phpmyadmin/ ) all you need to do is include the following line in /etc/apache2/apache2.conf:
Include /etc/phpmyadmin/apache.conf
Now restart Apache:
/etc/init.d/apache2 restart
Point your browser to: http://example.com/phpmyadmin/ and you're ready to go.
That's it! MySQL and phpMyAdmin are ready. Log in with your MySQL root account and password and create users to connect to the databases from your PHP script.
The really quick way of doing this
The above is broken into step by step examples to give you a detailed understanding of what each step does. However, you can install the LAMP server running only two commands. First run:
apt-get update
And then run:
apt-get install apache2 php5 libapache2-mod-php5 mysql-server mysql-client php5-mysql phpmyadmin
That's it. With these two commands you will install everything as described in the wiki HOWTO.
Bandwidth Balancing with wondershaper
apt-get install wondershaper
my streamyx spec is 512kbps download/256kbps upload
debian:/home/zahari# wondershaper eth0 500 200
-->checking on screen status debian:/home/zahari# wondershaper eth0
to clear the control type -->wondershaper eth0 clear
Selasa, 27 Oktober 2009
Setup php5-suhosin on Debian Etch
PHP-suhosin installation
Debian etch installation
The installation of suhosin on debian etch is really pretty simple. It took me all of 5 minutes or so to have a basic working installation.
First we start by finding the suhosin package for our php version
apt-cache search suhosin
php4-suhosin - advanced protection module for php4
php5-suhosin - advanced protection module for php5
Now install suhosin
apt-get install php5-suhosin
The suhosin.ini should be located in /etc/php5/conf.d .
Configuration
The basic configuration that ships with suhosin will work out-of-the-box but I have added a few tweaks.
In the php.ini we add the following:
Enable suhosin
extension=suhosin.so
Disable session encryption (required for most login scripts)
suhosin.session.encrypt = Off
Log all errors
suhosin.log.syslog=511
Max traversal depth ie '../../'
suhosin.executor.include.max_traversal=4
Disable eval
suhosin.executor.disable_eval=On
Disable /e modifier
suhosin.executor.disable_emodifier=On
Disallow newlines in Subject:, To: headers and double newlines in additional headers
suhosin.mail.protect=2
Recommend Settings
Silently fail all failed sql queries
suhosin.sql.bailout_on_error=On
Isnin, 26 Oktober 2009
Linux Basic Command / guide
1. Need to quickly tar and gzip an entire folder? Try the command below!
tar -cvzpf filename.tar.gz /path/to/folder
tar -cvzpf joomla15-cherasnet.tar.gz joomla15/
tar -cvzpf --exclude-caches joomla15-cherasnet.tar.gz joomla15/
tar -cvzpP --file=/distr/backup.tar.gz --exclude={/dev/*,/proc/*,/sys/*,/srv/*,/distr/*,/tmp/*} /
tar work with directory "/" except for
/dev
/proc
/sys
/srv/
/distr
/tmp
contoh buat tar exclude tmp,cache folder
tar -cvzpP --file=backupjoomla15-14.tar.gz --exclude={/home/zahari/joomla15/tmp/*,/home/zahari/joomla15/cache/*} /home/zahari/joomla15
========================================================
2. If are seeing a lots of “TCP: drop open request from A.B.C.D” messages and you don’t expect a real load the server, you’ll need to enable syncookies. Edit your /etc/sysctl.conf and append the following lines:
# enable syncookies
net.ipv4.tcp_syncookies = 1
from terminal, type sysctl-p to reload the kernel configuration.
Buat Sendiri (DIY) Router HotSpot Menggunakan Debian Etch
The installation instruction for installing Apache, PHP, MySQL and phpMyAdmin in Debian Etch and Ubuntu is the same as above. The difference is in Debian Sarge, its using PHP4 and MySQL4 while in Debian Etch and Ubuntu is using PHP5 and MySQL5.
apt-get install apache2 libapache2-mod-php5 php5 php5-cli php5-mysql php5-gd php5-mcrypt mysql-client mysql-server libmysqlclient15-dev phpmyadmin
Pastikan run command seperti dibawah untuk apache faham php
> a2enmod php5
>/etc/init.d/apache2 force-reload
==== Byk lagi -==tunggu
Memulakan Perniagaan Cara WI-FI tiket Prabayar dengan modal hanya RM450.00
MudahSPOT hanya RM450.00. Keperluan 1) Talian Internet Streamyx/3G/WIMAX. Cuma 3G/WIMAX kurang stabil untuk perniagaan 2) Router Kerb...
-
MySQL Tips: Howto change the MySQL root password Here is a quick tip that will show several methods to change the mysql root password (that ...
-
detailed instructions on setting LAMP up and once completed you will have a LAMP server that runs: Apache 2 - Linux Web server MySQL 5 - My...
-
1. Need to quickly tar and gzip an entire folder? Try the command below! tar -cvzpf filename.tar.gz /path/to/folder tar -cvzpf joomla15-che...