Centos 5下配置https服务器的方法_Linux

[root@centos5 ~]# yum -y install mod_ssl 在线安装mod_ssl
Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* base: centos.candishosting.com.cn
* updates: mirror.khlug.org
* addons: centos.candishosting.com.cn
* extras: centos.candishosting.com.cn
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package mod_ssl.i386 1:2.2.3-11.el5_2.centos.4 set to be updated
--> Processing Dependency: libdistcache.so.1 for package: mod_ssl
--> Processing Dependency: libnal.so.1 for package: mod_ssl
--> Running transaction check
---> Package distcache.i386 0:1.4.5-14.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mod_ssl i386 1:2.2.3-11.el5_2.centos.4 updates

85 k
Installing for dependencies:
distcache i386 1.4.5-14.1 base 119 k

Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 204 k
Downloading Packages:
(1/2): mod_ssl-2.2.3-11.e 100% |=========================| 85 kB 00:02
(2/2): distcache-1.4.5-14 100% |=========================| 119 kB 00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: distcache ######################### [1/2]
Installing: mod_ssl ######################### [2/2]

Installed: mod_ssl.i386 1:2.2.3-11.el5_2.centos.4
Dependency Installed: distcache.i386 0:1.4.5-14.1
Complete!

[root@centos5 ~]# cd /etc/httpd/conf 进入HTTP服务器配置文件所在目录
[root@centos5 conf]# rm -rf ssl.*/server.* 删除默认或残留的服务器证书相关文件

[root@centos5 ~]# rpm -qa |grep openssl
openssl-0.9.8b-10.el5

[root@centos5 ~]# openssl genrsa -out www.yang.com.key 1024 建立服务器密钥
Generating RSA private key, 1024 bit long modulus
...........................................................++++++
.++++++
e is 65537 (0x10001)

[root@centos5 ~]# openssl req -new -key www.yang.com.key -out www.yang.com.csr 建立服务器公钥

