TranslateProject/translated/Install Apache With SSL in Ubuntu 13.10.md

131 lines
3.7 KiB
Markdown
Raw Normal View History

2013-10-28 21:43:31 +08:00
在Ubuntu 13.10 下安装支持SSL的Apache
2013-10-24 11:05:41 +08:00
================================================================================
2013-10-28 21:43:31 +08:00
通过这个简短的教程,让我来指导你如何安装支持SSL的Apache.以下是我的试验机的详细说明:
2013-10-28 12:09:38 +08:00
### 系统信息 ###
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
root@ubuntu-unixmen:~# ifconfig
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
eth0 Link encap:Ethernet HWaddr 08:00:27:b8:b4:87
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
inet addr:10.1.1.110 Bcast:10.1.1.255 Mask:255.255.255.0
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
inet6 addr: fe80::a00:27ff:feb8:b487/64 Scope:Link
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
RX packets:1738 errors:0 dropped:0 overruns:0 frame:0
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
TX packets:69 errors:0 dropped:0 overruns:0 carrier:0
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
collisions:0 txqueuelen:1000
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
RX bytes:168845 (168.8 KB) TX bytes:9767 (9.7 KB)
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
----------
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
root@ubuntu-unixmen:~# cat /etc/issue
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Ubuntu 13.10 \n \l
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 安装apache ###
2013-10-24 11:05:41 +08:00
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
sudo apt-get install apache2 apache2-doc apache2-utils
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Reading package lists... Done
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Building dependency tree
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Reading state information... Done
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
The following extra packages will be installed:
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### apache测试页面 ###
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
打开浏览器,转到http://ip-address/.你应该会看到类似以下的信息.
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
![](http://180016988.r.cdn77.net/wp-content/uploads/2013/10/apache2-ubuntu.png)
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 创建目录 ###
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
创建一个名为**ssl**的目录
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
sudo mkdir /etc/apache2/ssl
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 创建一个自签名凭证 ###
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Generating a 2048 bit RSA private key.......................................................................................+++....................................+++writing new private key to '/etc/apache2/ssl/apache.key'-----You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 开启Apache SSL模块 ###
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
运行以下命令开启ssl模块
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
$ a2enmod ssl
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Considering dependency setenvif for ssl:
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Module setenvif already enabled
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Considering dependency mime for ssl:
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Module mime already enabled
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Considering dependency socache_shmcb for ssl:
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Enabling module socache_shmcb.
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Enabling module ssl
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
编辑 **/etc/apache2/sites-enabled/default-ssl.conf** 文件,
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
<VirtualHost 10.1.1.110:443>
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
ServerAdmin webmaster@localhost
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
ServerName www.unixmen.com:443
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
SSLEngine on
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
SSLCertificateFile /etc/apache2/ssl/apache.crt
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 启动Apache缺省ssl的虚拟主机: ###
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
a2ensite default-ssl
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
Enabling site default-ssl.
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
To activate the new configuration, you need to run:
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
service apache2 reload
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
### 重启Apache: ###
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
sudo service apache2 restart
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
###测试SSL连接###
2013-10-28 21:43:31 +08:00
2013-10-28 12:09:38 +08:00
打开浏览器,转到**https://IP-address**.
2013-10-28 21:43:31 +08:00
2013-10-24 11:05:41 +08:00
![](http://180016988.r.cdn77.net/wp-content/uploads/2013/10/apache-cert.png)
2013-10-28 21:43:31 +08:00
2013-10-28 21:44:17 +08:00
安装完成,尽情享用!
2013-10-24 11:05:41 +08:00
--------------------------------------------------------------------------------
via: http://www.unixmen.com/install-apache-ssl-ubuntu-13-10/
2013-10-28 21:43:31 +08:00
译者:[Luoxcat](https://github.com/Luoxcat) 校对:[Caroline](https://github.com/carolinewuyan)
2013-10-24 11:05:41 +08:00
2013-10-27 14:08:46 +08:00
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出