linux下配置Apache基于加密的认证访问
2014-02-22 13:48
477 查看
1、首先要确认安装了 mod_ssl模块
我的机器是centos是系统,执行下面命令
yum install -y mod_ssl
2、用openssl工具生成密钥,证书请求文件,证书
在/usr/local/httpd目下,执行以下命令。
2.1生成密钥
openssl genrsa 1024 > server.key
说明:这是用128位rsa算法生成密钥,得到server.key文件
2.2生成证书请求文件
openssl req -new -out server.csr
说明:这是用步骤1的密钥生成证书请求文件server.csr, 这一步提很多问题,一一输入
2.3生成证书
命令:openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
说明:这是用步骤1,2的的密钥和证书请求生成证书server.crt,-days参数指明证书有效期,单位为天
3、 配置apache
修改httpd.conf
LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
修改httpd-ssl.conf
添加虚拟主机:
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
# General setup for the virtual host
DocumentRoot "/usr/local/httpd/htdocs/ssl"
ServerName ssl.baishiz.com:443
ServerAdmin you@example.com
ErrorLog "/usr/local/httpd/logs/error_log"
TransferLog "/usr/local/httpd/logs/access_log"
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/usr/local/httpd/server.crt"
SSLCertificateKeyFile "/usr/local/httpd/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/httpd/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "/usr/local/httpd/logs/ssl_request_log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
我的机器是centos是系统,执行下面命令
yum install -y mod_ssl
2、用openssl工具生成密钥,证书请求文件,证书
在/usr/local/httpd目下,执行以下命令。
2.1生成密钥
openssl genrsa 1024 > server.key
说明:这是用128位rsa算法生成密钥,得到server.key文件
2.2生成证书请求文件
openssl req -new -out server.csr
说明:这是用步骤1的密钥生成证书请求文件server.csr, 这一步提很多问题,一一输入
2.3生成证书
命令:openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
说明:这是用步骤1,2的的密钥和证书请求生成证书server.crt,-days参数指明证书有效期,单位为天
3、 配置apache
修改httpd.conf
LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
修改httpd-ssl.conf
添加虚拟主机:
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
# General setup for the virtual host
DocumentRoot "/usr/local/httpd/htdocs/ssl"
ServerName ssl.baishiz.com:443
ServerAdmin you@example.com
ErrorLog "/usr/local/httpd/logs/error_log"
TransferLog "/usr/local/httpd/logs/access_log"
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "/usr/local/httpd/server.crt"
SSLCertificateKeyFile "/usr/local/httpd/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/httpd/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "/usr/local/httpd/logs/ssl_request_log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
![](http://images.cnitblog.com/blog/467192/201402/221351552221012.jpg)
相关文章推荐
- ubuntu 13.10 64bit上关于 cgi 的问题
- 如何在apache官网下载将将jar包
- Apache CXF学习 - SOAP Handler的使用 推荐
- Apache配置虚拟目录,以及各种操作
- [python web]linux下apache + django + mod_wsgi + sqlite3配置
- 对于org.apache.commons.dbcp.BasicDataSource的配置认知
- 【转】修复关于apache-xampp的问题:Port 443 in use by “vmware-hostd.exe”!
- java转换json需要导入的jar包,org/apache/commons/lang/exception/NestableRuntimeException
- 禁止显示或发送Apache版本号(设置ServerTokens)
- 安装Apache提示APR not found的解决办法
- 安装Apache提示APR not found的解决办法
- apchae commons-validator 初体验
- Apache的rewrite重写相关的参数详解说明(伪静态)
- apache CXF wsdl2java工具的使用
- apache2.4下载地址
- apache不允许目录列出索引
- java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory的解决办法
- apache加载php模块失败
- Apache中 RewriteRule 规则参数介绍
- Apache CXF学习-创建基于spring的web service 推荐