安装zlib
cd /opt/sudytech/httpd-2.2.34/srclib/zlib-1.2.8 ./configure --prefix=/usr/local/zlib --libdir=/lib64 --includedir=/usr/include make make install echo “/usr/local/zlib” >> /etc/ld.so.conf(仅运行一次) ldconfig |
安装openssl
安装pcre
tar –xzvf pcre-8.37.tar.gz |
安装apr-1.5.2
tar -xzvf apr-1.5.2.tar.gz (如果出现 libtool的command not found,则编辑libtool将 $echo 替换为$ECHO或更新libtool,出现cannot remove libtoolT则编辑 configure文件,查找 $RM "$cfgfile",并用#注释掉,更新autoconf、automake、libxml2) |
安装apr-util-1.5.4
tar –xzvf apr-util-1.5.4.tar.gz |
安装httpd-2.4.18(httpd-2.2.31)
tar –xzvf httpd-2.4.18-sudy-modified.tgz |
安装tomcat-connectors-1.2.37(1.2.23)
tar –xzvf tomcat-connectors-1.2.37-src.tgz |
配置文件修改
8.1 httpd.conf修改
httpd.conf基础修改参见基础环境部署文档
httpd.conf中需开启ssl功能
(标红字体请检查是否 解除 注释)
LoadModule ssl_module modules/mod_ssl.so # Secure (SSL/TLS) connections Include conf/extra/httpd-ssl.conf |
启用https功能后,httpd.conf中将不使用 * 主机名,否则将与https主机名冲突
将ServerName、VirtualHost改为真实IP或真实主机名
8.2 httpd-ssl.conf修改
默认监控端口为443,可依据实际更换为所需端口号
修改主目录、主机名日志信息等
# General setup for the virtual host DocumentRoot "/opt/sudytech/apache-tomcat-6.0.53/webapps/ROOT" ServerName www.sudytech.com:443 ServerAdmin you@example.com ErrorLog "/opt/sudytech/apache2/logs/error_https_log" TransferLog "/opt/sudytech/apache2/logs/access_https_log" |
修改默认证书信息
注:常见的如沃通证书需要使用证书链,也有只需主机证书和个签的版本,对应将证书加载至对应位置即可(证书路径可自由定义,但apache启动用户需有文件读写权限)
当有特定页面使用或用于发布服务器时,需要在httpd-ssl.conf中添加虚拟主机并指定使用ssl功能和各个证书位置
NameVirtualHost www.sudytech.com:443 <VirtualHost www.sudytech.com:443> DocumentRoot/opt/sudytech/apache-tomcat-6.0.45/webapps/ROOT ServerAdminadmin@www.abc.com ServerNamewww.sudytech.com DirectoryIndexindex.htm main.htm Includeconf/JK/m.conf SSLEngine on SSLCertificateFile"/opt/sudytech/apache2/conf/certificate/server.crt" SSLCertificateKeyFile"/opt/sudytech/apache2/conf/certificate/server.key" SSLCertificateChainFile"/opt/sudytech/apache2/conf/certificate/chain.crt" </VirtualHost> |
8.3 开放服务器防火墙443端口
8.4 配置https自动跳转
修改httpd.conf(或在静态页面站点文件目录中添加.htacess文件)
#RewriteEngine on #RewriteCond %{SERVER_PORT} !^443$ #RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R] #RewriteRule ^.*$ https://www.domain.com:443 |
可使用^(.*)?$发布重写所有域名
亦可使用^www.sudytech.com/(.*)$重写部分域名
具体apache重写方法详参
http://jingyan.baidu.com/article/359911f5104c3757fe0306ba.html
http://jingyan.baidu.com/article/90bc8fc804f4faf652640c6c.html