Saturday, August 29, 2009

Vim undo redo

SkyHi @ Saturday, August 29, 2009

Undo and redo *undo-redo*

The basics are explained in section |02.5| of the user manual.

1. Undo and redo commands |undo-commands|
2. Two ways of undo |undo-two-ways|
3. Remarks about undo |undo-remarks|


1. Undo and redo commands *undo-commands*

or *undo* ** *u*
u Undo [count] changes. {Vi: only one level}

*:u* *:un* *:undo*
:u[ndo] Undo one change. {Vi: only one level}

CTRL-R Redo [count] changes which were undone. {Vi: redraw

*:red* *:redo* *redo*
:red[o] Redo one change which was undone. {Vi: no redo}

U Undo all latest changes on one line. {Vi: while not
moved off of it}

The last changes are remembered. You can use the undo and redo commands above
to revert the text to how it was before each change. You can also apply the
changes again, getting back the text before the undo.

The "U" command is treated by undo/redo just like any other command. Thus a
"u" command undoes a "U" command and a 'CTRL-R' command redoes it again. When
mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will
restore the situation of a line to before the previous "U" command. This may
be confusing. Try it out to get used to it.
The "U" command will always mark the buffer as changed. When "U" changes the
buffer back to how it was without changes, it is still considered changed.
Use "u" to undo changes until the buffer becomes unchanged.


2. Two ways of undo *undo-two-ways*

How undo and redo commands work depends on the 'u' flag in 'cpoptions'.
There is the Vim way ('u' excluded) and the vi-compatible way ('u' included).
In the Vim way, "uu" undoes two changes. In the Vi-compatible way, "uu" does
nothing (undoes an undo).

'u' excluded, the Vim way:
You can go back in time with the undo command. You can then go forward again
with the redo command. If you make a new change after the undo command,
the redo will not be possible anymore.

'u' included, the Vi-compatible way:
The undo command undoes the previous change, and also the previous undo command.
The redo command repeats the previous undo command. It does NOT repeat a
change command, use "." for that.

Examples Vim way Vi-compatible way
"uu" two times undo no-op
"u CTRL-R" no-op two times undo

Rationale: Nvi uses the "." command instead of CTRL-R. Unfortunately, this
is not Vi compatible. For example "dwdwu." in Vi deletes two
words, in Nvi it does nothing.



Linux install and uninstall from source

SkyHi @ Saturday, August 29, 2009
< Installing software from source in Linux - 1.2 >

So you've downloaded a software package with tar.gz or tar.bz2 extension and have no idea what to do with it. Or perhaps you already know that it's most likely the source code of the program you want to install and you have to compile it, but don't know how. Don't worry, compiling and installing software from source in Linux isn't as hard as it may sound!

Author: Nana Långstedt < nana.langstedt at >
tuXfile created: 13 July 2002
Last modified: 22 September 2005


* The procedure
* Step 1. Unpacking
* Step 2. Configuring
* Step 3. Building
* Step 4. Installing
* Cleaning up the mess
* Uninstalling

back to

* Linux software
* Linux help
* tuXfiles home

< The procedure >

The installation procedure for software that comes in tar.gz and tar.bz2 packages isn't always the same, but usually it's like this:

# tar xvzf package.tar.gz (or tar xvjf package.tar.bz2)
# cd package
# ./configure
# make
# make install

If you're lucky, by issuing these simple commands you unpack, configure, compile, and install the software package and you don't even have to know what you're doing. However, it's healthy to take a closer look at the installation procedure and see what these steps mean.

< Step 1. Unpacking >

Maybe you've already noticed that the package containing the source code of the program has a tar.gz or a tar.bz2 extension. This means that the package is a compressed tar archive, also known as a tarball. When making the package, the source code and the other needed files were piled together in a single tar archive, hence the tar extension. After piling them all together in the tar archive, the archive was compressed with gzip, hence the gz extension.

Some people want to compress the tar archive with bzip2 instead of gzip. In these cases the package has a tar.bz2 extension. You install these packages exactly the same way as tar.gz packages, but you use a bit different command when unpacking.

It doesn't matter where you put the tarballs you download from the internet but I suggest creating a special directory for downloaded tarballs. In this tutorial I assume you keep tarballs in a directory called dls that you've created under your home directory. However, the dls directory is just an example. You can put your downloaded tar.gz or tar.bz2 software packages into any directory you want. In this example I assume your username is me and you've downloaded a package called pkg.tar.gz into the dls directory you've created (/home/me/dls).

Ok, finally on to unpacking the tarball. After downloading the package, you unpack it with this command:

me@puter: ~/dls$ tar xvzf pkg.tar.gz

As you can see, you use the tar command with the appropriate options (xvzf) for unpacking the tarball. If you have a package with tar.bz2 extension instead, you must tell tar that this isn't a gzipped tar archive. You do so by using the j option instead of z, like this:

me@puter: ~/dls$ tar xvjf pkg.tar.bz2

What happens after unpacking, depends on the package, but in most cases a directory with the package's name is created. The newly created directory goes under the directory where you are right now. To be sure, you can give the ls command:

me@puter: ~/dls$ ls
pkg pkg.tar.gz
me@puter: ~/dls$

In our example unpacking our package pkg.tar.gz did what expected and created a directory with the package's name. Now you must cd into that newly created directory:

me@puter: ~/dls$ cd pkg
me@puter: ~/dls/pkg$

Read any documentation you find in this directory, like README or INSTALL files, before continuing!

< Step 2. Configuring >

Now, after we've changed into the package's directory (and done a little RTFM'ing), it's time to configure the package. Usually, but not always (that's why you need to check out the README and INSTALL files) it's done by running the configure script.

You run the script with this command:

me@puter: ~/dls/pkg$ ./configure

When you run the configure script, you don't actually compile anything yet. configure just checks your system and assigns values for system-dependent variables. These values are used for generating a Makefile. The Makefile in turn is used for generating the actual binary.

When you run the configure script, you'll see a bunch of weird messages scrolling on your screen. This is normal and you shouldn't worry about it. If configure finds an error, it complains about it and exits. However, if everything works like it should, configure doesn't complain about anything, exits, and shuts up.

If configure exited without errors, it's time to move on to the next step.

< Step 3. Building >

It's finally time to actually build the binary, the executable program, from the source code. This is done by running the make command:

me@puter: ~/dls/pkg$ make

Note that make needs the Makefile for building the program. Otherwise it doesn't know what to do. This is why it's so important to run the configure script successfully, or generate the Makefile some other way.

When you run make, you'll see again a bunch of strange messages filling your screen. This is also perfectly normal and nothing you should worry about. This step may take some time, depending on how big the program is and how fast your computer is. If you're doing this on an old dementic rig with a snail processor, go grab yourself some coffee. At this point I usually lose my patience completely.

If all goes as it should, your executable is finished and ready to run after make has done its job. Now, the final step is to install the program.

< Step 4. Installing >

Now it's finally time to install the program. When doing this you must be root. If you've done things as a normal user, you can become root with the su command. It'll ask you the root password and then you're ready for the final step!

me@puter: ~/dls/pkg$ su
root@puter: /home/me/dls/pkg#

Now when you're root, you can install the program with the make install command:

root@puter: /home/me/dls/pkg# make install

Again, you'll get some weird messages scrolling on the screen. After it's stopped, congrats: you've installed the software and you're ready to run it!

Because in this example we didn't change the behavior of the configure script, the program was installed in the default place. In many cases it's /usr/local/bin. If /usr/local/bin (or whatever place your program was installed in) is already in your PATH, you can just run the program by typing its name.

And one more thing: if you became root with su, you'd better get back your normal user privileges before you do something stupid. Type exit to become a normal user again:

root@puter: /home/me/dls/pkg# exit
me@puter: ~/dls/pkg$

< Cleaning up the mess >

I bet you want to save some disk space. If this is the case, you'll want to get rid of some files you don't need. When you ran make it created all sorts of files that were needed during the build process but are useless now and are just taking up disk space. This is why you'll want to make clean:

me@puter: ~/dls/pkg$ make clean

However, make sure you keep your Makefile. It's needed if you later decide to uninstall the program and want to do it as painlessly as possible!

< Uninstalling >

So, you decided you didn't like the program after all? Uninstalling the programs you've compiled yourself isn't as easy as uninstalling programs you've installed with a package manager, like rpm.

If you want to uninstall the software you've compiled yourself, do the obvious: do some old-fashioned RTFM'ig. Read the documentation that came with your software package and see if it says anything about uninstalling. If it doesn't, you can start pulling your hair out.

If you didn't delete your Makefile, you may be able to remove the program by doing a make uninstall:

root@puter: /home/me/dls/pkg# make uninstall

If you see weird text scrolling on your screen (but at this point you've probably got used to weird text filling the screen? :-) that's a good sign. If make starts complaining at you, that's a bad sign. Then you'll have to remove the program files manually.

If you know where the program was installed, you'll have to manually delete the installed files or the directory where your program is. If you have no idea where all the files are, you'll have to read the Makefile and see where all the files got installed, and then delete them.


Friday, August 28, 2009

wget select files from a website

SkyHi @ Friday, August 28, 2009
Step 1:
[root@home php5.2.10]# cat phpfiles.rtf
08-Mar-2008 19:53 23K
[ ] php-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 1.2M
[ ] php-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 1.3M
[ ] php-PHPMailer-5.0.2-3.el5.remi.noarch.rpm 08-Aug-2009 10:28 74K
[ ] php-bcmath-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 34K
[ ] php-bcmath-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 34K
[ ] php-channel-ezc-1-1.el5.remi.noarch.rpm 19-Jul-2009 10:37 3.3K
[ ] php-channel-phing-1.0.0-6.el5.remi.noarch.rpm 19-Jul-2009 11:14 3.9K
[ ] php-channel-phpdb-1.0.0-5.el5.remi.noarch.rpm 19-Jul-2009 11:14 3.8K
[ ] php-channel-phpunit-1.0-3.el5.remi.noarch.rpm 19-Jul-2009 11:14 3.4K
[ ] php-channel-symfony-1.0.0-3.el5.remi.noarch.rpm 19-Jul-2009 11:14 3.5K
[ ] php-cli-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 2.4M
[ ] php-cli-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 2.5M
[ ] php-common-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 267K
[ ] php-common-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 591K
[ ] php-dba-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 41K
[ ] php-dba-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 41K
[ ] php-devel-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 582K
[ ] php-devel-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 620K
[ ] php-eaccelerator- 14-Apr-2008 12:14 137K
[ ] php-eaccelerator-0.9.6-0.2.rc1.el5.remi.i386.rpm 13-Aug-2009 20:07 100K
[ ] php-embedded-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 1.2M
[ ] php-embedded-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 1.3M
[ ] php-enchant-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 28K
[ ] php-ezc-Archive-1.3.3-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 607K
[ ] php-ezc-Authentication-1.3-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 620K
[ ] php-ezc-AuthenticationDatabaseTiein-1.1-1.el5.remi.noarch.rpm 24-Aug-2009 20:25 44K
[ ] php-ezc-Base-1.7-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 233K
[ ] php-ezc-Cache-1.4.1-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 768K
[ ] php-ezc-Configuration-1.3.3-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 447K
[ ] php-ezc-ConsoleTools-1.5.2-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 903K
[ ] php-ezc-Database-1.4.5-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 619K
[ ] php-ezc-Database-1.4.6-1.el5.remi.noarch.rpm 29-Jul-2009 08:36 619K
[ ] php-ezc-EventLog-1.4-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 254K
[ ] php-ezc-Feed-1.2.1-1.el5.remi.noarch.rpm 24-Aug-2009 20:25 588K
[ ] php-ezc-File-1.2-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 36K
[ ] php-ezc-Mail-1.6.3-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 1.1M
[ ] php-ezc-PersistentObject-1.6-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 1.1M
[ ] php-ezc-SystemInformation-1.0.7-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 141K
[ ] php-ezc-Template-1.4-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 8.0M
[ ] php-ezc-Webdav-1.1.1-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 2.7M
[ ] php-gd-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 124K
[ ] php-gd-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 114K
[ ] php-imap-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 54K
[ ] php-imap-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 52K
[ ] php-interbase-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 64K
[ ] php-interbase-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 67K
[ ] php-intl-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 72K
[ ] php-ldap-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 36K
[ ] php-ldap-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 38K
[ ] php-mbstring-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 1.1M
[ ] php-mbstring-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 1.1M
[ ] php-mcrypt-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 30K
[ ] php-mcrypt-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 32K
[ ] php-mhash-5.2.9-1.el5.remi.i386.rpm 27-Feb-2009 22:25 22K
[ ] php-mhash-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 23K
[ ] php-mssql-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 43K
[ ] php-mssql-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 44K
[ ] php-mysql-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 84K
[ ] php-mysql-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 85K
[ ] php-ncurses-5.2.9-1.el5.remi.i386.rpm 27-Feb-2009 22:25 40K
[ ] php-ncurses-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 41K
[ ] php-oci8-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 75K
[ ] php-oci8-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 89K
[ ] php-odbc-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 53K
[ ] php-odbc-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 53K
[ ] php-pdo-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 91K
[ ] php-pdo-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 93K
[ ] php-pear-1.8.0-2.el5.remi.1.noarch.rpm 11-Apr-2009 11:45 421K
[ ] php-pear-1.8.1-1.el5.remi.noarch.rpm 18-Apr-2009 16:58 419K
[ ] php-pear-Auth-1.6.1-9.el5.remi.noarch.rpm 19-Jul-2009 13:41 62K
[ ] php-pear-Auth-RADIUS-1.0.6-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 12K
[ ] php-pear-Auth-SASL-1.0.3-1.el5.remi.noarch.rpm 08-Aug-2009 10:28 11K
[ ] php-pear-Auth-radius-1.6.1-9.el5.remi.noarch.rpm 19-Jul-2009 13:41 5.3K
[ ] php-pear-Auth-samba-1.6.1-9.el5.remi.noarch.rpm 19-Jul-2009 13:41 4.9K
[ ] php-pear-Auth_HTTP-2.1.6-3.el5.remi.noarch.rpm 18-Aug-2009 17:53 12K
[ ] php-pear-Cache-1.5.5-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 37K
[ ] php-pear-Cache-Lite-1.7.4-1.el5.remi.noarch.rpm 12-Jul-2008 08:16 40K
[ ] php-pear-Cache-Lite-1.7.8-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 40K
[ ] php-pear-Config-1.10.11-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 35K
[ ] php-pear-Console-Color-1.0.2-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 8.8K
[ ] php-pear-Console-Table-1.1.3-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 15K
[ ] php-pear-Crypt-Blowfish-1.1.0-0.3.rc2.el5.remi.noarch.rpm 19-Jul-2009 13:41 22K
[ ] php-pear-Crypt-CHAP-1.0.1-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 9.5K
[ ] php-pear-Event-Dispatcher-1.1.0-1.el5.remi.noarch.rpm 29-Jul-2009 08:36 14K
[ ] php-pear-File-1.3.0-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 37K
[ ] php-pear-File-Bittorrent2-1.3.1-4.el5.remi.noarch.rpm 08-Aug-2009 10:28 77K
[ ] php-pear-HTML-QuickForm-advmultiselect-1.5.1-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 39K
[ ] php-pear-HTML-Table-1.8.2-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 23K
[ ] php-pear-HTML_Javascript-1.1.1-4.el5.remi.noarch.rpm 18-Aug-2009 17:53 13K
[ ] php-pear-HTTP-1.4.1-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 15K
[ ] php-pear-HTTP-Client-1.2.1-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 14K
[ ] php-pear-Log-1.11.4-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 56K
[ ] php-pear-Log-1.11.5-1.el5.remi.noarch.rpm 08-Aug-2009 10:28 56K
[ ] php-pear-MDB2-Driver-mysqli-1.4.1-4.el5.remi.noarch.rpm 19-Jul-2009 13:41 42K
[ ] php-pear-Mail-Mime-1.5.2-4.el5.remi.noarch.rpm 02-Dec-2008 18:36 31K
[ ] php-pear-Mail-Mime-1.5.2-5.el5.remi.noarch.rpm 19-Jul-2009 13:41 31K
[ ] php-pear-Mail-mimeDecode-1.5.0-3.el5.remi.noarch.rpm 02-Dec-2008 18:36 13K
[ ] php-pear-Mail-mimeDecode-1.5.0-4.el5.remi.noarch.rpm 19-Jul-2009 13:41 13K
[ ] php-pear-Net-DNS-1.0.1-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 31K
[ ] php-pear-Net-FTP-1.3.7-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 38K
[ ] php-pear-Net-IPv4-1.3.0-3.el5.remi.noarch.rpm 19-Jul-2009 13:41 8.1K
[ ] php-pear-Net-Ping-2.4.4-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 14K
[ ] php-pear-Net-SMTP-1.3.3-1.el5.remi.noarch.rpm 19-Jul-2009 13:41 17K
[ ] php-pear-Net-Sieve-1.1.6-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 18K
[ ] php-pear-Net-Sieve-1.1.7-1.el5.remi.noarch.rpm 29-Jul-2009 08:36 18K
[ ] php-pear-Net-Socket-1.0.9-2.el5.remi.noarch.rpm 19-Jul-2009 13:41 10K
[ ] php-pear-PEAR-Command-Packaging-0.2.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 21K
[ ] php-pear-PHP-CodeSniffer-1.1.0-1.el5.remi.noarch.rpm 19-Jul-2009 15:37 298K
[ ] php-pear-PHP-CompatInfo-1.8.1-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 166K
[ ] php-pear-PHPUnit-3.3.16-1.el5.remi.noarch.rpm 19-Jul-2009 15:37 323K
[ ] php-pear-SOAP-0.12.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 78K
[ ] php-pear-Services-Weather-1.4.4-1.el5.remi.noarch.rpm 19-Jul-2009 15:37 57K
[ ] php-pear-Structures-DataGrid-0.9.0-4.el5.remi.noarch.rpm 19-Jul-2009 15:37 54K
[ ] php-pear-Structures-DataGrid-DataSource-Array-0.1.4-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 7.3K
[ ] php-pear-Structures-DataGrid-DataSource-DataObject-0.2.1-2.el5.remi.noarch.rpm19-Jul-2009 15:37 11K
[ ] php-pear-Structures-DataGrid-DataSource-MDB2-0.1.11-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 7.4K
[ ] php-pear-Structures-DataGrid-Renderer-Pager-0.1.3-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 8.1K
[ ] php-pear-Structures-DataGrid-Renderer-Smarty-0.1.4-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 9.7K
[ ] php-pear-Validate-Finance-CreditCard-0.5.3-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 10K
[ ] php-pear-XML-Beautifier-1.2.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 17K
[ ] php-pear-XML-Parser-1.3.2-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 22K
[ ] php-pear-creole-1.1.0-6.el5.remi.noarch.rpm 19-Jul-2009 15:37 105K
[ ] php-pear-pake-1.1.4-4.el5.remi.noarch.rpm 19-Jul-2009 15:37 30K
[ ] php-pear-phing-2.3.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 435K
[ ] php-pear-propel_generator-1.3.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 190K
[ ] php-pear-propel_runtime-1.3.0-2.el5.remi.noarch.rpm 19-Jul-2009 15:37 64K
[ ] php-pecl-Fileinfo-1.0.4-3.el5.remi.i386.rpm 16-Jun-2007 23:09 11K
[ ] php-pecl-apc-3.1.2-2.el5.remi.1.i386.rpm 02-Jul-2009 22:28 86K
[ ] php-pecl-apc-3.1.3p1-1.el5.remi.i386.rpm 15-Aug-2009 07:55 101K
[ ] php-pecl-geoip-1.0.7-2.el5.remi.i386.rpm 03-Jul-2009 18:42 13K
[ ] php-pecl-imagick-2.2.2-3.el5.remi.1.i386.rpm 02-Jul-2009 22:28 87K
[ ] php-pecl-imagick-2.3.0-1.el5.remi.i386.rpm 24-Aug-2009 18:56 90K
[ ] php-pecl-lzf-1.5.2-3.el5.remi.i386.rpm 03-Jul-2009 18:42 9.0K
[ ] php-pecl-mailparse-2.1.1-5.el5.remi.i386.rpm 16-Jun-2007 15:36 27K
[ ] php-pecl-mailparse-2.1.5-2.el5.remi.1.i386.rpm 02-Jul-2009 22:28 34K
[ ] php-pecl-memcache-3.0.4-1.el5.remi.i386.rpm 28-Feb-2009 18:07 63K
[ ] php-pecl-memcache-3.0.4-2.el5.remi.1.i386.rpm 02-Jul-2009 22:28 64K
[ ] php-pecl-memcached-0.2.0-1.el5.remi.i386.rpm 29-Jun-2009 18:09 29K
[ ] php-pecl-memcached-0.2.0-2.el5.remi.1.i386.rpm 02-Jul-2009 22:28 29K
[ ] php-pecl-ncurses-1.0.0-4.el5.remi.1.i386.rpm 02-Jul-2009 22:28 28K
[ ] php-pecl-pdflib-2.1.6-1.el5.remi.i386.rpm 21-Mar-2009 16:50 44K
[ ] php-pecl-pdflib-2.1.7-2.el5.remi.1.i386.rpm 02-Jul-2009 22:30 42K
[ ] php-pecl-phar-1.2.2-1.el5.remi.i386.rpm 27-Oct-2007 10:30 62K
[ ] php-pecl-radius-1.2.5-6.el5.remi.i386.rpm 03-Jul-2009 18:42 33K
[ ] php-pecl-ssh2-0.11.0-1.el5.remi.i386.rpm 09-Jun-2009 19:10 29K
[ ] php-pecl-ssh2-0.11.0-3.el5.remi.1.i386.rpm 02-Jul-2009 22:28 29K
[ ] php-pecl-xdebug-2.0.3-4.el5.remi.i386.rpm 12-Dec-2008 18:20 151K
[ ] php-pecl-xdebug-2.0.5-1.el5.remi.i386.rpm 14-Jul-2009 09:30 151K
[ ] php-pgsql-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 71K
[ ] php-pgsql-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 72K
[ ] php-process-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 37K
[ ] php-process-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 40K
[ ] php-pspell-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 26K
[ ] php-pspell-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 28K
[ ] php-recode-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 22K
[ ] php-recode-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 25K
[ ] php-snmp-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 29K
[ ] php-snmp-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 32K
[ ] php-soap-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 145K
[ ] php-soap-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 147K
[ ] php-suhosin-0.9.24-1.el5.remi.i386.rpm 11-May-2008 11:01 74K
[ ] php-suhosin-0.9.27-1.el5.remi.i386.rpm 18-Sep-2008 19:21 76K
[ ] php-tidy-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 34K
[ ] php-tidy-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 37K
[ ] php-xml-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 115K
[ ] php-xml-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 114K
[ ] php-xmlrpc-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 57K
[ ] php-xmlrpc-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 54K
[ ] php-zts-5.2.10-1.el5.remi.i386.rpm 21-Jun-2009 11:46 1.3M
[ ] php-zts-5.3.0-2.el5.remi.2.i386.rpm 19-Jul-2009 18:08 1.3M
[ ] phpMyAdmin- 30-Jun-2009 22:44 4.1M
[ ] phpMyAdmin-3.2.1-1.el5.remi.noarch.rpm 10-Aug-2009 19:14 4.2M
[ ] phpcs-1.1.0-1.el5.remi.noarch.rpm

Step 2:
[root@home php5.2.10]# awk '{ print $3 }' phpfiles.rtf > phpfiles.rtf.1

[root@home php5.2.10]# cat phpfiles.rtf.1

[root@home php5.2.10]# cat
for i in `cat phpfiles.rtf.1`
wget "$i"

Centos * HowTos * PHP 5.1 To 5.2

SkyHi @ Friday, August 28, 2009

This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:

# rpm -qa |grep php


As long as you're using the standard PHP packages on your CentOS server you won't need to do anything extra. If you're using extra PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find updated versions of them.

Add the development repositories

First thing we need to do is add the development repositories to yum. When we add the development repository we're going to configure it so it only pulls PHP packages. To start we'll need create a new yum repository configuration file (use your favorite editor):

# /etc/yum.repos.d/CentOS-Testing.repo

Copy/paste the following into this file:

# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.
name=CentOS-5 Testing

Save and close the file and you're done.

Update PHP packages

Before updating your PHP packages you'll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:

# rpm -qa |grep php

Now you can use yum to update the PHP packages on your system:

# yum update

You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.2.x. If that is acceptable type "y" to continue and let yum update the packages.

Once yum has completed restart Apache:

# service httpd restart

To verify the update is working create a simple testing.php in your www directory with the following source code:


and open it in a web browser. The new PHP version should be reflected at the top of the page.


You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.

# rpm -qa |grep php


# php -v

PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Note: If your "php -v" output returns errors about PDO or JSON click here


Updating/Installing mcrypt

If you have php-mcrypt for PHP 5.1.x installed you'll want to remove it:

Note: Your version number maybe different. Alter below command accordingly.

rpm -e php-mcrypt-5.1.6-15.el5.centos.1

Download php-mcrypt for PHP 5.2.x and install it. You can find a 32-bit php-mcrypt package here FedoraJunkies.

Note: You'll notice the "--nodeps" flag in the example. When you try to install php-mcrypt without it you get an error that php-common-5.2.6-2.el5s2 is missing even though it is installed.

wget -c
rpm -i --nodeps php-mcrypt-5.2.6-2.i386.rpm

Restart Apache and you should now see mcrypt information on your testing.php page.

JSON and PDO being loaded twice

When you run the command "php -v" you might see the following errors:

# php -v

PHP Warning: Module 'json' already loaded in Unknown on line 0
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

This is caused by the following two lines in the /etc/php.ini file:

; Extension JSON

; Extension PDO

Comment out these lines by adding a ";" in front of "extension=". These two modules are already loaded via these two files:



PHP 5.3 on CentOS 5

SkyHi @ Friday, August 28, 2009
My previous articles on installing PHP on CentOS dealt with installing PHP 5.2.6. I have found this to have some bugs that kill the process without error information. One bug I found, which was on an x86_64 server, was that converting an object to a string did this.
So, I have compiled the latest PHP version, 5.2.10 5.3.0 5.3.3, and put it in my own repository for easy installation. I have compiled it for CentOS 5 i386 and x86_64, and provided the source RPMS in the repo, if anyone wants to compile it for another OS or architecture.
Update 2009-07-03 – I updated the version to PHP 5.3, which was released a few days before. This includes many new features such as closures, namespaces, and packaged scripts in phar files, which I’ll blog about soon. Check out PHP changelog for more details.
Update 2009-09-01 – Added a note about deprecated errors, and how to silence them. Also I have included a tip that might help those of you struggling to install.
Update 2010-03-03 – I’ve added both apc 3.1.3p1 beta (php-pecl-apc in yum) and eAccelerator 0.9.6 (php-eaccelerator in yum) RPMs to the repository, they are compiled for (and work on) php 5.3.x

I have also included the same php extensions I mentioned in my other article, php-mcrypt, php-mhash (in PHP 5.2), php-mssql and php-tidy
To install, first you must tell rpm to accept rpm’s signed by me, then add the yum repository information to yum:
rpm -ivh`uname -i`/webtatic-release-5-0.noarch.rpm
Now you can install php by doing:
yum --enablerepo=webtatic install php
Or update an existing installation of php, which will also update all of the other php modules installed:
yum --enablerepo=webtatic update php
If this does not work correctly, try disabling all other repositories while installing/updating, by adding the –disablerepo=* option. This will stop other dependencies from being installed, so you may want to install them first.
yum --disablerepo=* --enablerepo=webtatic update php

“Depsolving” problems

If you get depsolving problems when updating, you may have currently installed some extensions that have been removed, e.g. php-mhash, php-ncurses.
You will need to remove them before upgrading.
yum remove php-mhash php-ncurses

Deprecated Errors

Once you are running the new version, you may get “deprecated” errors in your error logs. This isn’t bad, it just means to tell you that some of the functions you are using are no longer prefered, and may be removed in a future major release. An example of this is the ereg functions. Preg functions are prefered over these, as they are much faster and more powerful, and in all cases do at least the same thing.
If upgrading the functions are not an option, and you would like to hide the deprecated errors from your error log, for example on a production server, just edit your /etc/php.ini file, find the line:
error_reporting  =  E_ALL
and replace to:
error_reporting  =  E_ALL & ~E_DEPRECATED

PHP 5.2.14

I am also maintaining a PHP 5.2.14 release, so should you prefer to install that (for reasons like incompatibilities or testing), you can force it to install that instead by doing:
yum --enablerepo=webtatic --exclude=php*5.3* update php
Or you can add to the /etc/yum.repos.d/webtatic.repo the line:



SkyHi @ Friday, August 28, 2009

Cent os php source rpm 5.2

SkyHi @ Friday, August 28, 2009
Here at EchoDitto, most of our servers are running CentOS Linux, which is a 100% binary-compatible version of the industry standard Red Hat Enterprise Linux (RHEL) without any of the fees. The problem with RHEL/CentOS is that they shipped with PHP 5.1.6, and as of this writing PHP is at 5.2.9. That's not a big deal, being a minor point revision behind, until you come across an application or module that needs a minimum of version 5.2. The last thing I want to do is install packages from a third-party or build it from source and risk breaking other packages. So what's the answer? Building it from the source rpm. There's no better way to keep the system free of third-party packages but also up to date.

Why source RPMs and not the source from PHP? Building a source RPM is the same procedure used to build the packages that Red Hat creates, and includes the libraries and dependencies and sub-packages that you would normally get from Red Hat directly. It will also include all of the same build flags in your new version that were available in the older package, meaning your PHP scripts won't suddenly break. This ultimately ensures binary compatibility and the ability to easily upgrade if Red Hat or CentOS were to release a package newer than yours.

Sure, you could enable the CentOS Testing repository, but with all of the warnings about packages breaking your system, and configuring yum to only update PHP and not mess up mysql or Apache, I'd rather build and install only the packages that I need without worrying about breaking other packages. Want PHP 5.2 on your CentOS or RHEL server? Follow along.

1. Start by downloading the latest PHP 5.2 source RPM from the aforementioned CentOS Testing repository from As of this writing, they're at php-5.2.6-2. Why aren't we using the 5.1.6 source? The source RPM for 5.2.6 includes the latest patches from Red Hat that you can normally only get from being a part of the non-free Red Hat Network.

I'll assume you're running as root for this guide. Download the source RPM with wget

# wget

2. Install the source RPM

# rpm -ivh php-5.2.6-2.el5s2.src.rpm

3. If you get an error and the install fails, you may need to manually create the SOURCES directory and install again

# mkdir -p /usr/src/redhat/SOURCES
# rpm -ivh php-5.2.6-2.el5s2.src.rpm

4. Download the latest stable release of PHP from the download page and save it in the SOURCES folder. Change the version number to the latest version if needed.

# cd /usr/src/redhat/SOURCES
# wget

5. In the SPECS folder, copy the original php.spec file in case you make mistakes or wish to build 5.2.6.

# cd /usr/src/redhat/SPECS
# cp php.spec php526.spec

6. Edit php.spec and change the version and revision numbers to be 5.2.9 (or later) and the revision to 1 since this is your first build.

Summary: The PHP HTML-embedded scripting language
Name: php
Version: 5.2.9
Release: 1%{?dist}
License: PHP
Group: Development/Languages

7. Make sure you have the Development Tools group install for rpmbuild if you haven't already done so.

# yum groupinstall "Development Tools"

8. Try and build the spec file to see if you are missing any packages. For this tutorial, I am running from the minimal package set.

# rpmbuild -ba php.spec
cat: /usr/include/httpd/.mmn: No such file or directory
error: Failed build dependencies:
bzip2-devel is needed by php-5.2.9-1.i386
curl-devel >= 7.9 is needed by php-5.2.9-1.i386
db4-devel is needed by php-5.2.9-1.i386
expat-devel is needed by php-5.2.9-1.i386
gmp-devel is needed by php-5.2.9-1.i386
aspell-devel >= 0.50.0 is needed by php-5.2.9-1.i386
httpd-devel >= 2.0.46-1 is needed by php-5.2.9-1.i386
libjpeg-devel is needed by php-5.2.9-1.i386
libpng-devel is needed by php-5.2.9-1.i386
pam-devel is needed by php-5.2.9-1.i386
openssl-devel is needed by php-5.2.9-1.i386
sqlite-devel >= 3.0.0 is needed by php-5.2.9-1.i386
zlib-devel is needed by php-5.2.9-1.i386
pcre-devel >= 6.6 is needed by php-5.2.9-1.i386
readline-devel is needed by php-5.2.9-1.i386
krb5-devel is needed by php-5.2.9-1.i386
libc-client-devel is needed by php-5.2.9-1.i386
cyrus-sasl-devel is needed by php-5.2.9-1.i386
openldap-devel is needed by php-5.2.9-1.i386
mysql-devel >= 4.1.0 is needed by php-5.2.9-1.i386
postgresql-devel is needed by php-5.2.9-1.i386
unixODBC-devel is needed by php-5.2.9-1.i386
libxml2-devel is needed by php-5.2.9-1.i386
net-snmp-devel is needed by php-5.2.9-1.i386
libxslt-devel >= 1.0.18-1 is needed by php-5.2.9-1.i386
libxml2-devel >= 2.4.14-1 is needed by php-5.2.9-1.i386
ncurses-devel is needed by php-5.2.9-1.i386
gd-devel is needed by php-5.2.9-1.i386
freetype-devel is needed by php-5.2.9-1.i386

9. Install any required packages with yum. If any of these packages have other dependencies they will be downloaded as well. This might take a while.

# yum install bzip2-devel curl-devel db4-devel expat-devel gmp-devel aspell-devel \
httpd-devel libjpeg-devel libpng-devel pam-devel openssl-devel sqlite-devel zlib-devel \
pcre-devel readline-devel krb5-devel libc-client-devel cyrus-sasl-devel openldap-devel \
mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel \
libxml2-devel ncurses-devel gd-devel freetype-devel

10. Try and build the spec file again to see if any patches fail to load properly. This usually happens if a patch has been rolled into the mainline PHP project and is no longer needed.

# rpmbuild -ba php.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.81391
+ umask 022
+ cd /usr/src/redhat/BUILD
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf php-5.2.9
+ /bin/gzip -dc /usr/src/redhat/SOURCES/php-5.2.9.tar.gz
+ tar -xf -
... output snipped ...
Patch #32 (php-5.2.5-systzdata.patch):
+ patch -p1 -b --suffix .systzdata -s
+ echo 'Patch #50 (php-5.2.4-tests-dashn.patch):'
Patch #50 (php-5.2.4-tests-dashn.patch):
+ patch -p1 -b --suffix .tests-dashn -s
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
1 out of 1 hunk ignored -- saving rejects to file ext/standard/tests/file/bug26615.phpt.rej
1 out of 1 hunk FAILED -- saving rejects to file ext/standard/tests/file/proc_open01.phpt.rej
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
1 out of 1 hunk ignored -- saving rejects to file ext/standard/tests/file/bug26938.phpt.rej
error: Bad exit status from /var/tmp/rpm-tmp.81391 (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.81391 (%prep)

11. Looks like Patch 50 failed. Edit the spec file and comment out the line that begins with %patch50

%patch30 -p1 -b .dlopen
%patch31 -p1 -b .easter
%patch32 -p1 -b .systzdata
#%patch50 -p1 -b .tests-dashn
%patch51 -p1 -b .tests-wddx

12. For 5.2.9 as of this writing, this is the only patch that fails to load properly. In later versions, you may find that other patches fail to load, and you should comment those out as well.
13. Build the spec file again and after several minutes it will be complete and you'll have a handful of rpms in /usr/src/redhat/RPMS/i386

# rpmbuild -ba php.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.77534
+ umask 022
+ cd /usr/src/redhat/BUILD
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf php-5.2.9
+ /bin/gzip -dc /usr/src/redhat/SOURCES/php-5.2.9.tar.gz
+ tar -xf -
... output snipped ...
Wrote: /usr/src/redhat/RPMS/i386/php-ncurses-5.2.9-1.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/php-gd-5.2.9-1.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/php-bcmath-5.2.9-1.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/php-dba-5.2.9-1.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/php-debuginfo-5.2.9-1.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.7525
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd php-5.2.9
+ '[' /var/tmp/php-5.2.9-1-root-root '!=' / ']'
+ rm -rf /var/tmp/php-5.2.9-1-root-root
+ rm files.bcmath files.common files.dba files.dbase files.dom files.imap [snip]
+ exit 0

14. You'll probably want to also build the php-extras source RPM as well. php-extras provides extensions for dbase, readline, mcrypt, mhash, tidy and mssql. Since there is no package in CentOS Testing, grab the latest from 5.1.6.

# wget

15. And install it.

# rpm -ivh php-extras-5.1.6-15.el5.centos.1.src.rpm

16. Copy the php-extras.spec file like you did for php.spec so you can have the original.

# cd /usr/src/redhat/SPECS
# cp php-extras.spec php-extras516.spec

17. We ultimately need to replace the patches in php-extras.spec with the same from the much newer php.spec, as well as the ABI version numbers in the beginning of the file. has already done this and you can go ahead and download the edited spec file, which also includes new PHP 5.2 extensions for json and filter. Remember, if you had a failed patch from php.spec, you'll need to comment it out in php-extras.spec as well. For 5.2.9, I had to comment out patch50 again.

%patch32 -p1 -b .systzdata
#%patch50 -p1 -b .tests-dashn
%patch51 -p1 -b .tests-wddx

18. Once your php-extras.spec file is up to date, build the spec file and see if you're missing any dependencies.

# rpmbuild -ba php-extras.spec
error: Failed build dependencies:
php-devel = 5.2.9 is needed by php-extras-5.2.9-1.i386
libmcrypt-devel is needed by php-extras-5.2.9-1.i386
mhash-devel is needed by php-extras-5.2.9-1.i386
libtidy-devel is needed by php-extras-5.2.9-1.i386
freetds-devel is needed by php-extras-5.2.9-1.i386

19. Let's go back and install the php package that we need. If you only want the minimum needed to build php-extras, start by installing php-devel and seeing what it asks for, and install it's dependencies.

# cd /usr/src/redhat/RPMS/i386
# rpm -ivh php-devel-5.2.9-1.i386.rpm
error: Failed dependencies:
php = 5.2.9-1 is needed by php-devel-5.2.9-1.i386
# rpm -ivh php-5.2.9-1.i386.rpm php-devel-5.2.9-1.i386.rpm
error: Failed dependencies:
php-cli = 5.2.9-1 is needed by php-5.2.9-1.i386
php-common = 5.2.9-1 is needed by php-5.2.9-1.i386
# rpm -ivh php-5.2.9-1.i386.rpm php-devel-5.2.9-1.i386.rpm php-cli-5.2.9-1.i386.rpm php-common-5.2.9-1.i386.rpm
Preparing... ########################################### [100%]
1:php-common ########################################### [ 25%]
2:php-cli ########################################### [ 50%]
3:php ########################################### [ 75%]
4:php-devel ########################################### [100%]

20. After installing those four packages, install the other packages with yum.

# yum install libmcrypt-devel mhash-devel libtidy-devel freetds-devel

21. Now that all of the dependencies are resolved, build the php-extras.spec file.

# cd /usr/src/redhat/SPECS
# rpmbuild -ba php-extras.spec

22. If you're using RHEL, the build might fail for two reasons: a library for tidy is needed, and mhash-devel isn't available for RHEL. Both are easy to fix. Install 'tidy' with yum, and while mhash-devel isn't available, you can download libmhash-devel and edit the spec file to require libmhash-devel instead of mhash-devel.

You should now have all of your RPMs in /usr/src/redhat/RPMS/i386 (or x86_64) and install whichever packages you want. If in doubt, install them all. They're mainly static libraries and won't bloat your system. You may not want to install the debuginfo packages since you may find little use for them.

Staying updated is easy, download the source from into /usr/src/redhat/SOURCES and edit the spec files for the new version numbers, rebuild, and install RPMs. If you're concerned about new patches being needed, you can grab the latest source RPM from Centos: If CentOS were to ever come out with a newer version, or you want to subscribe to a yum repo and they provided a higher version, it would update as normal. You would need to rebuild in pear/pecl libraries by uninstall+installing them.

Yes, this is an involved process the first time around, but after doing this once you only need to download the latest source from and edit the spec file version number and rebuild and update. If an old patch fails in a newer version you'll need to comment it out, but it's that simple.

This also works for 64-bit installations. Thanks to DiNo for helping me get PHP built on a 64-bit RHEL installation.

If you'd like to skip the steps and get right to building, you can download and install the source RPMs and build again the spec files. If you'd like to do itself, you can compare my spec files to yours. Enjoy the latest PHP hotness!


PHP 5.2 on Red Hat 5 / CentOS 5

SkyHi @ Friday, August 28, 2009
The following is a build log for installing PHP 5.2.5 on Red Hat Enterprise 5 / CentOS 5. I grabbed the source RPM from Fedora 9. Some people just have to have the latest version. Sigh.

I highly recommend this build method if you require PHP 5.2. It folds in all the latest Fedora patches, which will eventually make their way into Enterprise.

Please note that you can tweak the configure options by editing the php.spec before executing rpmbuild.

I happen to be building on x86_64 64-bit, but this will most likely work on 32-bit as well. Some of the build dependencies require packages from EPEL.

# cd /usr/src
# wget
# rpm -Uvh
# yum install httpd-devel libc-client-devel postgresql-devel \
unixODBC-devel net-snmp-devel gd-devel libmcrypt-devel \
mhash-devel libtidy-devel freetds-devel aspell-devel
# yum install apr-devel
# rpm -ihv php-5.2.5-7.fc9.src.rpm
# cd /usr/src/redhat/SPECS
# rpmbuild -bb php.spec
# cd /usr/src/redhat/RPMS/x86_64
# rpm -ihv php-5.2.5-7.x86_64.rpm php-ldap-5.2.5-7.x86_64.rpm \
php-gd-5.2.5-7.x86_64.rpm php-cli-5.2.5-7.x86_64.rpm \
php-common-5.2.5-7.x86_64.rpm php-mbstring-5.2.5-7.x86_64.rpm \
php-pdo-5.2.5-7.x86_64.rpm php-mysql-5.2.5-7.x86_64.rpm


Thursday, August 27, 2009

10 Ways to Automatically & Manually Backup MySQL Database

SkyHi @ Thursday, August 27, 2009
MySQL is one of the most popular open source database management system for the development of interactive Websites.

If your site stores its sensitive data in a MySQL database, you will most definitely want to backup that information so that it can be restored in case of any disaster (we all have been there).

There are several ways to backup MySQL data. In this article we’ll look at how to backup your databases using different methods, we will also learn how to achieve an automatic backup solution to make the process easier. Starting with the mysqldump utility that comes with MySQL, we will review several examples using mysqldump, including the backup of your database to a file, another server, and even a compressed gzip file and send it to your email.

1. Automatically backup mysql database to Amazon S3

MySQL Backup Solution

Many of users use Amazon S3 to backup their mysql databases. Here is an automated script which does this task of taking the backup of a mysql database and then moving it to the Amazon S3.
2. How to Backup MySQL Database automatically (for Linux users)
view plaincopy to clipboardprint?

1. 15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /mnt/disk2/database_`data ' %m-%d-%Y'`.sql.gz

15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | gzip > /mnt/disk2/database_`data ' %m-%d-%Y'`.sql.gz

This post will show you how to backup MySQL Database automatically if you are a linux user. You can use cron to backup your MySQL database automatically.”cron” is a time-based scheduling utility in Unix/Linux
operating system.
3. Backup your MySQL databases automatically with AutoMySQLBackup

AutoMySQLBackup has some great features to: backup a single database, multiple databases, or all the databases on the server; each database is saved in a separate file that can be compressed (with gzip or bzip2); it will rotate the backups and not keep them filling your hard drive (as normal in the daily backup you will have only the last 7 days of backups, the weekly if enabled will have one for each week, etc.).
4. Backing Up With MySQLDump

1. mysqldump ---user [user name] ---password=[password]
2. [database name] > [dump file]

mysqldump ---user [user name] ---password=[password]
[database name] > [dump file]

In this article we’ll look at how to backup our databases using the mysqldump utility that comes with MySQL. Several examples will be reviewed using mysqldump, including the backup of your database to a file,
another server, and even a compressed gzip file.
5. Backup Your Database into an XML File Using PHP

1. mysqldump ---user [user name] ---password=[password]
2. [database name] > [dump file]

mysqldump ---user [user name] ---password=[password]
[database name] > [dump file]

Here’s a PHP snippet that outputs your database as XML. XML isn’t the easiest format to restore a table but it can be easier to read.
6. How to – Using PHP To Backup MySQL Database

Execute a database backup query from PHP file. Below is an example of using SELECT INTO OUTFILE query for creating table backup:
view plaincopy to clipboardprint?

1. 2. include 'config.php';
3. include 'opendb.php';
5. $tableName = 'mypet';
6. $backupFile = 'backup/mypet.sql';
7. $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
8. $result = mysql_query($query);
10. include 'closedb.php';
11. ?>

include 'config.php';
include 'opendb.php';

$tableName = 'mypet';
$backupFile = 'backup/mypet.sql';
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
$result = mysql_query($query);

include 'closedb.php';

To restore the backup you just need to run LOAD DATA INFILE query like this :
view plaincopy to clipboardprint?

1. 2. include 'config.php';
3. include 'opendb.php';
5. $tableName = 'mypet';
6. $backupFile = 'mypet.sql';
7. $query = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName";
8. $result = mysql_query($query);
10. include 'closedb.php';
11. ?>

include 'config.php';
include 'opendb.php';

$tableName = 'mypet';
$backupFile = 'mypet.sql';
$query = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName";
$result = mysql_query($query);

include 'closedb.php';

7. Backup MySQL Database Via SSH

A simple solution to backup your large MySQL databases through SSH. You will need to enable shell access inside your Plesk control panel and use a utility such as PuTTY to log into your server via SSH.
8. How to e-mail yourself an automatic backup of your MySQL database table with PHP

This script will send an e-mail to you with an .sql file attached, thus enabling you to back up specific tables easily. You could even set up an e-mail account just to receive these backups…
9. Ubuntu Linux Backup MySQL server Shell Script

If you have a dedicated VPS server running Ubuntu Linux. Here is how to backup all your mysql server databases to your ftp server
10. How to backup MySQL databases, web server files to a FTP server automatically

This is a simple backup solution for people who run their own web server and MySQL server on a dedicated box or VPS. The main advantage of using FTP or NAS backup is a protection from data loss.First you will need to backup each database with mysqldump command, Automating tasks of backup with tar, Setup a cron job and generate FTP backup script.

1. $ mysqldump -u root -h localhost -pmypassword faqs | gzip -9 > faqs-db.sql.gz

$ mysqldump -u root -h localhost -pmypassword faqs | gzip -9 > faqs-db.sql.gz

11. MySQL Export: How to backup your MySQL database?

MySQL Backup Solution

You can easily create a dump file(export/backup) of a database used by your account. In order to do so you should access the phpMyAdmin tool available in your cPanel.


How to: Backup MySQL database & email results using PHP

SkyHi @ Thursday, August 27, 2009
There are a bunch of scripts on the Internet that overly complicate the issue of automatically backing up your database. Here is a PHP script I wrote to backup a mysql database and email the results. Just set a cron job (/etc/crontab) to run this script with the following command: php /…./dbBackUp.php



Quickly and easily backup your MySQL database and have the tgz emailed to you. You need PEAR installed with the Mail and Mail_Mime packages installed. Read more about PEAR here: This will work in any *nix enviornment. Make sure you have write access to your /tmp directory.



// mysql & minor details..
$tmpDir = "/tmp/";
$user = "root";
$password = "pass";
$dbName = "db";
$prefix = "db_";

// email settings...
$to = "";
$from = "";
$subject = "db - backup";
$sqlFile = $tmpDir.$'Y_m_d').".sql";
$attachment = $tmpDir.$'Y_m_d').".tgz";

$creatBackup = "mysqldump -u ".$user." --password=".$password." ".$dbName." > ".$sqlFile;
$createZip = "tar cvzf $attachment $sqlFile";

$headers = array('From' => $from, 'Subject' => $subject);
$textMessage = $attachment;
$htmlMessage = "";

$mime = new Mail_Mime("\n");
$mime->addAttachment($attachment, 'text/plain');
$body = $mime->get();
$hdrs = $mime->headers($headers);
$mail = &Mail::factory('mail');
$mail->send($to, $hdrs, $body);




How To Backup Your MySQL Database With PHP

SkyHi @ Thursday, August 27, 2009
he Article

If your website some how gets hacked and you lose all your MySQL Database information, I doubt you would be laughing... or smiling... That's why you need to backup your database from time to time so that you can put it back the way it was. Here is a simple script using PHP and MySQL to backup your database!

The Script

First of all you need to connect to the database:

$db_host = "localhost";
$db_name = "";
$db_user = "";
$db_pass = "";

@mysql_select_db($db_name) or die("Unable to select database.");

And then you need to create a function that will backup your table contents:

function datadump ($table) {

$result .= "# Dump of $table \n";
$result .= "# Dump DATE : " . date("d-M-Y") ."\n\n";

$query = mysql_query("select * from $table");
$num_fields = @mysql_num_fields($query);
$numrow = mysql_num_rows($query);

for ($i =0; $i<$numrow; $i++) {
$result .= "INSERT INTO ".$table." VALUES(";
for($j=0; $j<$num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\"";
if ($j<($num_fields-1)) $result .= ",";
$result .= ");\n";
return $result . "\n\n\n";

OK, now you add the last bit to the script:

$table1 = datadump ("table1");
$table2 = datadump ("table2");
$table3 = datadump ("table3");

$content = $table1 . $table2 . $table3;

$file_name = "MySQL_Database_Backup.sql";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=$file_name");
echo $content;

See this part:

$table1 = datadump ("table1");
$table2 = datadump ("table2");
$table3 = datadump ("table3");

$content = $table1 . $table2 . $table3;

That is where you need to specify the tables you want to backup.

Lets say you had 3 tables called links, categories and users. You would need to add:

$links = datadump ("links");
$categories = datadump ("categories");
$users = datadump ("users");

And then to the $content area add:

$content = $links . $categories . $users;

That's it. Enter your MySQL Database information and fill in the tables an hey presto, run the script and it should backup your table contents!



Backup and restore MySQL databases with PHP

SkyHi @ Thursday, August 27, 2009
One of the most important tasks any developer needs to do often is back up their MySQL database. In many cases, the database is what drives most of the site. While most web hosts do a daily backup of a customer’s database, relying on them to make backups and provide them at no cost is risky to say the least. That’s why I’ve created a database backup function that I can call whenever I want — including nightly CRONs.


/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')

$link = mysql_connect($host,$user,$pass);

//get all of the tables
if($tables == '*')
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
$tables[] = $row[0];
$tables = is_array($tables) ? $tables : explode(',',$tables);

//cycle through
foreach($tables as $table)
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);

$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";

for ($i = 0; $i < $num_fields; $i++)
while($row = mysql_fetch_row($result))
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
$return.= ");\n";

//save file
$handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');


Mysql Blog

SkyHi @ Thursday, August 27, 2009

MySQL: RENAME TABLE on Transactional Tables Can Jeopardize Slave Data

SkyHi @ Thursday, August 27, 2009

MySql: Drop table, rename table, drop foreign key, drop column

SkyHi @ Thursday, August 27, 2009
MySql: Drop table, rename table, drop foreign key, drop column
July 24th, 2009 by jeremychone

#switch to the right DB
USE database_name;

#drop a table
DROP TABLE table_name;

#rename a table
RENAME TABLE table_name TO new_table_name;

#drop a foreign key

#drop a column
ALTER TABLE table_name DROP COLUMN column_name;

Renaming a table in MySQL

SkyHi @ Thursday, August 27, 2009
Sometimes you need to rename a table in MySQL. You either run an SQL query to do this or do it with phpMyAdmin if you don't want to bother remembering the SQL to do so. This post looks at how to rename a table in MySQL either with a SQL query or using phpMyAdmin.

The example SQL below renames the MySQL table "tablename" to "tablename_renamed":

RENAME TABLE tablename TO tablename_renamed

To rename a MySQL table with phpMyAdmin, select the database then table, and click the "Operations" tab. Then put the new name into the text box labelled "rename table to" and click the "Go" button. The relevent buttons etc are highlighted with red circles in the screenshot below.

After clicking the "Go" button the table will be renamed and the same page as shown above will be loaded again, showing the rename query that was executed.

Mysql Alter Rename Table

SkyHi @ Thursday, August 27, 2009
Mysql Alter Rename Table is used to redefine and rename the existing table.

Understand with Example

The Tutorial illustrate an example from 'Mysql Alter Rename Table'. To understand this example we create a table 'employees' with required field name and datatype respectively. The table 'employees' have a Empid as Primary Key.

Query to create table:-

CREATE TABLE employees (
->Empid int(10),
->Empname varchar(60),
->date date

Query to insert data into Table named employees:

To insert a records or rows into a table 'employees' we use insert into statement that add the records value to table 'employees'.

mysql>insert into employees values(01,'Girish','2008-12-22');
Query OK, 1 row affected (0.02 sec)

mysql>insert into employee1 values(02,'Komal','2008-12-23');
Query OK, 1 row affected (0.02 sec)

Query to view data of Table named employees:

To view the detail of table we use select query that return the records details from table 'employees'.

mysql> select * from employees;


| empid | empname | date |
| 1 | Girish | 2008-12-22 |
| 2 | Komal | 2008-12-23 |
2 rows in set (0.00 sec)

Query to rename table name:

The Query below is used to modify the definition of table 'employees' and rename keyword is used to change the existing name of table from 'employees' to 'employees1'.

mysql> alter table employees rename as employees1;
Query OK, 0 rows affected (0.03 sec)

Query to view table data:

mysql> select * from employees;
ERROR 1146 (42S02): Table 'girish.employees' doesn't exist

Query to view table data:

mysql> select * from employees1;
| empid | empname | date |
| 1 | Girish | 2008-12-22 |
| 2 | Komal | 2008-12-23 |
2 rows in set (0.00 sec)


MySQL rename a table or column

SkyHi @ Thursday, August 27, 2009
Summary: As of MySQL 5.0, renaming a table is trivial with the "rename table" function. Renaming a column was a little cryptic, even looking at the documentation. Here are a couple of concrete examples.

To rename a table from "lu_wind_direction" to "lu_direction":

mysql> rename table lu_wind_direction to lu_direction;

To rename a column called "wind_direction_id" to "direction_id" in the table named "spacetime":

mysql> alter table spacetime change wind_direction_id direction_id tinyint(3) unsigned;

So, when renaming a column, it's just the original name first, then after the new name, you need to include the column specifications and constraints.


Rename or change name of MySQL table

SkyHi @ Thursday, August 27, 2009
If you change your mind and want to rename an existing MySQL table, with or without data in it, it is no problem. One simple command will change the table’s name.

To change the name of an existing table first to second, use this command as a user with adequate privileges:

RENAME TABLE first TO second;

It is good DBA manners to make sure that no one and no program are using this table before making the name change.


MySQL Rename Multiple Columns

SkyHi @ Thursday, August 27, 2009





SkyHi @ Thursday, August 27, 2009
12.1.32. RENAME DATABASE Syntax

RENAME {DATABASE | SCHEMA} db_name TO new_db_name;

This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23. It was intended to enable upgrading pre-5.1 databases to use the encoding implemented in 5.1 for mapping database names to database directory names (see Section 8.2.3, “Mapping of Identifiers to File Names”). However, use of this statement could result in loss of database contents, which is why it was removed. Do not use RENAME DATABASE in earlier versions in which it is present.

To perform the task of upgrading database names with the new encoding, use ALTER DATABASE db_name UPGRADE DATA DIRECTORY NAME instead (see Section 12.1.1, “ALTER DATABASE


How do I quickly rename a mysql database (change schema name)?

SkyHi @ Thursday, August 27, 2009
three options:

1) create the new database, bring down the server, move the files from one database folder to the other, and restart the server. note that this will only work if ALL of your tables are myisam.

2) create the new database, use CREATE TABLE ... LIKE statements, then use INSERT ... SELECT * FROM statements.

3) use mysqldump and reload with that file.


3 vote down

the simple way

Change to DB directory:

cd /var/lib/mysql/

Shut down SQL...this is important!

/etc/init.d/mysql stop

Okay,this way doesn't work for InnoDB or BDB-Databases

Rename Database:

mv old-name new-name

...or the table...

cd database/

mv old-name.frm new-name.frm

mv old-name.MYD new-name.MYD

mv old-name.MYI new-name.MYI

Restart MySQL

/etc/init.d/mysql start


OK,this way doesn't work with InnoDB or BDB-DBs. In this case you have to dump the db and re-import it


In MySQL Administrator do the following:

1. Under Catalogs, create a new database schema.
2. Go to Backup and create a backup of the old schema.
3. Execute backup.
4. Go to Restore and open the file created in step 3.
5. Select 'Another Schema' under Target Schema and select the new database schema.
6. Start Restore.
7. Verify new schema and, if it looks good, delete the old one.


mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql


When you rename a database in PHPMyAdmin it creates a dump, then drops and recreates the database with the new name.


Rename multiple tables in MySQL database

SkyHi @ Thursday, August 27, 2009
Having to rename multiple tables with a similar pattern (prefix, suffix, ...) by replacing the recurring pattern, isn't an easy task, because there is no simple function or statement for doing it, not as far as I know.
Renaming tables like 'table_1234' and 'table_3456' to 'new_table_1234' and 'new_table_3456', is pretty straightforward in SQL:

RENAME TABLE `database`.`table_1234`
TO `database`.`new_table_1234`;
RENAME TABLE `database`.`table_3456`
TO `database`.`new_table_3456`;

or in one SQL statement :

`database`.`table_1234` TO `database`.`new_table_1234`,
`database`.`table_3456` TO `database`.`new_table_3456`;

But when renaming a lot of tables, this method becomes tedious and time consuming.

This PHP script automates the renaming of multiple tables in a MySQL database. It lists all tables in a MySQL database, which contain a defined string pattern. The script creates and executes a series of SQL statements, which rename the table by replacing the search pattern in the original table name with another pattern in the new table name.

This script can easily be modified to rename multiple databases, or when stripping the original pattern (f.e. a prefix) and adding a new pattern (f.e. a suffix) is needed.

$db_server = "localhost"; // hostname MySQL server
$db_username = "username"; // username MySQL server
$db_password = "password"; // password MySQL server
$db_name = "database"; // database name

$pattern = "pattern_"; // search string
$new_pattern = "new_pattern_"; // replacement string,
// can be empty

// login to MySQL server
$link = mysql_connect( $db_server, $db_username, $db_password);

if (!$link)
die('Could not connect: ' . mysql_error());

// list all tables in the database containing the search pattern
$sql = "SHOW TABLES FROM `" . $db_name . "`";
$sql .= " LIKE '%" . $pattern . "%'";

$result = mysql_query ( $sql, $link );
if (!$result)
die("Invalid query: " . mysql_error( $link ));

$renamed = 0;
$failed = 0;

while ( $row = mysql_fetch_array ($result) )
// rename every table by replacing the search pattern
// with a new pattern
$table_name = $row[0];
$new_table_name = str_replace ( $pattern, $new_pattern, $table_name);

$sql = "RENAME TABLE `" . $db_name . "`.`" . $table_name . "`";
$sql .= " TO `" . $db_name . "`.`" . $new_table_name . "`";

$result_rename = mysql_query ( $sql, $link );
if ($result_rename)
echo "Table `" . $table_name . "` renamed to :`";
echo $new_table_name . "`.\n";
// notify when the renaming failed and show reason why
echo "Renaming of table `" . $table_name . "` has failed: ";
echo mysql_error( $link ) . "\n";

echo $renamed . " tables were renamed, " . $failed . " failed.\n";

// close connection to MySQL server
mysql_close( $link );


RENAME DATABASE in MySQL 5.1.21 and found it useful I tried it with 5.1.24

SkyHi @ Thursday, August 27, 2009
Dangerous command
Posted by Vadim | Vote on Planet MySQL

Remembering that I did RENAME DATABASE in MySQL 5.1.21 and found it useful I tried it with 5.1.24 (I was playing with 20GB InnoDB database, so dumping is not fastest way) and all my tries finished with “Syntax error”.
So RTMF and documentation says
“This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23.”

For me term ‘dangerous’ is interesting there , as I’d expect really dangerous is DROP DATABASE (which I hope will not be removed in next release) , and RENAME DATABASE is supposed to be kind of safe – just replaces old name to new one.

I guess there are some related bugs – and there are:
Bug#28360: RENAME DATABASE destroys routines
Bug#17565: RENAME DATABASE destroys events
so basically RENAME DATABASE destroyed all events and routines related to database.

And solution of bug is:

Removed the

So it seems MySQL took an interesting practice to get GA released as soon as possible – just remove features that does not work instead of fix it.
The similar was with FEDERATED storage engine, which was disabled by default in 5.1.23 binaries, in contrast to previous version (but should be enabled again in 5.1.24).

That probably helps to get ‘Zero P1 bugs reported’



SkyHi @ Thursday, August 27, 2009
DefaultRoot -- Sets default chroot directory

DefaultRoot [ directory [group-expression]]


DefaultRoot /


server config, ,




0.99.0pl7 and later


The DefaultRoot directive controls the default root directory assigned to a user upon login. If DefaultRoot is set to a directory other than "/", a chroot operation is performed immediately after a client authenticates. This can be used to effectively isolate the client from a portion of the host system filespace. The specified root directory must begin with a / or can be the magic character '~'; meaning that the client is chroot jailed into their home directory.

When the specified chroot directory is a symlink this will be resolved to it's parent first before setting up the chroot. This can have unwanted side effects. For example if a user has write access to the symlink he could modify it so that it points to '/'. Thus the chroot would be the root directory of the server, resulting in insufficient or no restrictions.

If the DefaultRoot directive specifies a directory which disallows access to the logged-in user's home directory, the user's current working directory after login is set to the DefaultRoot instead of their normal home directory. DefaultRoot cannot be used in configuration blocks, as the directive explicitly contains a root directory used for Anonymous logins. The special character '~' is replaced with the authenticating user's home directory immediately after login. Note that the default root may be a subdirectory of the home directory, such as "~/anon-ftp".

The optional group-expression argument can be used to restrict the DefaultRoot directive to a unix group, groups or subset of groups. The expression takes the format: [!]group-name1[,[!]group-name2[,...]]. The expression is parsed in a logical boolean AND fashion, such that each member of the expression must evaluate to logically TRUE in order for the DefaultRoot directive to apply. The special character '!' is used to negate group membership.

Care should be taken when using DefaultRoot. Chroot "jails" should not be used as methods for implementing general system security as there are potentially ways that a user can "escape" the jail.
See also


Example of a DefaultRoot configuration:

ServerName "A test ProFTPD Server"
ServerType inetd
User ftp
Group ftp
# This causes proftpd to perform a chroot into the authenticating user's directory
# immediately after login.
# Once this happens, the user is unable to "see" higher level directories.
# Because a group-expression is included, only users who are a member of
# the group 'users' and NOT a member of 'staff' will have their default
# root directory set to '~'.
DefaultRoot ~ users,!staff


MySQL Rename database

SkyHi @ Thursday, August 27, 2009
Method 1:
RENAME DATABASE old_name TO new_name;

ERROR: You have an error in your SQL syntax; check manual that corresponds to your mysql version for right syntax.

First check whether it supports or not.

Method 2:
you can rename your database in phpMyAdmin by selecting the database you want to edit, then clicking on the "Operations" tab on the top. From here there is an option to "Rename database to:"

I would suggest u copy the database that you are renaming in case something goes haywire

Method 3:
The safest way is to use mysqldump to back up the old database, then restore the dump

Provided that you can shutdown anything which is updating the database (so that there is no chance of anything changing), this is a good solution:

mysql -p

create database new_database;

mysqldump old_database -p | mysql -D new_database -p

It'll dump out the old database to STDOUT, pipe this to a second MySQL process and insert the dumped data (and schema) to the new DB.

You'll have to manually DROP the old DB and change the permissions on the new DB, but at least you have the data and schema.

I find this very useful for creating 'live' backups of databases.

Logwatch bind Zone update refused:

SkyHi @ Thursday, August 27, 2009
Zone update refused: ( 58 Time(s)

Well, it means that a zone update was not authorized.
I would need to know more details though as to whether this was an outbound or inbound zone update.
Normally in a correct bind configuration only the master nameservers of a zone (domain) are authorized to do zone updates. Of course there is dynDNS but I will not go into that here. The there is the zone update that occurs between the Master and its Secondaries by either sending a notify and the Secondaries comparing serial no. for the zone and the update checks depending on the time out value for the secondaries in the zone.
Sometimes people like to inject false DNS information into an unprotected zone to hijack it though!
So what I would need to see is the zone file for that zone in question and the part of the bind log file where it states the error. You can send it through PM if you like and I can then post the solution here to keep information private.