Category Archives: apache

htdocs folders in vista not showing





After reinstalling apache, php in vista I got trouble displaying my htdocs folders on browser. Some were there and some were not. I double checked my apache settings if I missed something but so far I did not. I compared what’s the difference of those folders and found out that the one with .htaccess file in it were not showing. Realizing that, it means something to do with my htaccess file. Checked my httpd.conf settings and I forgot to uncomment this line #LoadModule rewrite_module modules/mod_rewrite.so, so all you need to do is uncomment it and you’re good to go.

TAR command

create:
tar -cvf mystuff.tar mystuff/
tar -czvf mystuff.tgz mystuff/
extracting:
tar -xvf mystuff.tar
tar -xzvf mystuff.tgz
testing/viewing:
tar -tvf mystuff.tar
tar -tzvf mystuff.tgz





Note that .tgz is the same thing as .tar.gz
Tar “tars up” a bunch of files into one “tar-file”
gzip is compression, but only works on one file, so the entire “tarfile” is compressed.

Also when creating a tar or cpio backup, never, never, never use an “absolute” path — you have been warned; also linux tar warns you of this too. The problem is that when you want to unpack, you cannot choose where to unpack to, you will be forced to unpack to the “same” absolute path. When creating a tar or cpio you should change the the appropriate directory and tar from there.

Also when creating a tar or cpio it is general good practice to tar up a directory (appropriately named) which contains your files, rather than just the files. This is good courtesy to anyone unpacking your tarfile.

If you would like to create a tar file while saving ownership and permissions, add the “p” flag.

Creating and saving ownership and permissions:
tar -cpvf mystuff.tar mystuff/
tar -cpzvf mystuff.tgz mystuff/

Also take note of the following commands:
gzip
gunzip
cat
zcat
bzcat
bzip2
bunzip2
zgrep
bzgrep

(cd /mydir && tar -czf – .)|(cd /destdir && tar -xzvf -)
tar -czf – . | ssh user@dest “(cd /destdir && tar -xzvf -)”
(cd /mydir && tar -czf – .) | ssh user@dest “(cd /destdir && tar -xzvf -)”

Errors:
If you receive an error such as the following:

[root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -czvf - linux-2.2.22.tar.bz2)"|tar -xzvf -
user@dest's password:
linux-2.2.22.tar.bz2
linux-2.2.22.tar.bz2

gzip: stdin: decompression OK, trailing garbage ignored
tar: Child returned status 2
tar: Error exit delayed from previous errors
[root@localhost test]#

Then try leaving off the compression as follows:

[root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -cvf - linux-2.2.22.tar.bz2)"|tar -xvf -
user@dest's password:
linux-2.2.22.tar.bz2
linux-2.2.22.tar.bz2
[root@localhost test]# echo $?
0
[root@localhost test]#

Spaces in your filenames?
Having fun with spaces in the filename or directory name? Here’s your answer:

find . -type f -name '*jpg' | grep " " | while read REPLY; do
     tar -cf - "$REPLY" | (cd /tmp/jpg && tar -xvf -)
done

Bonus:

find . -type f | while read REPLY; do
     cp -a "$REPLY" /tmp/jpg/`echo $REPLY \
       | sed -e 's/ //g' -e 's/\///g' -e 's/^\._//'`
done

ssh root@dest 'tar -C / -czf - --exclude ./proc/* --exclude ./dev/pts/* .' > gmaster.tgz
proc and dev was empty for the following command, so I didn't exclude them:
tar -czf - . | ssh user@dest "cat - > k12ltsp.master.tgz"

source: http://roffle.us/blog/archives/13-Linux-TAR-Command.html

url rewriting guide

Introduction to mod_rewrite

The Apache module mod_rewrite is a killer one, i.e. it is a really sophisticated module which provides a powerful way to do URL manipulations. With it you can do nearly all types of URL manipulations you ever dreamed about. The price you have to pay is to accept complexity, because mod_rewrite’s major drawback is that it is not easy to understand and use for the beginner. And even Apache experts sometimes discover new aspects where mod_rewrite can help.

In other words: With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power. This paper tries to give you a few initial success events to avoid the first case by presenting already invented solutions to you.

Practical Solutions

Here come a lot of practical solutions I’ve either invented myself or collected from other peoples solutions in the past. Feel free to learn the black magic of URL rewriting from these examples. ATTENTION: Depending on your server-configuration it can be necessary to slightly change the examples for your situation, e.g. adding the [PT] flag when additionally using mod_alias and mod_userdir, etc. Or rewriting a ruleset to fit in .htaccess context instead of per-server context. Always try to understand what a particular ruleset really does before you use it in order to avoid problems.

Canonical Hostnames

Description:
The goal of this rule is to force the use of a particular hostname, in preference to other hostnames which may be used to reach the same site. For example, if you wish to force the use of www.example.com instead of example.com, you might use a variant of the following recipe.
Solution:
# For sites running on a port other than 80
RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)         http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]

Move Homedirs to Different Webserver

Description:
A lot of webmaster aksed for a solution to the following situation: They wanted to redirect just all homedirs on a webserver to another webserver. They usually need such things when establishing a newer webserver which will replace the old one over time.
Solution:
The solution is trivial with mod_rewrite. On the old webserver we just redirect all /~user/anypath URLs to http://newserver/~user/anypath.

RewriteEngine on
RewriteRule   ^/~(.+)  http://newserver/~$1  [R,L]

source: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

Error installing apache,php on windows vista

I’ve done this before, I’ve installed it several times but how come this time it’s not working with the same settings that needed to be changed… a moment of confusion, annoyance and craziness flashed on my eyes. I’ve exerted every bit of energy left in my body, wasted every precious moment of my time, tried and checked every possible way to no luck at all!!!

What have I done wrong was all I can say. I can’t make Apache 2.2 and PHP 5.2 run on my notebook. A moment of silence…then I realized that whatever changes I’ve made on the php test file was not being reflected on the browser. I then again checked the path on the config files but everything was correct.

Btw, I was using php editor to modify the config files for I have read on some forums that you won’t be able to edit it with notepad in windows vista environment but you can with any php editors. Realizing that, I viewed the files using windows explorer if the changes I’ve made was reflected. Behold it’s not!!! Then I remembered another thing  mentioned on that thread that it’s because of the UAC (User Account Control) setting which you can find in Control Panel => User Accounts. Then right away I  turned it OFF, restarted the computer and re-opened the config files for apache(httpd.conf) and php(php.ini), applied the settings, saved it and problem solved!!! What a nightmare!!!

So first and foremost before installing apache or php always check your operating system if you’re running on windows vista environment which has some user settings that will make you CRAZY!!! :P

You can check the installation guide of apache 2.2, php 5.2 and mysql 5 for windows here. Goodluck! :P

apache error, operation has failed

Upon installing my apache on windows vista environment I encountered this error “…operation has failed.”. Make sure you have the correct path and dll file on you httpd.conf which is in my case located on this path C:\WEB

LoadModule php5_module “C:/WEB/PHP/php5apache2_2.dll”

and if still the problem persists open the apache monitor click on connect, type in or browse your computer name and restart apache.


You can also find here the quick guide on installing apache 2.2, php 5.2 and mysql 5.