Install httpd and mod_ssl on linux

来源:互联网 发布:淘宝怎么开店步骤图解 编辑:程序博客网 时间:2024/05/17 07:53

一、安装httpd

       yum install httpd


二、安装mod_ssl

     http://dev.antoinesolutions.com/apache-server/mod_ssl

     1. yum install mod_ssl

      事实上做了上面那步后没有修改另外的文件。


三、安装好httpd后,配置自己的服务器

       1.在conf.d文件夹下自己建了一个vhost.conf,内容如下:

        我的服务器启动是在localhost:8080

  

ProxyRequests OffProxyVia On<Proxy *>  Order deny,allow  Allow from all  AddDefaultCharset Windows-31J</Proxy><VirtualHost *:443>  ProxyPreserveHost On  ServerName myServerName:443  ## Play Application  ProxyPass / http://localhost:8080/  ProxyPassReverse / http://localhost:8080/  ErrorLog logs/ssl_error_log  TransferLog logs/ssl_access_log  LogLevel warn  SSLEngine on  SSLProtocol all -SSLv2  SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW  SSLCertificateFile 证书(.crt)路径  SSLCertificateKeyFile 密钥文件(.key)路径  SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0  LogFormat "%t %v %h %l %u \"%r\" %>s %b \"%{Referer}i -> %U\" \"%{User-Agent}i\"" custom  CustomLog logs/ssl_access_log custom env=!nolog  CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=!nolog  SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(css)|(js)$" nolog  SetEnvIf Request_URI "favicon\.ico" nolog</VirtualHost>

2.重启httpd:/etc/init.d/httpd restart

    

访问自己的网站,发现如果加上https会正常访问自己的网站,如果是http会默认到apache的test 页面

    修改/etc/httpd/conf文件夹下httpd.conf文件,加上下面内容,将http访问强制转到https

RewriteEngine onRewriteCond   %{HTTPS} !=onRewriteRule   ^(.*)  https://%{SERVER_NAME}$1 [L,R]
 重启httpd,OK,搞定!!!!
0 0
原创粉丝点击