FTP Trick – Using wget to Download a FTP Directory Recursively

Hello Guys,

 

If you are stuck in downloading an FTP directory recursively, You can use the following FTP Trick Using wget to Download FTP Directory Recursively. It’s Very Simple to use.

You would need to do this via SSH console. Just login to your SSH server and then execute the below wget command.

wget -r --user username --password password --passive-ftp ftp://xx.xx.xx.xx//home/XYZ/public_html/

Where xx.xx.xx.xx is the IP address of your FTP server and you have to provide the username/passwords as the arguments as shown above.

Some FTP servers allow only passive-mode transfers, To enable the passive mode we should use –passive-ftp flag

 

Hope this helps. If you have other methods, you can post them in the below comment Box :)

How to Fix PHP/MySQL Issue – Special Characters shown as Question Marks

Recently i migrated a LAMP server and the application code was having Japanese/Chinese characters.

After the migration process we faced issues, Special Characters were not rendering properly instead they were appearing as question marks.

I then applied the following mysql configuration change to /etc/mysql/my.cnf under [mysqld] section and my issue got fixed :)

[mysqld]
character_set_server           = utf8
collation-server               = utf8_unicode_ci
skip-character-set-client-handshake

Please note that a Restart of mysql is required after the change. Hope this helps.

Let me know if any troubles.

Apache : Rewrite Rule to redirect based on Cookie Value

Sometimes we require to redirect a specific page based on the cookie value defined.
You can use the following rewrite rules to achieve this.

 

RewriteEngine on
RewriteCond %{HTTP_COOKIE} cookie=([a-zA-Z]+)
RewriteRule .* http://mydomain.com/NEW-LOCATION/%1 [R=301,L]

Here the value of cookie can be any value like age,name,etc.

How to Use RedirectMatch to redirect everything except folder

301-redirect

The following htaccess line of code shows you How to Use RedirectMatch to redirect everything except folder.

In my example i am redirecting everything to new domain except the /blog/ folder.

RedirectMatch 301 ^/(?!blog/)(.*)$ http://NEW.domain.com/$1

That’s it. You will see that everything gets redirected to http://NEW.domain.com/ except /blog/ paths.

Please post if you know of any other methods.

How to Install and Configure OBTVSE2 on Ubuntu

OBTVSE2 is a clean and simple markdown blogging platform on Rails. Installing OBTVS2 on Ubuntu is quite easier if you have basic Linux Admin skills.

I followed the below steps to setup OBTVSE2 on Ubuntu Server

1. We need to create a Normal SSH user with sudo priviliges called obtv using the below commands and login to that user shell

#useradd -m obtv -s /bin/bash -g sudo
--Assign a password to this user
#passwd obtv
Login as obtv user now and you should be under /home/obtv directory

2. OBTVSE2 requires Ruby, So We need to setup the Ruby environment , Follow the steps below

 

#curl -L https://get.rvm.io | bash -s stable --rails
#source ~/.rvm/scripts/rvm
#rvm install ruby-2.0.0-p481
#rails new Sites

This will setup the ruby project under /home/obtv/Sites/

3. Now we will download the obtvse2 inside “Sites” folder

#cd Sites/
#git clone git://github.com/natew/obtvse2.git
#cd obtvse2
#gem install debugger
#bundle install
#rake db:migrate

4. obtvse2 requires a runtime server, For this we will install a node.js server

#apt-get install libpq-dev nodejs

5. Now we will start the OBTVSE2 application on some port say 3000. We will start this server inside a screen so it will be running even if you logout
From root user login, create a screen

#screen -S obtvse2-blog

Now under the screen start the application on port 3000 with user obtv

Edit /home/obtv/Sites/obtvse2/config/info.yml to fill in your personal and site information.

#su - obtv
#cd Sites/obtvse2
#bundle exec rails s

This will start your obtvse2 application on port 3000
After executing above commands, Press ctrl+D to leave the screen active and exit.

6. Now we have to Configure Apache so that your site blog.domain.com connects to the back-end OBTVSE2 application.

Create a virtual host and configuration should look like below

ServerName blog.domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
<Directory /var/www/html>
Options -Indexes
DirectoryIndex index.html index.php
AllowOverride All

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

7. After this just enable this Apache virtual host, reload your apache server and access the obtvse2 application at http://blog.domain.com

If you have any difficulty with the setup, Feel free to ask.

Optimized SSL paramaters for Nginx utilizing SPDY

You can use the following Nginx SSL configuration for optimal performance on your SSL based sites running Nginx web server.

 

listen 443 spdy;
server_name domain.com www.domain.com;
ssl on;
ssl_certificate           /etc/nginx/ssl/SSL.crt;
ssl_certificate_key       /etc/nginx/ssl/SSL.key;

ssl_session_cache  builtin:1000  shared:SSL:10m;
ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

 

Useful JVM Parameters for Troubleshooting Adobe CQ5 performance

We often face the performance issues on our CQ5 servers which may be related to high memory or CPU utilization issues.

Below are some Useful JVM Parameters for debugging Adobe CQ5 performance.

-XX:+HeapDumpOnOutOfMemoryError — write an heapdump if the JVM runs out of heap space
    -XX:+HeapDumpOnCtrlBreak — on windows create an heapdump when pressing ctrl+break
    -verbose:gc — verbose garbage collection logging
    -XX:+PrintGCTimeStamps — print timestamps in the GC log
    -XX:+PrintGCDetails — even more GC information
    -Xloggc:gc.log — write the GC logs to this file and not to stdout
    -XX:+UseGCLogFileRoatation (since Java 6u32 or Java 7u2) — enable GC log rotation
    -XX:+NumberOfGCLogFiles=10 (since Java 6u32 or Java 7u2) — and keep 10 versions of that GC log

How to Disable mod_security for a specific domain in Apache

mod_security is a great tool to protect your Apache web server from the internet attacks like XSS, SQL injection attacks etc.

However sometimes if you would like to disable mod_security rules for a virtual host,

You can simply do this by adding the below code to your Virtual host configuration in your Apache. Adding SecRuleEngine Off will instruct your apache to NOT apply mod_security rules to this Virtual Host.

Here is an example of a simple virtual host configuration

 

<VirtualHost *:80>
ServerName xyz.com
DocumentRoot /var/www/html
SecRuleEngine Off
</VirtualHost *:80>