I've just done this on Ubuntu 14 (for the first time today, so there may be a better way!) by setting
$wgServer = "//myhostname.com/mediawiki";
This makes the server name "protocol relative" so it works with either HTTP or HTTPS. You can probably just set it to https://... though.
Then configure apache2 to redirect all HTTP traffic to HTTPS:
Edit the default SSL configuration (this assumes you are just using the default site):
sudo vim /etc/apache2/sites-available/default-ssl.conf
to read something like:
# Redirect HTTP to HTTPS
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
# Normal HTTPS config for default site
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the default SSL site, if you haven't already (this creates a link from sites-enabled to sites-available)
sudo a2ensite default-ssl
This assumes that you have already obtained an SSL certificate (I generated a self-signed one) which has been placed in /etc/apache2/ssl/apache.pem
and /etc/apache2/ssl/apache.key
as referenced in the config above.
Finally get apache to use the new config:
sudo service apache2 restart
(Or reload
may be enough)