Archive for April, 2010

Weird characters instead of latin!!

Tuesday, April 20th, 2010

Well I’m moving from a home server to a virtual dedicated server.

It’s been hours of configurations and moving databases, files and stuff but I’m almost done. Almost all my test sites are up and running. A couple of minutes ago I uploaded a site that uses a lot of latin characters like ñ and accents. I wasn’t worried because I had my meta tags ‘properly’ set.

To my surprise once the site was up and I opened the URL it was showing weird characters instead of the latin characters!!!

Why?! My meta tags are correct! What could be wrong?

So I went back and started reviewing the web server conf file… I remembered that there was a conf variable I had to set for my metas to work… finally I got to this lines:

# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8
Ok so this is the conf variable I was searching. As always I didn’t read the commented words and put ISO-8859-1 instead of UTF-8. Some sites were OK but others went ahead with the weird characters!!!
I went back to editing the conf file but this time I took the time to read the comment. BINGO!
If this variable is set then the server will overwrite the meta define value of my web page which in this case was:
meta http-equiv=”Content-Typecontent=”text/html; charset=ISO-8859-1
So what I did was comment that line out and now my web server does check for the proper meta.
Great!!!!

Setting up https with Apache

Wednesday, April 14th, 2010

Been months since I wanted to do this.

I always thought that setting up https with Apache was very complicated. Specially because of the certificates.

For the last couple of days I’ve been working on setting up a linux server. It would be used for hosting a couple of pages so I need it to have the basic functionality like smtp, pop, imap, http and ssh as well as a couple of other things like memcached.

I had set up httpd before but honestly never https because I thought it was very difficult but it isn’t!!!

Things are really really simple, follow these simple steps once you have httpd running:

1.Install mod_ssl for apache

yum install mod_ssl

2.Restart httpd

service httpd restart

Now you have https available with a default certificate! so the next step would be creating your own certificate

3. Run the following command

openssl req $@ -new -x509 -days 365 -nodes -out /var/www/html/certs/mycert.pem -keyout /var/www/html/certs/mycert.pem

Remeber to change the path to your certificate or copy it later to the httpd certificate’s path.

You’ll be asked for some info.

4. Open ssl.conf (In my case, I have a Centos 5 distro, it’s the following path: /etc/httpd/conf.d/ssl.conf) and search for the following line:

SSLCertificateFile /etc/pki/tls/certs/localhost.crt

Replace the path with your own certificate’s path.

Comment the following line:

SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

5.Now restart httpd

Done! you have https running on port 443 with your own certificate.

Remember the certificate is valid for your site but since it’s not registered with an authority browsers will keep sending a warning.