Invalid command 'Header' in htaccess

by cliper Tuesday, February 01, 2011 12:05 PM

You might encounter an error in your /etc/apache2/error.log stating:

 

[Tue Feb 01 00:57:02 2011] [alert] [client 192.168.1.102] /home/cliper/lampen/.htaccess: 
Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

This is because mod_rewrite is not loaded. In my case, I suspected that mod_headers was not enabled.

So in terminal I did

 

a2enmod headers

 

and restart apache2

 

/etc/init.d/apache2 restart

 

For hosted sites, you might contact your system administrator or in your cpanel.

 

System: Debian

Apache ver: 2.2.9 (Debian)

 

...

 

Tags:

Apache 2 | Linux | Tips/Tricks | Web Hosting

Playing with your hosts file /etc/hosts

by cliper Thursday, January 27, 2011 10:36 AM

Last week, I've been playing a lot of my local PC and my development computer. Sometimes we need to replicate everything from server to local. You know what I mean?

Anyways, this is very useful when you have a client abroad and that they gave you an assignment with very limited control. In this post, I'll make an example of a website which has a third-party component which is bought by your client and license is locked-in by domain name.

Now you think that "how the heck I'm supposed to use those components locally?". Answer is "your host file". You ask again, "What is it to do with my host file?". Well, its easy. I don't have time to explain more about the OS host file but know this:

The host file is a system file that will be called by your system whenever you're trying to requests a domain on the internet before a DNS request is requested to your router and router to routers... and in to the root zones. Well, you don't have to know all those stuff. For this post, I'd like to make an example on why this file is important.

First, you have to know some things. For windows, it usually resides in C:\WINDOWS\system32\drivers\etc\hosts. By typing "drivers" in your Start > Run, you will be redirected to C:\WINDOWS\system32\drivers.

For linux, its in /etc/hosts. This file will not appear in windows if you don't have network adapter installed.

So how does it look like? well, it should have an entry something like this:

127.0.0.1       localhost
127.0.0.1 	mpa.one.microsoft.com

for windows and are very identical to linux and most unix systems.

Now, if we're going to add an entry there say mydomain.com with an ip address of our own, all requests to "mydomain.com" will be mapped to that of our own ip address. Whenever any programs like your browser, IM clients, torrents and others will make requests to the internet, it will consult your host file first.

So back to our third-party component. Let's assume we have downloaded all the files for website.com from  your client, all you have to do is make an entry of website.com and put your local ip address with it. So it should look something like this.

127.0.0.1       localhost
127.0.0.1 	mpa.one.microsoft.com
127.0.0.1   website.com

Now, let's try your third-party components if it works. This solution is not applicable to components that are locked by ip address. So don't comment about it. :P

The host file draws many solutions to our problems and are very handy for making hacks like this one. Also, some viruses and trojans are making use of this.

For the sake of others, I'd extend this post to something different. We know that we had the internet crowded with spams nowadays. Commonly happens in the internet wherein we sent e-mails everyday, we receive newsletters everyday, we register to a new website everyday... to name a few. Now we can fall as a victim to this. Now remember this: "make sure you're visiting a website with the proper url in your browser". Remember to read e-mail with caution. Don't read mails you don't know. Make sure you don't get ip address like 12.13.243.24 in your browsers address but you see paypal website. Check your host file regularly. Make sure there's no strange entries like 172.12.33.4    ip1.otherhackergroup.com

That's it for now and please do leave a message if you have something to ask. Thanks!

 

...

 

Tags: ,

Linux

Images don't show up in Magento Product Information Page

by cliper Thursday, January 27, 2011 10:22 AM

Late yesterday, we're working on something we don't expect in magento. Looking into the problem is very frustrating because we really don't have any clue what just happened until we found out that its just a persmission problem.

This might occur to you when you want to move a magento site to other existing instance (site) of magento. If you've been to magento, you know this already. In our case, we manually copied the media folder under the root directory of magento to the target instance of magento. Now, the previous media dir has "cache" folder already since it has been running for a long time now.

This cache folder is created on-the-fly when we tried to visit product information so that when you get back, it will reuse the same pictures together with your active session in the server-side.

Now, what just happened when we transferred the pictures in the target instance using "cp -r" in linux is that it resets the permissions of the folder. So eventually, the web-server and php can't right in it.

So our quick solution is we chowned the folder to its same user of the target folder. in the example it is "user" and a group "www-data". We also chowned the folder to 777 since its not that visible to public and for us to really make sure it is writable for any users.

> chown -R user:www-data cache/
> chmod -R 777 cache/

Anytime you can adjust the permissions like change to 775 or 755. And for this problem, it works and it solved our 24 horurs problem.

 

...

Tags:

Linux | Magento | PHP | Tips/Tricks

Copying Multiple Files using SCP

by cliper Thursday, January 20, 2011 10:43 AM

 

For the rest of my Linux experience, I've been doing a lot of backups. One tool that I can rely on is "scp" (Secure Copy).

Well, I'd recommend this tool when copying files from server or vise-versa.

Here's the how to use it:

 

scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

           [-l limit] [-o ssh_option] [-P port] [-S program]

           [[user@]host1:]file1 ... [[user@]host2:]file2

 

In this snippet, we only need the "user@host1:]file1

There are also popular tools like rsync, wget, or version controls like git, etc... when downloading files, synching projects etc. and I will post about it later.

Anyways, here's my code snippets for scp:

"For this snippets, suppose we have a server named "google-server.com" and we had files named twitter.txt and facebook.txt under /home/cliper/"

Copy (download) multiple files: twitter.txt, facebook.txt from google-server.com

// note, we use brackets together with a back-slash to separate multiple files.
scp user@google-server.com:/home/cliper/\{twitter.txt,facebook.txt\}

 

 

Copy (download) twitter.txt from google-server.com

scp user@google-server.com:/home/cliper/twitter.txt

Uploading files to the server is much like the command above. In the following examples, we have server1.com as our target server and we have a folder /home/cliper/ there. Assumed that we had a Linux box locally when sending the files to server1.com. Now take a look at the difference. So if we have /home/mylocal_linux_pc/file.txt you will do something like..

Upload files to server1.com

 

scp /home/mylocal_linux_pc/file.txt user@server1.com:/home/cliper/

 

 

Tags: ,

Code Snippets | Linux

Backup/Restore mysql databases using mysqldump

by cliper Wednesday, December 08, 2010 12:35 PM

Sometimes we want to have a dump of all our databases in mysql and restore it later to somewhere else or in the same server. here’s how...

In your terminal:

Backup database...

 

mysqldump -uuser -ppassword database_name>database_name.sql

 

where user is your mysql db user, and password. Note: No spaces should be inserted after -u and -p. Specially in -p for password.

To restore database...

 

mysql -uuser -ppassword database_name<database_name.sql

 

while we can do the above command for restoring. We can also do it safely by using the source keyword in mysql.

In terminal, do:

 

mysql -uuser -ppassword

 

 

When in mysql console, execute:

 

USE database_name;
SOURCE database_name.sql;

 

Make sure you change to the path of the file database_name.sql where it resides. Otherwise, you will get an error similar to: Failed to open file 'database_name.sql', error: 2

Also, we can back-up a table instead of the whole db.. you can do:

 

mysqldump -uuser -ppassword database_name table_name>database_name.sql

 

 

and should be able to restore it too.

 

Tags: ,

Code Snippets | Linux | MySQL | Tips/Tricks

About the author

Author's PhotoI enjoy web developing and would like to share my thoughts of it.

Send mailE-mail me

Most comments

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar