Zhao Peng
Zhao Peng

Reputation: 1831

How to use https?

If on the server, we already setup/configured the SSL certificate, how could I make my websites using secure page? Just make the linke to https://example.com/etc.php?

Thanks!

Upvotes: 6

Views: 8098

Answers (1)

Jonathan Barlow
Jonathan Barlow

Reputation: 1075

Two things have to be in place.

  1. You'll need to setup the ssl cert properly, which it sounds like you have
  2. As the other commentator said, this will depend upon which webserver you're using. More likely than not, apache:

Apache:

You'll need to modify the apache settings to support the https version of your site. If you're using a modern installation of Apache2 with virtual hosts, usually there will be a "sites-available" directory where individual config files exists for each domain. For a domain that will have both http and https (80 and 443), you would do something like this, assuming apache is listening on 127.0.0.1 (this would not be the case for most apache installations, so be sure to change the ip). It also goes without saying that you need to change the paths and domain name in the following:

<VirtualHost 127.0.0.1:80>
  ServerAdmin [email protected]
  ServerName somebody.com
  ServerAlias www.somebody.com
  DocumentRoot /home/somebody/www
  <Directory "/home/somebody/www">
        Options FollowSymLinks
        AllowOverride All
        Options -Indexes
  </Directory>
  ErrorLog /home/logs/somebody.error.log
  CustomLog /home/logs/somebody.access.log combined
</VirtualHost>
<VirtualHost 127.0.0.1:443> SSLEngine On SSLCertificateFile /etc/apache2/ssl/something.crt SSLCertificateKeyFile /etc/apache2/ssl/something.key SSLCertificateChainFile /etc/apache2/ssl/gd_bundle.crt ServerAdmin [email protected] ServerName somebody.com ServerAlias www.somebody.com DocumentRoot /home/somebody/www <Directory "/home/somebody/www"> Options FollowSymLinks AllowOverride All Options -Indexes </Directory> ErrorLog /home/logs/somebody.ssl.error.log CustomLog /home/logs/somebody.ssl.access.log combined </VirtualHost>

If you are using nginx, there is a similar dual block you'll need to have for :80 and :443. Look at the block you already have for 80 and consult their documentation:

http://nginx.org/en/docs/http/configuring_https_servers.html

You may also be using iis, in which case, here are the instructions for version 7:

How do I configure a site in IIS 7 for SSL?

Upvotes: 5

Related Questions