Friday, 7 June 2013

Multiple hosted websites are redirecting to only one of my sites on Apache

I had an interesting problem today.

I am attempting to host 3 different web sites on an apache configuration on a raspberry pi. Individually, I can launch each webpage without issue and have the site show up. However, somehow, when I enabled more than one site at a time, each one on different ports, it would show only one site across all ports.

I tried configuring different sites with different ports, changed <Directory> tags to see if my directories were overriding each other, etc.

Most of the data is stored in /var/www/[site-name], so it was only until I tried adding another site at /var/www/[different-site-name] and have it still happen that I knew it was not a path conflict. I fudged with the apache settings for a while to no effect.

A little voice in my head hinted at one of the configuration files I had used a long time ago, the /etc/apache2/conf.d/virtual.conf file. I checked it out, and it had this to say:


NameVirtualServer *


Now, in my website ports.conf file, I specified lines like this:
NameVirtualServer *:80
NameVirtualServer *:8081
NameVirtualServer *:8082

Somehow it clicked. I disabled the /etc/apache2/conf.d/virtual.conf contents by changing the line to this:

# NameVirtualServer *

saved and restarted apache.

Now everything works as configured.

It may seem like a trivial problem, but it cost me a couple hours of my valuable time and I *could not* find a solution on google. Granted, I didn't scour the bowels of the internet for this small problem.

Hopefully this will help others in my position.

(Performed on a Raspbian installation)

Thursday, 25 April 2013

Ubuntu 13.04: First Impressions - fails to install

After going through the livecd process which was smooth and uneventful, when it came to the reboot back into the installed system, all I got was a blinking cursor on a black screen.

This is caused by Grub not being installed properly, for whatever reason.

The solution was for me to mount my filesystem (/dev/sda1 in my case) and use the "grub-install --root-directory=/mount/point/ /dev/sda" command. If I didn't add the --root-directory option, it would fail.

Rebooting again allowed me to log in.

Not impressed Canonical. I'll keep going with this OS for a bit, but when it comes to reliability and usefulness, I stick with Gentoo.

Update:

The problem is with one of the raid packages, as this also occurs on Debian 7 in the same situation. It's not an Ubuntu-specific problem, but upstream. Still, with such a blocker for an install, I don't see how it could have crept through TWO different distribution QA phases.

Wednesday, 27 March 2013

Django: Common Errors, variables not appearing

While it's against the django mindset, I have done a few copy-pastes in my time using this framework.

Recently I've been doing some copy-pasting of some modules and found that often I was getting blank lines when retrieving variables.

The problem was that my text editor was fudging with the tab order of some of the lines-- a huge problem in python-based programs. My Meta class was tabbed forward so it was part of the method, not the class. By de-tabbing it, I was able to see my variables as expected.

Sometimes it's the small things.
If such a scenario exists, a better idea that goes along with the DRY principle would be to create one base Form class with the Meta class and have all other classes inherit it appropriately.

Tuesday, 19 March 2013

Django: Python Unchained

So I've been doing a lot of work with django lately (https://www.djangoproject.com/) and it has been an excellent MVC so far. Python in particular is very powerful and I've had 3+ years of experience with it, as opposed to CakePHP and Ruby on Rails (PHP/Ruby).

However, MVC's are not without their difficulties, even though they do save time and effort. Documentation has always been the #1 issue when using other people's software, and to this day there have only been a couple bits of software I've used with proper docs. Python and KDE are two big names at the top of my head.

I experienced one such django issue for which there wasn't a clear answer to what I was experiencing, and with the interests of newbies in mind, I will document some of those weird django errors in this blog.


Problem: Django is not displaying a view and gives 404 errors, doesn't report URLs that are defined in the urls.py file.

Solution: Every definition of the urlpatterns variable must include a blank string at the start of the tuple parameter you supply.

Wrong:
urlpatterns = patterns(url(r'^index/', index.index),
)

Right: 
urlpatterns = patterns('',
    url(r'^index/', index.index),
)

In hindsight, it would be a simple fix if I knew what pattern() required. I hope this helps at least one other person.

Cheers.


p.s. I *would* like to format code snippets properly, but apparently Blogger is incapable of doing so without some css/javascript tweaking. =/