Confused Development

I develop software and I often get confused in the process. I usually find the answers after a while, but a month later I can't remember them. So from now on, I will write them down here.

Tuesday, October 13, 2009

Reverse Proxy to Make SPARQL Endpoint Available on Nice URI

When you set up an RDF repository such as Sesame2, you are likely to get a SPARQL endpoint at a URI such as http://my.server.org:8080/openrdf-sesame/repositories/repname. That's ok, but it doesn't look very nice. In order to serve the same endpoint at a nicer URI, say http://my.server.org/sparql, you can set up something called a reverse proxy on your Apache server. Here is how to do it on Debian:

Add the Reverse Proxy Rule

In /etc/apache2/conf.d, add a new configuration file sparql.conf. Make it look like this:

# Make the SPARQL endpoint of the Sesame server running on port 8080
# available as http://my.server.org/sparql.
#
# Configuration is done as per the Basic Example for Reverse Proxies
# in http://httpd.apache.org/docs/2.2/mod/mod_proxy.html .

<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>
ProxyPass /sparql http://my.server.org:8080/openrdf-sesame/repositories/repname
ProxyPassReverse /sparql http://my.server.org:8080/openrdf-sesame/repositories/repname

Enable the Proxy Modules

In order for this to work, Apache has to load a number of modules having to do with proxies. The easiest and safest way to load them is by using the a2enmod command and select all proxy-related modules:

knumoe@exp3:/etc/apache2/conf.d$ sudo a2enmod
Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta cgi cgid charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dump_io env expires ext_filter file_cache filter headers ident imagemap include info ldap log_forensic mem_cache mime mime_magic negotiation php5 proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http rewrite setenvif speling ssl status substitute suexec unique_id userdir usertrack version vhost_alias
Which module(s) do you want to enable (wildcards ok)?
proxy*

Restart Apache

sudo /etc/init.d/apache2 restart

Labels: , , , ,

Monday, June 15, 2009

WordPress Blank Screen of Death

I'm using subversion to keep my WordPress installation updated. This always worked perfectly fine, but recently I did an update and wasn't able to access any php driven part of the blog anymore (so, basically everything). All I would get is the dreaded WordPress Blank Screen of Death.

I looked in the error logs (WP had a special error log in the Apache log folder) and saw that there was a Parse Error: parse error, unexpected T_SL reported for one of the php files. After some googling, this post here made me realise that the problem could be related to a subversion conflict, which will lead to < signs showing up in the source files, rendering them invalid. I checked the offending files and really, it turned out that my last svn update had introduced a conflict. To resolve it, I simply deleted the offending files, executed svn update again, and all my troubles were gone!

Labels: , , ,

Tuesday, August 26, 2008

Let Regular Web Sites Coexist with a CMS like Drupal

I have a server setup where I want Drupal (could be any other CMS, though) to be served from the document root. I.e., I don't want a URL like http://my.server/drupal/interesting-page, but instead I want http://my.server/interesting-page. This is easy to achieve in Apache2: I simply have to set the document root to the Drupal folder. Here is an example from an Apache2 configuration file:

  <VirtualHost *>
  ...
  DocumentRoot /var/www/drupal
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/drupal>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
  </Directory>
  ...
  </VirtualHost>

Another requirement I have is that certain folders should be served alongside Drupal. E.g., let's assume I have a folder called dumps, which I want to serve at http://my.server/dumps. Now, I could of course just put it into the drupal folder at /var/www/drupal/dumps. However, I would like the drupal folder to only contain drupal stuff. Otherwise things might get messy when I do updates, etc. This is where the Alias directive in Apache's mod_alias module comes in handy. I can put dumps at /var/www/dumps and then map requests to http://my.server/dumps to that folder. Here is what that looks like in my Virtual Host definition (including some settings for how to handle that folder):

Alias /dumps "/var/www/dumps"
<Directory "/var/www/dumps">
  Options Indexes MultiViews
  AllowOverride None
  Order deny,allow
  Allow from all
</Directory>

Labels: ,

Wednesday, August 20, 2008

Installing Drupal6.4 on Debian4 + Apache2

I had to install Drupal today on one of our servers. I ran into a few minor problems:

  • There were some problems with file permissions in the drupal/sites folder, so I changed owner and group of some files and folders to www-data.
  • Drupal complained that the PHP GD library is not installed: just run apt-get install php5-gd and restart Apache.
  • Drupal couldn't send mails, so I installed postfix (sudo apt-get install postfix), set the server for outgoing mail (here called the "smart server") to our institute's smtp server, and used mailx to test it.

Labels: , , ,