DKIM DomainKeys for additional domains
I will assume that you are using ‘iredmail’ and need to configure an additional domain (example.com) for your mail server.
1) First generate a new key for your domain under ‘amavisd‘:
amavisd genrsa /var/lib/dkim/example.com.pem
chmod 0644 /var/lib/dkim/example.com.pem
2) Open up the ‘amavisd.conf’ file (will be present at ‘/etc/amavisd/amavisd.conf’ most probably) and add the following path for the key you just created above:
# Add dkim_key here."
dkim_key("example.com", "dkim", "/var/lib/dkim/example.com.pem");
3) Add your new domain to ‘@local_domains_map’ entry in ‘amavisd. conf’ file, something like:
@local_domains_maps = ( [".$mydomain", "yourexistingdomain.com", "example.com"] ); # list of all local domains
4) Restart amavisd:
/etc/init.d/amavisd restart
5) Time to update the key to your DNS:
a) Look for the key you just installed:
amavisd -c /etc/amavisd/amavisd.conf showkeys example.com
b) It should look something like this:
; key#1, domain xyz.com, /var/lib/dkim/xyz.com.pem dkim._domainkey.example.com. 3600 TXT ( "v=DKIM1; p=" "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEzgjyG2It0ZdQQTgGNj2jNDKe" "fsa978sd98fsd9vds97FHv9fHIUSAY(#@*oiu7cs98a9" "a*@#&($*#@U9ujw9ffljhljoU(ewur0932870932" "jvAe33lH9tiVljog1QYSUDOEAaads")
c) Add the dkim domainkey to your DNS zone file. Just copy the output above to the zone file.
d) Make sure to update a correct SPF entry also.
"v=spf1 ip4:server_IP_address_here -all"
e) Restart ‘named’ service:
/etc/init.d/named restart
EOF
Related articles
Applying a PHP Patch over Windows
If you need to apply a PHP patch (basically a PHP patch file) using Windows O.S, follow the steps below:
Here:
a) Download the patch file provided by the concerned developer. (say phppatch.txt)
b) Download GNU patch files (patch-2.5.9-7-bin.zip) from the link below:
https://www.dropbox.com/s/atmornybkosgzi7/patch-2.5.9-7- bin.zip
c) Download the ‘batch’ script from the following link:
https://www.dropbox.com/s/nunpw39cwubh2xt/patch.bat
d) Extract the archive ‘patch-2.5.9-7-bin.zip’.
e) Copy the batch script (patch.bat) to ‘bin’ folder present at ‘patch-2.5.9-7-bin’.
f) Copy the PHP patch file ‘phppatch.txt’ to ‘bin’ folder present in ‘patch-2.5.9-7-bin’.
g) Edit the batch script ‘patch.bat’ and add the path of ‘helpdesk document root’ and the path of ‘PHP patch file’. I have added sample entries, so just replace those with actual path.
h) Execute ‘patch.bat’ (Run as Administrator) and wait till the patch is applied.
That’s all.
Changing SWAP memory & performance tweaking
If you ever required to change the memory allocated to SWAP on run-time or just want to define SWAP for the first time (say you forgot while configuring the server), use the steps below:
I will assume your server RAM is 1Gb, so will define SWAP as 2Gb:
a) dd if=/dev/zero of=/swap bs=1024 count=2097152
b) mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap
c) echo /swap swap swap defaults 0 0 >> /etc/fstab
d) echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p
NOTE: Keep vm.swappiness as low as you can. Keeping the value of swappiness will probably improve overall performance for a typical Linux server.
vm.swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible.
vm.swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache.
Related articles
WordPress custom permalinks and Nginx
Enabling custom permalinks on WordPress with Nginx is bit tricky but easy. If you are using Apache with ‘mod_rewrite‘ enabled, WordPress will automatically add the the rewrite rules to your ‘.htaccess file’.
But, with Nginx you need to define the rewrite rules as well as add the ‘try_files’ directive to the Nginx configuration file for your domain/website. Otherwise, if you have enabled the custom permalinks on WordPress and you are using Nginx, then clicking the post URL will return a page with ‘404 Error‘.
So, below is the procedure, rewrite rules and the directive you need to define for Nginx & WordPress:
1) First, you need to enable the ‘custom permalink’ for your WordPress site from ‘Dashboard > Settings > Permalinks > Choose Custom Structure’
2) Next, create a ‘.htaccess’ file in your web sites’ document root with the following content and if the file already exists, just add the rewrite rule:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
3) Now, you need to define the ‘try_files’ directive in the Nginx configuration file for your web site.
a) Open the configuration file present at ‘/etc/nginx/sites-enabled/yoursite.conf’ or ‘/etc/nginx/conf.d/default.conf’
b) Then add the following lines under the location / block:
try_files $uri $uri/ /index.php?$args;
c) It should look like:
location / {
root /var/www/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
4) Restart/reload the Nginx:
service nginx restart or nginx -s reload
5) And you are done !
While executing an XMPP Python script (which I had created over the past), following warning was received:
Could not load one of the supported DNS libraries (dnspython or pydns)
I was pretty unsure that why it happened, as earlier the script was working all fine. So, a bit of brainstorming made me conclude that my Python script was asking for a DNS zone transfer and the script was terminating prematurely.
Then I came across ‘dnspython’, a DNS tool-kit for Python. It supports almost all record types and can be used for queries, zone transfers, and dynamic updates. ‘dnspython’ provides both high and low level access to DNS.
Time to get ‘dnspython’ installed (So that my script should get back on track):
1) Download ‘dnspython-1.10.0′, here’s a direct link:
2) Unzip the package:
[root@gettechgo ~]# unzip dnspython-1.10.0.zip Archive: dnspython-1.10.0.zip inflating: dnspython-1.10.0/ChangeLog inflating: dnspython-1.10.0/LICENSE . . . inflating: dnspython-1.10.0/tests/update.py inflating: dnspython-1.10.0/tests/zone.py
3) Jump to the newly created directory ‘dnspython-1.10.0′.
[root@gettechgo ~]# cd dnspython-1.10.0
4) Install the Toolkit:
[root@gettechgo dnspython-1.10.0]# python setup.py install running install running build running build_py creating build creating build/lib creating build/lib/dns copying dns/edns.py -> build/lib/dns . . . byte-compiling /usr/local/lib/python2.7/site-packages/dns/set.py to set.pyc running install_egg_info Writing /usr/local/lib/python2.7/site-packages/dnspython-1.10.0-py2.7.egg-info
Mission accomplished, Zone transfer (TCP) for client–server transactions, back on track !
Migrating Git Repository
If you are thinking about migrating a Git directory from an existing machine (i.e, the one from which you make commits to your repository) to another machine. Then I believe, this post could be a great help.
There is a folder named ‘.git’, which is created the moment you initialize the git repository under a folder. This folder contains the information about ‘origin’, ‘trunk’, etc. Or in simple words, the information about your ‘Git’ repository.
So, lets start with the directory migration, I will explain using a test scenario.
Test parameters:
1) Two machines (abc & xyz) and corresponding ‘Git’ user accounts, ‘gituser@abc’ & ‘gituser@xyz’.
2) A ‘Git’ directory that is required to be migrated: my_git_folder
Procedure:
1) Copy all the contents of ‘/home/gituser/my_git_folder’ present at ‘abc’ machine to ‘/home/gituser/my_git_folder’ present at ‘xyz’ machine.
2) To allow the ‘user’ which is present at other machine (gituser@xyz), make commits to your git repository, you need to create an SSH-key pair and then add the public key (id_rsa.pub) to your account at Github (Account Settings > SSH Keys)
[gituser@xyz]# ssh-keygen -t rsa -C "your_git_emailid@youremail.com" Generating public/private rsa key pair. Enter file in which to save the key (/home/gituser/.ssh/id_rsa):[Press Enter] Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again] Your identification has been saved in /home/gituser/.ssh/id_rsa. Your public key has been saved in /home/gituser/.ssh/id_rsa.pub. The key fingerprint is: 05:0e:44:gb:ca:55:f6:7d:61:7f:f1:95:9f:f0:22:99 your_git_emailid@youremail.com
NOTE: Please make sure that the folder ‘/home/gituser/.ssh’ and a file ‘/home/gituser/.ssh/authorized_keys’ is already present. If not, create them and then proceed with creating the SSH key-pair.
3) Add the public key (/home/gituser/.ssh/id_rsa.pub) to your Git account. (Account Settings > SSH Keys)
4) Test the connection:
[gituser@xyz]# ssh -T git@github.com The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 05:0e:44:gb:ca:55:f6:7d:61:7f:f1:95:9f:f0:22:99. Are you sure you want to continue connecting (yes/no)? [Type yes] Hi username! You've successfully authenticated, but GitHub does not provide shell access.
By now, your new machine has the authentication to commit to your Git repository.
But, to make the commits you need to tell Github that it is you using the new machine and trying to commit !
5) So, while pushing some new data to your repository from your new machine, you would be trying something like:
[gituser@xyz my_git_folder]# git init [gituser@xyz my_git_folder]# git add the_contents [gituser@xyz my_git_folder]# git commit -a #Save the file with a commit identification. [gituser@xyz my_git_folder]# git push origin master
Here above, you will be prompted to identify your self:
*** Please tell me who you are.
6) Run the following commands:
[gituser@xyz my_git_folder]# git config --global user.email "your_git_email_id@youremail"
[gituser@xyz my_git_folder]# git config --global user.name "Your Name"
7) Now again, try to push:
[gituser@xyz my_git_folder]# git push origin master
You will see output, something like:
Counting objects: 7, done. Delta compression using up to 2 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (7/7), done. total 7 (delta 1), reused 0 (delta 0)
Deal done !
Related articles
SetupTools for Python
‘setuptools’, it is a Python-tool or module that helps to build, compile, distribute, upgrade, install and un-install Python packages easily by wrapping them into “egg”s. Eggs contain additional information to process dependencies, etc.
So, while installing a Python sub module or executing a Python script, if you encounter something like:
ImportError: No module named setuptools
Then, it is understood that you need to install corresponding ‘setuptools’ for your Python distribution.
In my case, I installed ‘setuptools’ as follows (python 2.4):
$ wget "http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg#md5=bd639f9b0eac4c42497034dec2ec0c2b" $ sh setuptools-0.6c11-py2.4.egg
Below is a snip from the process output:
Saving to: `setuptools-0.6c11-py2.4.egg' 100%[=============================================================>] 337,658 118K/s in 2.8s 2013-01-19 13:46:38 (118 KB/s) - `setuptools-0.6c11-py2.4.egg' saved [337658/337658]Processing setuptools-0.6c11-py2.4.egg creating /usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg Extracting setuptools-0.6c11-py2.4.egg to /usr/lib/python2.4/site-packages Adding setuptools 0.6c11 to easy-install.pth file Installing easy_install script to /usr/bin Installing easy_install-2.4 script to /usr/bin
NOTE: Use the right version of ‘setuptools’ for your distribution.
Available at: setuptools-Downloads
Related articles
Bitten by Python
I got a python bite, and didn’t sleep that night…
People! Nothing to worry about, I am talking about the programming language Python, which doesn’t allow me to sleep at nights, due to its extensively addicting functionalities that make me dig more and more.
Well, I am much more familiar and comfortable writing Shell scripts, as I enjoy shell programming. But, a few days back, I got myself occupied with configuring Python on my machine (you might have noticed, that I didn’t spammed your mailbox with my post-notification emails, past two days)
So, what I am up with ! is an XMPP (ejabber) client for your Linux machines, with which you can control your machine/server remotely, as if you are chatting with your buddies over Pidgin, Pandion or Gtalk.
To begin with, I used the Python-XMPP library as an API to handle the XML streams between client and the server.
Now, first let me impart a little bit of XMPP to your brains:
XMPP or formerly known as ‘jabber protocol’ is an XML based open standards protocol in which XML streams are used handle the message communication.
XMPP stands for: Extensible Messaging and Presence Protocol
The Python-XMPP module:
I believe Python is such a strong programming language, as its standard library & extensions provides you immense functionality to play around.
So, to code the client, I needed some inbuilt functions and libraries, and XMPP module for Python, indeed satisfied my hunger.
Now, let’s see How to install XMPP module for Python:
1) Get the package, a bit Googling! or if you are lazy enough, use the direct download link below:
wget "http://ge.tt/api/1/files/9LQK5WV/0/blob?download"
2) Installing the XMPP module:
tar -xvzf xmpppy-0.5.0rc1.tar.gz cd xmpppy-0.5.0rc1.tar.gz python setup.py install
3) If the systems prompts you to install ‘SetupTools‘ for Python, then you can download the corresponding Python egg for your Python installation, from the link below:
http://pypi.python.org/pypi/setuptools#downloads
Installing the Python Egg:
Python egg can be installed by executing the egg, just like a shell script:
sh setuptools-0.6c9-py2.4.egg
And you are done!
We have the XMPP module set-up for our Python installation, now you just need to brainstorm, for creating a script which makes your client/machine live. (You can refer the snapshot below, to see for your selves, how it works!)
Here are some useful functions:
import xmpp #Used to call xmpp within python. Basically, the first line of your code jid = xmpp.JID(user) #This will define the XMPP identification for the 'user' (an email address contained in a variable) connection = xmpp.Client(server) #Handles the client connection to the 'server'. Again, 'server' is an hostname contained in a variable. connection.connect() #Using connect() function to initiate the 'connection' defined above. authentication = connection.auth(jid.getNode(), password,"Client's-Name") #Dispatch the iq Stanza or say the account details and bind the machine to the server with an ID.
Check out the result when I combined everything (though added a lot of things), observe the snapshot carefully (Click to enlarge):
Ubuntu goes ‘Mobile’ (Ubuntu for phones & Android devices)
Canonical or the organization behind Ubuntu, is spreading its wings towards a better ‘Mobile Computing’. The reason why I said ‘Mobile Computing’, is that, sooner or later we would be using our smartphones to do whatever we do over our personal computers or laptops.
And that, would be possible with the ‘Ubuntu for phones and Android devices’, which will eventually port the same ‘Ubuntu’ that we use over our Desktops or Laptops to a mobile phone.
Basically, Canonical’s motive is to bring technology revolution, where every single computing device shares a common platform, and that would be ‘UBUNTU’.
Now, whether you are using a smartphone, a company workstation , a personal computer or a laptop, all would be running the same O.S and I think, how easy it would be for us to manage a whole lot of things, like a programmer/professional would just need to plug-in his/her phone to a screen and the power of an PC is just right there in his/her hands. The same goes for home-computing, when there would be no more compatibility issues between devices to share a lot of stuff, like music, pictures, videos & almost everything !
Related articles
How to configure PHPmail()
PHPmail(), it is the inbuilt PHP mailer, which can be used to route the emails from a PHP script.
Once you have PHP installed at your server, you need to make the required changes in the PHP configuration file ‘php.ini’ to send out the emails.
In case, you are using Unix O.S, ‘php.ini’ would be present at ‘/etc/php.ini/’ or ‘/usr/lib/’ and for Windows O.S, the path would be the directory in which you have installed PHP:
Say, “c:\Program Files\PHP\php.ini”
Coming back to the configuration, I hope you must have located the ‘php.ini’ file by now.
Open that file and configure the PHP mail() as follows:
1) Search for the line with [mail function] tag.
You will encounter the lines similar to those listed below :
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = postmaster@localhost; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
2) For UNIX O.S, you need to specify the sendmail_path as below (Sendmail must be configured):
sendmail_path = /usr/sbin/sendmail
3) For Windows systems, you need to specify the SMTP server details (Hostname, port) as follows:
SMTP = mail.smtpserver.net (This is just an example, you need to use your SMTP server host-name) ; "You can leave this to 'localhost' if you have an SMTP server configured locally. smtp_port = 25 (Use '465' for an SSL connection)
4) You can also set a default from address for the every out bound email from your server by initializing the variable sendmail_from as follows:
sendmail_from = thisisme@mydomain.com



















