Build an https Server (apache) in linux)

Source: Internet
Author: User

I. Installation preparation
1. Install Openssl
To enable Apache to support SSL, you must first install Openssl support. Openssl-0.9.8k.tar.gz
Download Openssl: http://www.openssl.org/source/
Tar-zxf openssl-0.9.8k.tar.gz // unzip the installation package
Cd openssl-0.9.8k // enter the unzipped installation package
./Config // configure and install. We recommend that you use the default configuration.
Make & make install // compile and install
Openssl will be installed to/usr/local/ssl by default

2. install Apache

Download the httpdsource code from http://httpd.apache.org/here, httpd2.2.22;
. /Configure -- prefix =/usr/local/httpd2.2.22 -- enable-so -- enable-ssl -- with-ssl =/usr/local/ssl -- enable-mod-shared = all // configure and install. Dynamic compilation module recommended
Make & make install
The Apache module is compiled dynamically to facilitate module load management. Apache will be installed in/usr/local/apache

Ii. Generate a certificate

To quickly build an available https server, you must go to the/usr/local/httpd2.2.22/conf/directory

(It can also be generated in another directory. Copy the generated file to the/usr/local/httpd2.2.22/conf/directory)

Run the following commands in sequence:

1. openssl req-new-text-out server. req

2. openssl rsa-in privkey. pem-out server. key

3. openssl req-x509-in server. req-text-key server. key-out server. crt

For more information, see the openssl document;

Iii. Apache configuration

Open the httpd. conf file in the conf directory under the apache installation directory and find
# LoadModule ssl_module modules/mod_ssl.so
Delete the configuration statement comment symbol "#" at the beginning of the line
Save and exit.
Open the ssl. conf file in the conf directory under the apache installation directory and find
Find the following configuration statement in the configuration file:
SSLCertificateFile conf/ssl. crt/server. crt Configure the server certificate to this path
SSLCertificateKeyFile conf/ssl. key/server. key: configure the private key of the server certificate to this path.
# SSLCertificateChainFile conf/ssl. crt/ca. crt Delete the comment "#" at the beginning of the line, and configure intermediate CA certificate intermediate. crt to this path
Save and exit, and restart Apache. Restart Method:
Go to the bin directory under the Apache installation directory and run the following command:
./Apachectl-k-stop
./Apachectl start

Access your site through https and test the installation and configuration of the site certificate.

In this case, you can access the established server through http and https;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.