Tuesday, January 15, 2013

Install php-mcrypt in CentOS 6

php-mcrypt is not in CentOS's standard repositories.  However, it is in Fedora's EPEL repository.

Install the EPEL Repo:
for 32 bit:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
for 64 bit:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Then you can
yum install php-mcrypt

EPEL also includes php-mbstring if you need that as i did.

Redirect http to https on Apache server (httpd)

After googling http to https redirect, I found several answers that simply did not work (for me).  Finally I came across one that did:

In the directory of your web-content, create the file .htaccess and fill it with these directives:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI}

That's it.

This worked on CentOS 6.3 and Apache 2.2.15

p.s. Don't forget your firewall settings.

Friday, January 11, 2013

Install official VMWare-Tools via yum repository for RedHat and CentOS

Edit: RHEL 7 and CentOS 7 now officially recommends open-vm-tools via their own repository -- i.e. sudo yum -y open-vm-tools , then reboot -- that is all!  If you are still using RHEL/CentOS 5 or 6, then continue below:

(Sources: http://packages.vmware.com/tools/docs/manuals/index.html)

All instructions assuming root or sudo.

Special Note: May have to remove old versions prior to upgrades:
vmware-uninstall-tools.pl  or
rpm -e VmwareTools or
yum remove vmware-tools[-esx] or ..?..

First, add gpg keys for repositories:
wget http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub
wget http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub

Adding the appropriate sources depend on Release-Version and Architecture:

(Tools version can be 4.0latest, 4.1latest, 5.0latest, or 5.1latest)
(Release can be rhel5 or rhel6)
(Architecture can be i386 or x86_64)

***** edit: Thanks to Anonymous (Nov 1 2013), please do not use "*latest" as VMWare now recommends the static url/folder.  Ex: "5.1u3". Find yours by traversing http://packages.vmware.com/tools/esx/ 
***** edit: As of Early 2014, I find "*.latest" is still working with ESXi 5.1 and CentoOS 6.5 -- proceed at your own discretion.

Confirm your distro with cat /etc/redhat-release

Confirm your architecture with uname -m (or -a) (if i686, use i386)

Create the repository file /etc/yum.repos.d/vmware-tools.repo and edit it to contain the following, based on the above confirmations and desired vmware version:
(your baseurl will be http://
(note various examples are commented with #)
name=VMware Tools



Installation for VMWare 4.x tools (option 1 or 2 exclusively):
option 1) 4.x including X11 dependencies:
yum install vmware-tools
option 2) 4.x excluding X11 dependencies (headless):

yum install vmware-tools-nox

Installation for VMWare 5.x tools:
Step 1) Confirm PAE or not (if not PAE, will not see it):
uname -a

Step 2) Install kmods: (option 1 or 2 exclusively)
Option 1) non-pae:
yum install vmware-tools-esx-kmods
Option 2) pae:
yum install vmware-tools-esx-kmods-PAE

Step3) Install tools: (option 1 or 2 exclusively)
Option 1) including X11 dependencies:
yum install vmware-tools-esx
Option 2) excluding X11 dependencies (headless):
yum install vmware-tools-esx-nox

Note, This can be done in one line, but "kmods" must be FIRST
yum install vmware-tools-esx-kmods[-kerneltype] vmware-tools-esx[-nox]
where [-kerneltype] is "-PAE" or nothing and "-nox" or not.

Therefore, this is the no pae, no X (headless) install command:
yum install vmware-tools-esx-kmods vmware-tools-esx-nox


Saturday, January 5, 2013

Open .URL files in Linux

EDIT:  Comments to this post have very nice solutions, honorable mention goes to Trogdor's 3rd post using bash -c "cat %f | grep URL | cut -d'=' -f2 | xargs firefox &" but first place goes to Christian Schmidt for his grep 'URL=' < "$1" | cut -d'=' -f2 | xargs -n1 xdg-open .

That said, here is my original post (which may be worth it just for the gnome association circus):

I've a ton of .URL files, created by drag-and-drop from Mozilla Firefox within MS-Windows.  These files are not automatically usable in Linux, which really sucks.  Googling did provide the solution though, and here I'll share my notes:

Create a script named open-url.sh (i like to store my scripts in ~/scripts/) containing the following:
# opens Windows .URL files in your default browser
# requires: xdg-open sed grep xargs
sed 's/^BASEURL=/URL=/' "$1" | grep -m 1 '^URL=' | sed 's/^URL=//' | sed 's/\r//' | xargs xdg-open

Now make it executable with chmod +x open-url.sh

Now you can associate .URL files with the script.  This might be the hard part, as I did fight with it in gnome; however, XFCE was straight forward.

If you are having particular problems in gnome, my notes report the following:
Duplicate the file /usr/share/applications/firefox.desktop into /usr/share/applications/web-link.desktop, and edit the latter to point to the script you created.

Edit: You may consider using ~/.local/share/applications/ instead. I've found it's easier for gnome to find the new .desktop here.

Edit: be sure to give it an appropriate Name= and GenericName=

Then associate the .URL files with the web-link.desktop file.

Edit: Possibly the best way to associate in gnome3 is right-click the file and "Open Other" choosing the new name you've given with the Name= from the .desktop previously edited. THEN, most importantly, right click the file again, then choose properties, and highlight the new name and click "Set as Default".

Additionally, even though Firefox was my default browser, my environment insisted on opening with Chromium.  I was forced to manipulate the xdg-open command.  Below are commands that may help you: xdg-open
xdg-settings get default-web-browser
xdg-settings set default-web-browser firefox.desktop
There is some chance, you may need to look into gnome-open or gvfs-open.

Edit: You can do OSX .webloc files too with the following script:
# opens OSX .webloc files in your favourite browser
# requires: grep awk xdg-open
# or edit for similar like gnome-open
grep string "$1" | awk -F\> '{print $2}' | awk -F\< '{print $1}' | xargs xdg-open

You may wish to read http://steronius.blogspot.com/search/label/xdg-mime%20default for setting mime-types.

Good luck.