You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:OM 输入国名
State or Province Name (full name) [Berkshire]:fuzhou 输入省名
Locality Name (eg, city) [Newbury]:fou 输入城市名
Organization Name (eg, company) [My Company Ltd]:yang 输入组织名(任意)
Organizational Unit Name (eg, section) []:www 不输入,直接回车
Common Name (eg, your name or your server's hostname) []:www.yang.com 输入通称(任意)
Email Address []:admin@yang.com 输入电子邮箱地址

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: 不输入,直接回车
An optional company name []: 不输入,直接回车

[root@centos5 ~]# ls -l
total 68
-rw------- 1 root root 986 Jan 31 23:54 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Feb 1 02:17 Desktop
-rw-r--r-- 1 root root 0 Feb 1 03:06 Finished
-rw-r--r-- 1 root root 15078 Jan 31 23:54 install.log
-rw-r--r-- 1 root root 2876 Jan 31 23:53 install.log.syslog
-rw-r--r-- 1 root root 0 Feb 1 03:06 Package
-rw-r--r-- 1 root root 0 Feb 1 03:06 Processing
-rw-r--r-- 1 root root 0 Feb 1 03:06 Running
-rw-r--r-- 1 root root 684 Feb 1 04:54 www.yang.com.csr
-rw-r--r-- 1 root root 887 Feb 1 04:52 www.yang.com.key

[root@centos5 ~]# openssl x509 -req -days 365 -in www.yang.com.csr -signkey www.yang.com.key -out www.yang.com.crt 建立服务器证书

Signature ok
subject=/C=OM/ST=fuzhou /L=fou/O=yang/OU=www/CN=www.yang.com/emailAddress=admin@ yang.com
Getting Private key

[root@centos5 ~]# ll
total 72
-rw------- 1 root root 986 Jan 31 23:54 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Feb 1 02:17 Desktop
-rw-r--r-- 1 root root 0 Feb 1 03:06 Finished
-rw-r--r-- 1 root root 15078 Jan 31 23:54 install.log
-rw-r--r-- 1 root root 2876 Jan 31 23:53 install.log.syslog
-rw-r--r-- 1 root root 0 Feb 1 03:06 Package
-rw-r--r-- 1 root root 0 Feb 1 03:06 Processing
-rw-r--r-- 1 root root 0 Feb 1 03:06 Running
-rw-r--r-- 1 root root 920 Feb 1 04:57 www.yang.com.crt
-rw-r--r-- 1 root root 684 Feb 1 04:54 www.yang.com.csr
-rw-r--r-- 1 root root 887 Feb 1 04:52 www.yang.com.key

[root@centos5 ~]# vi /etc/httpd/conf.d/ssl.conf 修改SSL的设置文件

# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
#
Listen 443

[root@centos5 ~]# /etc/rc.d/init.d/httpd restart 重启服务
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

[root@centos5 ~]# netstat -ntpl |grep 443
tcp 0 0 :::443 :::* LIST

EN 10317/httpd


注:本实验以http://www.centospub.com/make/ssl.html为指导

配置SSL虚拟主机

#vi /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.0.20:443

NameVirtualHost 192.168.0.20:80
<VirtualHost IP:192.168.0.20:443>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html
ServerName www. yang.com

SSLEngine on
SSLCertificateFile /etc/httpd/conf/www.yang.com.crt
SSLCertificateKeyFile /etc/httpd/conf/www.yang.com.key

ErrorLog logs/dummy-www.yang.com-error_log
CustomLog logs/dummy-www.yang.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.20:443>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/cgi-bin/openwebmail
ServerName mail.yang.com

SSLEngine on
SSLCertificateFile /etc/httpd/conf/www.yang.com.crt
SSLCertificateKeyFile /etc/httpd/conf/www.yang.com.key

ErrorLog logs/dummy-www.yang.com-error_log
CustomLog logs/dummy-www.yang.com-access_log common
</VirtualHost>

#vi /etc/httpd/conf.d/ssl.conf 添加下面的内容

SSLEngine on
SSLCertificateFile /etc/httpd/conf/www.yang.com.crt
SSLCertificateKeyFile /etc/httpd/conf/www.yang.com.key

时间: 2024-08-02 00:52:14

Centos 5下配置https服务器的方法_Linux的相关文章

Linux操作系统下配置DNS服务器的方法介绍

有两台邮件服务器分别为192.168.1.1(windows下主机名为b.test.cn)和192.168.1.3(linux下主机名为a.test.com). 在linux下配置DNS服务器,下面是配置过程中设置过的一些文件, /etc/hosts 文件的具体内容如下: # Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 l

在linux下配置DNS服务器的方法

有两台邮件服务器分别为192.168.1.1(windows下主机名为b.test.cn)和192.168.1.3(linux下主机名为a.test.com). 在linux下配置DNS服务器,下面是配置过程中设置过的一些文件, /etc/hosts 文件的具体内容如下: # Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 l

linux配置ISCSI服务器的方法_Linux

一.在linux下安装启动iscsi target 1.安装启动iscsi服务 [root@wjb10000 ~]# yum -y install targetcli.noarch 2.建立一个目录设置为iscsi设备 [root@wjb10000 ~]# mkdir /iscsi_disks 3.设置target [root@wjb10000 ~]# targetcli Warning: Could not load preferences file /root/.targetcli/pref

linux配置ntp服务器的方法_Linux

一.安装ntp软件 1.检查是否安装了ntp相关包. rpm -qa | grep ntp 2.安装ntp软件. yum -y install ntp 二.参数讲解 ignore  :关闭所有的 NTP 联机服务 nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时. notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网 noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器 notrap :不提供

Linux配置VSFTP服务器的方法_Linux

一.Linux FTP服务器分类:  <1>wu-ftp  <2>proftp=profession ftp  <3>vsftp=very security ftp 配置文件: /etc/vsftpd/vsftpd.conf   //主配置文件 /etc/vsftpd.ftpusers      //被禁止登录FTP的用户文件 /etc/vsftpd.user_list     //允许登录FTP的用户文件 二.访问方式  <1>匿名登录  <2>

centos系统搭建本地yum服务器的方法_Linux

前言 首先特别说明的是,YUM只是为了解决RPM的依赖关系的问题,而不是一种其它的软件安装模式.虽然在centos中可以直接使用yum源,但是也存在着与外网隔绝的现状,因此需要搭建本地yum源,下面来看看详细的方法. 系统:centos 6.5 1.将光盘挂载到/mnt下面 # mount /dev/cdrom /mnt 2.删除系统自带的repo文件 # cd /etc/yum.repos.d/ # mkdir bak # mv *.repo bak 3.安装createrepo(其实只要安装

Debian下配置SSH服务器的方法

Debian 503版本中实现的,Debian默认好像是没有ssh支持的. SSH的安装 apt-get install openssh-server apt-get install ssh SSH的配置 OpenSSH的配置都集中在/etc/ssh/ssh_config文件中 编辑"ssh_config"文件(vim /etc/ssh/ssh_config),添加或改变下面的参数: # Site-wide defaults for various options Host * For

Nginx 下配置SSL证书的方法_Linux

1.Nginx 配置 ssl 模块 默认 Nginx 是没有 ssl 模块的,而我的 VPS 默认装的是 Nginx 0.7.63 ,顺带把 Nginx 升级到 0.7.64 并且 配置 ssl 模块方法如下: 下载 Nginx 0.7.64 版本,解压 进入解压目录: 复制代码 代码如下: wget http://sysoev.ru/nginx/nginx-0.7.64.tar.gz tar zxvf nginx-0.7.64.tar.gz cd nginx-0.7.64 如果要更改heade

Ubuntu 下配置Rsync服务的方法_Linux

默认情况Ubuntu安装了rsync服务,但在/etc下没有配置文件,一般情况可以copy示例文件到/etc下 #cp /usr/share/doc/rsync/examples/rsyncd.conf /etc #vi /etc/rsyncd.conf # sample rsyncd.conf configuration file # GLOBAL OPTIONS motd file=/etc/motd #登录欢迎信息 log file=/var/log/rsyncd #日志文件 # for