linux sysadmin, drupal

HowTo Change Hostname in Linux

| Comments

Changing hostnames of linux servers should be easy. I’m sure there are other ways of doing this but here’s what I used most of the time:

To check for current hostname:


Change hostname

hostname new_hostname

Make change permanent on reboot:

  • Debian/Ubuntu: edit or make changes on this file /etc/hostname
  • RHEL/CentOS: edit or make changes on this file /etc/sysconfig/network


Make sure to check or update new hostname in /etc/hosts as some running application could be using hostname values in there. Test running applications as well or try to reload/restart if possible (ex: apache).

Install Varnish on Plesk 11 Server

| Comments

Setup guide for running Varnish on the same server with Plesk 11 on CentOS.

Setup Varnish

Start Varnish install, add vcl file for sites or apps (ex: in my case it’s for Drupal), configure varnish to exclude other sites or domains (ex: if not all sites on plesk server will use varnish), then configure your varnish server (ex: varnish port to 80, storage, apache backend, etc).

  • Install Varnish (for RHEL/CentOS):
rpm --nosignature -i
yum install varnish
  • Add varnish vcl file, default at /etc/varnish/default.vcl
  • If not all sites on plesk will use varnish, create exclude list for vcl receive (sample below).
# Don't cache the following domains
if ( ~ "(www\.)?(domain1|domain2)\.(com)") {
    return (pass);
  • Configure varnish server /etc/sysconfig/varnish to run on port 80. Don’t start Varnish yet since apache still runs on port 80.

Change Apache Port and Update VirtualHosts

Change Apache port from 80 to something else (ex: 8080) in Plesk configuration. Update all the virtualhost configs to use new apache port as well.

  • Backup first the plesk database config.

Install Nagios Varnish Plugin

| Comments

Varnish Nagios plugin can be used to monitor anything varnishstat reports, like uptime, cache_hit/miss, backend connectivity, etc. Refer to varnishstat -l for list of available fields.


  • install varnish devel libraries: yum install varnish-libs-devel or apt-get install libvarnish-dev
  • download varnish nagios plugin files from varnish site and compile source:
tar xzpf varnish-nagios-1.1.tar.gz
cd varnish-nagios-1.1
  • Copy plugin file check_varnish to nagios plugins directory (ex: /usr/lib64/nagios/plugins/)

Drupal CDN Setup for Rackspace CloudFiles Using FileConveyor

| Comments


  • CentOS 6.3 (LAMP stack)
  • Drupal 7
  • CDN Provider: Akamai (via Rackspace CloudFiles)
  • CDN Mode: Origin Push (RS CloudFiles has no support for Origin Pull)
  • FileConveyor

CDN Fileconveyor Install Process:

  • Login to Rackspace account and create cloud files container. Enable public access/CDN support. Adjust TTL if needed, default is 3 days.

    Notice: as of this writing I was having problem running fileconveyor with cloudfile containers in Chicago(ORD), containers in Dallas(DFW) works just fine.

  • Install Pip (just an option of installing fileconveyor, refer to fileconveyor site for additional options):

install python-setuptools
curl -O
  • Install Fileconveyor using Pip
pip install -e git+


| Comments

Had to setup FTPS for clients as they are having problem with SFTP with windows systems (something unsupported in .NET etc). Anyway, here’s a rundown of install/config process.

  • install vsftpd openssl (yum/aptitude/apt-get), most systems will have openssl installed.
  • generate ssl certificate for vsftpd
    • debian: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
    • centos: openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem
  • configure vsftpd for ssl/tls. add/edit the following lines below in addition to exisiting vsftpd config. For new setup, don’t forget to go over vsftpd config and enable/disable options that you need (ex: anonymous login, allow local users, chroot, etc)
    • debian: /etc/vsftpd.conf
    • centos: /etc/vsftpd/vsftpd.conf

Migrate MySQL Databases, Users, and Privileges to Different Server

| Comments

Here’s one way to migrate MySQL databases, users, and privileges to other server. Example commands below uses mysql root user.

1.) Databases:

  • Get list of databases
mysql -uroot -proot_password -e "show databases"
  • Dump all databases
mysqldump -uroot -proot_password --all-databases > databases.sql

Note: you can dump only the databases that you want to move. Also, you need to exclude the “mysql” database itself if you are moving into an mysql server with existing records.

MacOS: ERROR the Provided CC(/usr/bin/gcc) Is LLVM Based, It Is Not Yet Fully Supported

| Comments


The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

I got this error when installing ruby (1.9.2) on my fresh install Mountain Lion.  Looking at some references online, this looks like an issue with the compiler used in mac os (lion and mountain lion), as they switched to (LLVM) Clang compilers.

Work-around I found for my ruby installation is to specify the compiler to use during the installation (clang), change the default GCC to Clang.


rvm install ruby-1.9.2 --with-gcc=clang

Also, make sure you have the following installed and up to date for ruby install:

  • xcode with “Command Line Tools” components

  • rvm

Note:  This could also be the case with other packages compiled/installed from source.

Mysqldump Without Create Table Statements

| Comments

Can’t remember why I needed this before but here’s my note so I can remember it the next time. I only need to add “-n” and “-t” to my mysqldump statements.

-t, –no-create-info

  • Don’t write table creation info.

-n, –no-create-db

  • Suppress the CREATE DATABASE … IF EXISTS statement that normally is output for each dumped database if –all-databases or –databases is given.


mysqldump -udbuser -ppasswd -Q -n -t > database_dump.sql

Obviously, I don’t like to spend a minute to read the “–help” or “-h”, unless I have to. :)