Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I saw some similar posts like this , but it didn't help me at my exact problem. So I am using ubuntu 12.04 on a server with apache2 on it. There are like 5 websites which are Virtualhosts and Namebased running on it (using the same port). Now I need another page whiche REQUIRES a SSL certificate. Is it possible to run just the one page under ssl or do I automatically load everything in it when I configure SSL ?

I know that I have to put the SSL server under Port 443 like this :

<virtualhost *:443>
        SSLEngine On
        SSLCertificateFile /path/to/your/sslcert
        DocumentRoot /path/your/webcontent

Does anyone know and want to explain me, how to setup ssl for just one page?

share|improve this question

When you install Apache it creates a template for a default virtual host, but it also has a default-ssl virtual host. Copy that file and rename it my_secure_site or whatever. Then just change the domain name, the document root, directory, and the ssl key and certificate to the proper values for you site.

Also be sure you have the ssl module enable in Apache a2enmod mod-ssl. ports.conf should have a statement that will make Apache listen on 443 if a virtual domain is using ssl, but if you have a problem check you are listening on 443.

I had an issue where all my hosts were defined <virtualhost> and the when I tried to define the ssl site as <virtualhost>. I got an error like the following.

[Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

To avoid this all your virtual hosts should explicitly define the port <virtualhost>

share|improve this answer
thanks, i just installed certificate and loaded mod and when i now try to reach my page i get an internal error 500 : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. – Private Sep 30 '13 at 13:23
You might need to add/edit some namevirtualhost directives in ports.conf. The regular namevirtualhost (port 80) should include the Ip and port(80) and inside <if module mod_ssl> directive add (or edit) the namevirtualhost directive to include the Ip and port(443) e.g. – dan08 Sep 30 '13 at 13:45
up vote 0 down vote accepted


first of all check your hostname by entering

hostname  (you will need it later)

enable ssl-mod

sudo a2enmod ssl

guide from scratch :

Create folder for ssl certificate and key

sudo mkdir /etc/apache2/ssl 

create .key file and .crt file and after that load both apache2...

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

when you enter all the details for the certificate make sure that you have the same common name as your hostname , otherwise you will get a warning in your apache2 log for not having the right hostname. (not neccessary, but better to avoid this)

your ssl will only run under port 443 so you need to put the listener 443 to ports.conf in your apache dir by adding Listen 443

than create your ssl page under sites-available

sudo nano /etc/apache2/sites-available/ssl

<virtualhost *:443>
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
        DocumentRoot /var/www/yourlink

load the page by sudo a2ensite ssl

sudo service apache2 reload

now it will only SSL secure my yourlink folder.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.