dimitris kalamaras

mathematics, social network analysis, free software…

Month: July 2010

How to replace a given string inside a mysql table?

Just use the fabulous command REPLACE provided by mysql. The syntax goes like this:

update database_table set table_column = replace (table_column, "oldstring", "newstring");

For instance, to replace all occurrences of “modules” inside the linuxformat.gr drupal db with “sites/all/modules” I typed in:

update linuxformat_system set filename = replace (filename, "modules", "sites/all/modules");

Name-based Virtual Hosts in Apache

Name-based virtual hosting enables us to serve different domains from a single server. All we need is to add this line to /etc/apache2/sites-available/default:

NameVirtualHost *

The * specifies that Apache will serve requests for all IP addresses; optionally we can specify only a certain IP on the server.

Next, we create a new for each different domain we want to serve.

This can be done either by adding a few lines inside /etc/apache2/sites-available/default

<VirtualHost *>
    ServerName www.lxf.gr
    ServerAlias lxf.org
    DocumentRoot /media/oxy/www/lxf
</VirtualHost>

or by creating a new file (i.e. lxf.gr) inside /etc/apache2/sites-available

<VirtualHost *>
 ServerAdmin [email protected]
 ServerName lxf.gr
 ServerAlias lxf.gr
 DocumentRoot /media/oxy/www/lxf
 <Directory /media/oxy/www/lxf>
  Options Indexes FollowSymLinks
  Options -MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
 </Directory>
 CustomLog /var/log/apache2/lxf-access.log combined
 ServerSignature On
</VirtualHost>

and symlinking it to /etc/apache2/sites-enabled:

sudo ln -s /etc/apache2/sites-available/lxf  /etc/apache2/sites-enabled/

Technorati Tags: ,

Powered by WordPress & Theme by Anders Norén