<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DevOps技术分享 &#187; APACHE</title>
	<atom:link href="http://www.showerlee.com/archives/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://www.showerlee.com</link>
	<description>与你共同学习运维开发</description>
	<lastBuildDate>Mon, 19 Oct 2020 05:51:41 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6</generator>
		<item>
		<title>CentOS7.4部署Django+Python3+Apache+Mod_wsgi</title>
		<link>http://www.showerlee.com/archives/2511</link>
		<comments>http://www.showerlee.com/archives/2511#comments</comments>
		<pubDate>Mon, 16 Apr 2018 03:11:05 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[APACHE]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[mod_wsgi]]></category>
		<category><![CDATA[python3]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=2511</guid>
		<description><![CDATA[安装环境 Remote: CentOS 7.4 x64 (django.example.com) Python [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="font-size:16px;color:#337FE5;">安装环境</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	Remote: CentOS 7.4 x64 (<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>.example.com)
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	Python: Python3.6.5
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	Apache: Apache 2.4.6
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	Mod_wsgi: 4.6.4
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	Django: Django 2.0.4
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-size:16px;"><strong>一. 系统环境配置</strong></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">1.关闭iptables和selinux</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# su - root
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# systemctl stop firewalld
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="vertical-align:baseline;line-height:1.5;"># setenforce 0</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="vertical-align:baseline;line-height:1.5;"># vi /etc/sysconfig/selinux</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	修改
</p>
<pre class="prettyprint lang-bsh">SELINUX=disabled</pre>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="vertical-align:baseline;line-height:1.5;color:#337FE5;">2.添加本地host DNS</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="vertical-align:baseline;line-height:1.5;"># vi /etc/hosts</span>
</p>
<pre class="prettyprint lang-bsh">127.0.0.1    <a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>.example.com</pre>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="font-size:16px;color:#337FE5;"><strong>二. Python配置</strong></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">1.安装<a href="http://www.showerlee.com/archives/tag/python3" title="查看python3中的全部文章" class="tag_link">python3</a>.6.5源及依赖包</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="vertical-align:baseline;line-height:1.5;"># yum install epel-release -y</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# yum groupinstall "Development tools" -y
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	#&nbsp;<span style="color:#111111;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">yum install zlib-devel bzip2-devel openssl-devel ncurses-devel zx-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel libffi-devel -y</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">2.编译安装python3.6.5以及pip package manager</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# wget <a href="https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz" rel="nofollow">https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz</a> --no-check-certificate
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# tar xf Python-3.6.5.tar.xz
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# cd Python-3.6.5
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# ./configure --prefix=/usr/local --with-ensurepip=install --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# make &amp;&amp; make altinstall
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">3.安装virtualenv</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	#&nbsp;pip3.6 install --upgrade pip
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	#&nbsp;pip3.6 install virtualenv
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-family:Helvetica;font-size:16px;background-color:#FFFFFF;"><strong>三. Django环境配置</strong></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">1. 配置Django virtualenv</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# mkdir -p /var/www/html/<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# cd&nbsp;<span style="color:#111111;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">/var/www/html/<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# virtualenv -p /usr/local/bin/python3.6 .py3env
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">2. 开启virtualenv python3环境</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-size:16px;"><span style="color:#111111;font-size:13px;">#&nbsp;source .py3env/bin/activate</span></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-size:16px;"><span style="color:#337FE5;font-size:13px;">3. 在此环境安装Django相关模块</span></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# pip install <a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a> pymysql
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-size:16px;"><strong>四. Apache配置</strong></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">1. 安装apache package</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# yum install httpd httpd-devel -y
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">2.安装<a href="http://www.showerlee.com/archives/tag/mod_wsgi" title="查看mod_wsgi中的全部文章" class="tag_link">mod_wsgi</a> for python3</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#E53333;">Tip:这里其实是一个远古巨坑, 网上90%以上资料的会粗心的直接使用yum install <a href="http://www.showerlee.com/archives/tag/mod_wsgi" title="查看mod_wsgi中的全部文章" class="tag_link">mod_wsgi</a>去安装apache <a href="http://www.showerlee.com/archives/tag/mod_wsgi" title="查看mod_wsgi中的全部文章" class="tag_link">mod_wsgi</a>模块, 这样做其实最终mod模块会调用本地默认的python2的所有库文件, 无论你后面如何配置<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>入口文件, apache都不会使用我们配置的virutalenv下隔离的python3, 导致apache无法调用python3而报错. 这里小伙伴要注意哦.</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#111111;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;"># pip install <a href="http://www.showerlee.com/archives/tag/mod_wsgi" title="查看mod_wsgi中的全部文章" class="tag_link">mod_wsgi</a>&nbsp;</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">3.导出apache所需的mod_wsgi模块</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#111111;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">#&nbsp;mod_wsgi-express install-module</span>
</p>
<pre class="prettyprint lang-bsh">LoadModule wsgi_module "/usr/lib64/httpd/modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
WSGIPythonHome "/var/www/html/.py3env"</pre>
<p>
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">4.配置apache配置文件</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;"><span style="color:#000000;"># vi</span><span style="color:#000000;">&nbsp;/etc/httpd/conf/httpd.conf</span></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;background-color:#FFFFFF;">
	末行添加:
</p>
<pre class="prettyprint lang-bsh">LoadModule wsgi_module "/usr/lib64/httpd/modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"</pre>
<p>
	
</p>
<p>
	#&nbsp;vi /etc/httpd/conf.d/<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>.conf
</p>
<p>
	
</p>
<pre class="prettyprint lang-bsh">WSGIPythonHome "/var/www/html/<a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>/.py3env"

Listen 8080
&lt;VirtualHost *:8080&gt;

ServerName <a href="http://www.showerlee.com/archives/tag/django-2" title="查看django中的全部文章" class="tag_link">django</a>.example.com

Alias /static /var/www/html/django/static
&lt;Directory /var/www/html/django/static&gt;
 Require all granted
&lt;/Directory&gt;

&lt;Directory /var/www/html/django/myproject&gt;
  &lt;Files wsgi.py&gt;
    Require all granted
  &lt;/Files&gt;
&lt;/Directory&gt;

WSGIDaemonProcess myproject python-path=/var/www/html/django/.py3env/lib/python3.6/site-packages
WSGIScriptAlias / /var/www/html/django/myproject/wsgi.py

&lt;/VirtualHost&gt;</pre>
<p>
	
</p>
<p>
	
</p>
<p>
	<span style="color:#337FE5;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">5.重启apache并设置开机自启动</span>
</p>
<p>
	# systemctl restart httpd
</p>
<p>
	# systemctl enable httpd
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	<span style="color:#337FE5;font-family:Helvetica;font-size:16px;background-color:#FFFFFF;"><strong>五. Django项目配置</strong></span>
</p>
<p>
	<span style="color:#337FE5;">1. 保证virtualenv python3环境开启</span>
</p>
<p>
	# source <span style="color:#111111;font-family:Helvetica;font-size:13px;background-color:#FFFFFF;">/var/www/html/django/</span>.py3env/bin/activate
</p>
<p>
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">2.创建一个Django项目</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# cd /var/www/html/django/
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	#&nbsp;django-admin startproject myproject .
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">3.添加static目录</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# vi&nbsp;myproject/settings.py
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	末行添加:
</p>
<pre class="prettyprint lang-bsh">STATIC_ROOT = os.path.join(BASE_DIR, "static/")</pre>
<p>
	
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	<span style="color:#337FE5;">4.创建本地SQLlite文件</span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;background-color:#FFFFFF;">
	<span><span style="color:#E53333;">Tip:这里使用SQLlite代替其他数据库作为我们项目的DB</span></span>
</p>
<p style="font-family:Helvetica;font-size:13px;vertical-align:baseline;color:#111111;background-color:#FFFFFF;">
	# ./manage.py makemigrations<br />
# ./manage.py migrate
</p>
<pre class="prettyprint lang-bsh">Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying sessions.0001_initial... OK</pre>
<p>
	
</p>
<p>
	<span style="color:#337FE5;">5.创建项目管理员账户</span>
</p>
<p>
	#&nbsp;./manage.py createsuperuser
</p>
<pre class="prettyprint lang-bsh">Username (leave blank to use 'root'): root
Email address: <a href="mailto:admin@admin.com">admin@admin.com</a>
Password:
Password (again):
Superuser created successfully.</pre>
<p>
	
</p>
<p>
	<span style="color:#337FE5;">6.生成项目静态文件目录</span>
</p>
<p>
	#&nbsp;./manage.py collectstatic
</p>
<p>
	
</p>
<p>
	<span style="color:#337FE5;">7.修改wsgi入口文件</span>
</p>
<p>
	#&nbsp;vi myproject/wsgi.py
</p>
<pre class="prettyprint lang-bsh">import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
sys.path.append('/var/www/html/django')

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()</pre>
<p>
	
</p>
<p>
	<span style="color:#337FE5;">8.添加</span><span style="color:#337FE5;">ALLOWED_HOSTS</span>
</p>
<p>
	#&nbsp;vi myproject/settings.py
</p>
<p>
	Update:
</p>
<pre class="prettyprint lang-bsh">ALLOWED_HOSTS = ['django.example.com']</pre>
<p>
	
</p>
<p>
	<span style="color:#337FE5;">9.修改项目属主和权限</span>
</p>
<p>
	# chmod -R 755 /var/www/html
</p>
<p>
	# chown -R apache:apache /var/www/html
</p>
<p>
	
</p>
<p>
	查看最终目录下的生成的项目文件
</p>
<p>
	# ls -l
</p>
<pre class="prettyprint lang-bsh">-rwxr-xr-x 1 apache apache 38912 Apr 16 15:04 db.sqlite3
-rwxr-xr-x 1 apache apache   541 Apr 16 14:50 manage.py
drwxr-xr-x 3 apache apache  4096 Apr 16 15:21 myproject
drwxr-xr-x 3 apache apache  4096 Apr 16 15:05 static</pre>
<p>
	
</p>
<p>
	最终浏览器访问django项目
</p>
<p>
	<span style="color:#E53333;">Tip:保证windows本地添加django服务器的HOST域名</span>
</p>
<p>
	
</p>
<p>
	django测试页面
</p>
<p>
	<a href="http://www.showerlee.com/?attachment_id=2560"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2018/04/django.png" alt="" width="800" height="582" class="alignnone size-full wp-image-2560" title="" align="" /></a>
</p>
<p>
	
</p>
<p>
	项目主页, 输入之前创建的管理员账号密码
</p>
<p>
	<a href="http://www.showerlee.com/?attachment_id=2561"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2018/04/home.png" alt="" width="800" height="349" class="alignnone size-full wp-image-2561" title="" align="" /></a>
</p>
<p>
	
</p>
<p>
	项目后台
</p>
<p>
	<a href="http://www.showerlee.com/?attachment_id=2559"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2018/04/dashboard.png" alt="" width="600" height="245" class="alignnone size-full wp-image-2559" title="" align="" /></a>
</p>
<p>
	
</p>
<p>
	Finished...</p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/2511">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="CentOS7.4部署Django+Python3+Apache+Mod_wsgi" href="http://www.showerlee.com/archives/2511">http://www.showerlee.com/archives/2511</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/2511/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SVN到Git迁移笔记</title>
		<link>http://www.showerlee.com/archives/1227</link>
		<comments>http://www.showerlee.com/archives/1227#comments</comments>
		<pubDate>Fri, 08 Aug 2014 10:11:08 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Svn]]></category>
		<category><![CDATA[APACHE]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=1227</guid>
		<description><![CDATA[本篇博文目的是将本地SVN服务器的project迁移为GIT格式,并上传到目前大家常用的github托管服务器 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
	本篇博文目的是将本地SVN服务器的project迁移为GIT格式,并上传到目前大家常用的github托管服务器.
</p>
<p>
	
</p>
<p>
	<span style="line-height:1.5;">解决方案：</span>
</p>
<p>
	<span style="line-height:1.5;"><br />
</span>
</p>
<p>
	<span style="line-height:1.5;">一.环境部署</span>
</p>
<p>
	<span style="line-height:1.5;">操作系统： &nbsp; &nbsp; &nbsp; &nbsp;centos6.3 x64</span>
</p>
<p>
	<span style="line-height:1.5;">SVN: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; subversion-1.8.0</span>
</p>
<p>
	<span style="line-height:1.5;">apache: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;httpd-2.4.4</span>
</p>
<p>
	
</p>
<p>
	svn server(centos6.3 x64): node2.example.com
</p>
<p>
	<span style="line-height:1.5;">svn client(centos6.3 x64): node1.example.com</span>
</p>
<p>
	<span style="line-height:1.5;">git server: <a href="https://github.com/leonIi/" rel="nofollow">https://github.com/leonIi/</a></span>
</p>
<p>
	
</p>
<p>
	一.关闭iptables和SELINUX
</p>
<p>
	<span style="line-height:1.5;"># service iptables stop</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">注：如需开启防火墙,则添加如下一条规则打开svn 3690端口</span>
</p>
<p>
	<span style="line-height:1.5;"># iptables -A INPUT -p tcp &nbsp;--dport 3690 -j ACCEPT</span>
</p>
<p>
	<span style="line-height:1.5;"># setenforce 0</span>
</p>
<p>
	<span style="line-height:1.5;"># vi /etc/sysconfig/selinux</span>
</p>
<p>
	<span style="line-height:1.5;">---------------</span>
</p>
<p>
	<span style="line-height:1.5;">SELINUX=disabled</span>
</p>
<p>
	<span style="line-height:1.5;">---------------</span>
</p>
<p>
	
</p>
<p>
	二.同步时间
</p>
<p>
	<span style="line-height:1.5;"># ntpdate cn.pool.ntp.org</span>
</p>
<p>
	
</p>
<p>
	三.安装apache
</p>
<p>
	<span style="line-height:1.5;">传送门：<a href="http://www.showerlee.com/archives/6" target="_blank">http://www.showerlee.com/archives/6</a></span>
</p>
<p>
	
</p>
<p>
	四.关闭系统自带svnserve
</p>
<p>
	<span style="line-height:1.5;"># service svnserve stop</span>
</p>
<p>
	<span style="line-height:1.5;"># chkconfig svnserve off</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">注：本文档为了与apache2.4.4配合不发生兼容问题，所以使用了最新编译版本的svn,这里关闭是为了保证与rpm的版本不冲突.</span>
</p>
<p>
	
</p>
<p>
	五.安装svn server
</p>
<p>
	<span style="line-height:1.5;">传送门：<a href="http://www.showerlee.com/archives/350" target="_blank">http://www.showerlee.com/archives/350</a></span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">注:安装完毕后:</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">svn根目录: /data/svn_repo</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">http访问URL: <a href="http://node2.example.com/svn/&#039;具体仓库" rel="nofollow">http://node2.example.com/svn/&#039;具体仓库</a>'</span>
</p>
<p>
	
</p>
<p>
	六.SVN到GIT迁移
</p>
<p>
	
</p>
<p>
	1.首先在github上面创建一个repository(略)
</p>
<p>
	
</p>
<p>
	2.创建一个SVN仓库(svn server)
</p>
<p>
	
</p>
<p>
	# cd /data/svn_repo/
</p>
<p>
	<span style="line-height:1.5;"># svnadmin create project01</span>
</p>
<p>
	<span style="line-height:1.5;">重启svn与apache</span>
</p>
<p>
	<span style="line-height:1.5;"># killall svnserve</span>
</p>
<p>
	<span style="line-height:1.5;"># /usr/local/svn/bin/svnserve -d -r /data/svn_repo/</span>
</p>
<p>
	<span style="line-height:1.5;"># /usr/local/apache2/bin/apachectl restart</span>
</p>
<p>
	
</p>
<p>
	3.SVN checkin and checkout(svn client)
</p>
<p>
	<span style="line-height:1.5;">1).客户端安装svn(若安装可略过)</span>
</p>
<p>
	<span style="line-height:1.5;"># yum install svn -y</span>
</p>
<p>
	
</p>
<p>
	2). svn checkout
</p>
<p>
	<span style="line-height:1.5;"># cd ~</span>
</p>
<p>
	<span style="line-height:1.5;"># mkdir svn_client_repo</span>
</p>
<p>
	<span style="line-height:1.5;"># cd svn_client_repo</span>
</p>
<p>
	<span style="line-height:1.5;"># svn co <a href="http://node2.example.com/svn/project01" rel="nofollow">http://node2.example.com/svn/project01</a></span>
</p>
<p>
	
</p>
<p>
	3). svn status
</p>
<p>
	<span style="line-height:1.5;"># svn status project01</span>
</p>
<p>
	<span style="line-height:1.5;"># cd project01</span>
</p>
<p>
	<span style="line-height:1.5;"># touch test01 test02 test03</span>
</p>
<p>
	
</p>
<p>
	4). svn add (添加)
</p>
<p>
	<span style="line-height:1.5;"># svn add test01</span>
</p>
<p>
	<span style="line-height:1.5;"># svn add test02</span>
</p>
<p>
	<span style="line-height:1.5;"># svn add test03</span>
</p>
<p>
	
</p>
<p>
	5). svn checkin(提交)
</p>
<p>
	
</p>
<p>
	# svn ci -m”project01”
</p>
<p>
	
</p>
<p>
	6). svn log (查看文件日志注释)
</p>
<p>
	<span style="line-height:1.5;"># svn log 1</span>
</p>
<p>
	
</p>
<p>
	常见错误提示:
</p>
<p>
	
</p>
<p>
	<span style="color:#E53333;">Commit failed (details follow):</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">Error normalizing log message to internal format</span>
</p>
<p>
	<span style="line-height:1.5;color:#E53333;">Can't convert string from native encoding to 'UTF-8':</span>
</p>
<p>
	解决方法:
</p>
<p>
	<span style="line-height:1.5;"># vi ~/.subversion/config</span>
</p>
<p>
	<span style="line-height:1.5;">修改:log-encoding = UTF-8</span>
</p>
<p>
	
</p>
<p>
	<span style="color:#E53333;">svn: Can't open file '/data/svn_repo/project01/db/txn-current-lock': Permission denied</span>
</p>
<p>
	<span style="line-height:1.5;">解决方法:</span>
</p>
<p>
	<span style="line-height:1.5;">将server端 /data/svn_repo/project01目录属主修改为apache用户,默认为daemon</span>
</p>
<p>
	# chown -R daemon.daemon /data/svn_repo/project01
</p>
<p>
	
</p>
<p>
	2.使用git迁移(svn client)
</p>
<p>
	<span style="line-height:1.5;">1).客户端安装git(若安装可略过)</span>
</p>
<p>
	<span style="line-height:1.5;"># yum install git* git-svn -y</span>
</p>
<p>
	<span style="line-height:1.5;"># cd ~</span>
</p>
<p>
	<span style="line-height:1.5;"># mkdir git_client_repo</span>
</p>
<p>
	<span style="line-height:1.5;"># cd <span>git_client_repo</span></span>
</p>
<p>
	建立SVN用户到git用户的映射文件
</p>
<p>
	<span style="line-height:1.5;"># echo "(no author) = test &lt;test@123.com&gt;" &gt;&nbsp;userinfo.txt&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;"># git svn init <a href="http://node2.example.com/svn/project01&nbsp;project01" rel="nofollow">http://node2.example.com/svn/project01&nbsp;project01</a></span>
</p>
<p>
	<span style="line-height:1.5;"># cd project01</span>
</p>
<p>
	<span style="line-height:1.5;">将svn用户映射到git上.</span>
</p>
<p>
	<span style="line-height:1.5;"># git svn fetch&nbsp;<span>--authors-file=../userinfo.txt</span></span>
</p>
<p>
	# git log
</p>
<p>
	-------------------------------------------------------------------------------------------------------------------------
</p>
<p>
	<span style="line-height:1.5;">commit edc2cdd658f8844ad4a883d083b84ef5dad2320c</span>
</p>
<p>
	<span style="line-height:1.5;">Author: </span><span style="line-height:1.5;color:#E53333;">test &lt;test@123.com&gt;</span>
</p>
<p>
	<span style="line-height:1.5;">Date: &nbsp; Mon Aug 11 05:50:09 2014 +0000</span>
</p>
<p>
	
</p>
<p>
	&nbsp; &nbsp; project01<br />
&nbsp; &nbsp;&nbsp;
</p>
<p>
	&nbsp; &nbsp; git-svn-id: <a href="http://node2.example.com/svn/project01@2" rel="nofollow">http://node2.example.com/svn/project01@2</a> 595a6c50-5861-48b1-ab0a-b1b54e0fc7cc
</p>
<p>
	commit 9bde3c02fbfa6f22088b442a519cfd3870433ebc
</p>
<p>
	Author: <span style="color:#E53333;">test &lt;test@123.com&gt;</span>
</p>
<p>
	Date: &nbsp; Fri Aug 8 07:55:54 2014 +0000
</p>
<p>
	&nbsp; &nbsp; &lt;E2&gt;&lt;80&gt;&lt;9D&gt;project01&lt;E2&gt;&lt;80&gt;&lt;9D&gt;<br />
&nbsp; &nbsp;&nbsp;
</p>
<p>
	&nbsp; &nbsp; git-svn-id: <a href="http://node2.example.com/svn/project01@1" rel="nofollow">http://node2.example.com/svn/project01@1</a> 595a6c50-5861-48b1-ab0a-b1b54e0fc7cc
</p>
<p>
	<span style="line-height:1.5;">-----------------------------------------------------------------------------------------------------------------------</span>
</p>
<p>
	当然上面的两步，可以作一步处理
</p>
<p>
	#&nbsp;git svn clone <a href="http://node2.example.com/svn/project01" rel="nofollow">http://node2.example.com/svn/project01</a> &nbsp;--authors-file=userinfo.txt &nbsp;project01
</p>
<p>
	
</p>
<p>
	<span style="color:#E53333;">注: git svn fetch 这个步骤，可能碰到只想从某个版本开始进行fetch，那么请需要 –r 参数。</span>
</p>
<p>
	
</p>
<p>
	例如：
</p>
<p>
	
</p>
<p>
	# git svn fetch -r 1342:HEAD
</p>
<p>
	
</p>
<p>
	<span style="color:#E53333;">注：1342是你想要从这个版本开始fetch，如何查看这个版本号，你可以使用 svn 命令（windows下需要安装Subversion Client，e.g. sliksvn），简单使用就是 svn log svn_url&nbsp;</span>
</p>
<p>
	<span style="color:#E53333;">这个时候，你可能看到整屏在刷新，没关系，看到log就行。当然更简单的就是使用TortoiseSVN-&gt; Show log。</span>
</p>
<p>
	
</p>
<p>
	亦或者你可以这样使用：
</p>
<p>
	
</p>
<p>
	# git svn clone <a href="http://node2.example.com/svn/project01" rel="nofollow">http://node2.example.com/svn/project01</a> -sr 1342:HEAD project01
</p>
<p>
	
</p>
<p>
	2)创建本地SSH keys并上传到github,详见:
</p>
<p>
	<span style="line-height:1.5;"><a href="https://help.github.com/articles/generating-ssh-keys" rel="nofollow">https://help.github.com/articles/generating-ssh-keys</a></span>
</p>
<p>
	<span style="line-height:1.5;">并更改连接到github SSH端口</span>
</p>
<p>
	<span style="line-height:1.5;"># vim ~/.ssh/config</span>
</p>
<p>
	<span style="line-height:1.5;">增加:</span>
</p>
<p>
	<span style="line-height:1.5;">————————————————————————————</span>
</p>
<p>
	<span style="line-height:1.5;">Host github.com</span>
</p>
<p>
	<span style="line-height:1.5;">&nbsp; Hostname ssh.github.com</span>
</p>
<p>
	<span style="line-height:1.5;">&nbsp; Port 443</span>
</p>
<p>
	<span style="line-height:1.5;">————————————————————————————</span>
</p>
<p></p>
<p>
	
</p>
<p>
	3).到这步的时候，本地已经clone了SVN仓库，现在需要的就是提交到远程了。首先，关联github远程仓库，如下：
</p>
<p>
	
</p>
<p>
	# git remote add origin <a href="mailto:git@github.com">git@github.com</a>:leonIi/project01
</p>
<p>
	<span style="line-height:1.5;"># git fetch</span>
</p>
<p>
	<span style="line-height:1.5;"># git commit -a -m "add file"</span>
</p>
<p>
	<span style="line-height:1.5;"># git add .</span>
</p>
<p>
	<span style="line-height:1.5;"># git push -f&nbsp;</span>
</p>
<p>
	
</p>
<p>
	到github上面查看这个仓库(repository),大致效果如下（https://github.com/leonIi/project01.git）
</p>
<p>
	<a href="http://www.showerlee.com/wp-content/uploads/2014/08/QQ20140808-1@2x.png"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/08/QQ20140808-1@2x-1024x600.png" alt="QQ20140808-1@2x" width="1024" height="600" class="alignnone size-large wp-image-1233" /></a>
</p>
<p>
	
</p>
<p>
	<span>大功告成…</span>
</p>
<p>
	
</p>
<p></p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/1227">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="SVN到Git迁移笔记" href="http://www.showerlee.com/archives/1227">http://www.showerlee.com/archives/1227</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/1227/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS 6.3下CHEF批量部署APACHE</title>
		<link>http://www.showerlee.com/archives/1145</link>
		<comments>http://www.showerlee.com/archives/1145#comments</comments>
		<pubDate>Thu, 29 May 2014 04:23:53 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[CHEF]]></category>
		<category><![CDATA[APACHE]]></category>
		<category><![CDATA[chef]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=1145</guid>
		<description><![CDATA[之前的博文我介绍了如何搭建CHEF环境以及创建编写cookbook,resipes用来批量将cookbook下 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
	之前的博文我介绍了如何搭建CHEF环境以及创建编写cookbook,resipes用来批量将cookbook下发到客户端执行相应的部署操作.
</p>
<p>
	NOW,本篇文档我们会详细介绍如何利用CHEF独有的框架语言来批量部署安装<a href="http://www.showerlee.com/archives/tag/apache" title="查看APACHE中的全部文章" class="tag_link">APACHE</a>,并加载其HTTPS模块等功能.
</p>
<p>
	相信如果你看了本篇文档,利用CHEF实现一个批量自动化部署将不是什么难事.
</p>
<p>
	
</p>
<p>
	CHEF环境部署详见:&nbsp;<a href="http://showerlee.blog.51cto.com/2047005/1408467" target="_blank">http://showerlee.blog.51cto.com/2047005/1408467</a>
</p>
<p>
	
</p>
<p>
	操作系统：CentOS-6.3-x86-64
</p>
<p>
	CHEF： &nbsp; <a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>-server-11.0.12-1.el6.x86_64
</p>
<p>
	<span style="line-height:1.5;">Server : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.107.91.251 (<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>.example.com)</span>
</p>
<p>
	<span style="line-height:1.5;">Workstation: &nbsp; &nbsp; 10.107.91.251 (<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>.example.com)</span>
</p>
<p>
	<span style="line-height:1.5;">node: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.107.91.252 (node1.example.com)</span>
</p>
<p>
	
</p>
<p>
	一. 创建一个空的cookbook实例,并命名为apache&nbsp;(<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>.example.com)
</p>
<p>
	# su -
</p>
<p>
	# cd ~/<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>-repo/cookbooks/
</p>
<p>
	# knife cookbook create apache
</p>
<p>
	# ls
</p>
<p>
	------------------------------------------------------------------------------------------------
</p>
<p>
	README.md &nbsp;apache &nbsp;quick_start
</p>
<p>
	------------------------------------------------------------------------------------------------
</p>
<p>
	# cd apache
</p>
<p>
	# ls&nbsp;
</p>
<p>
	------------------------------------------------------------------------------------------------
</p>
<p>
	CHANGELOG.md &nbsp;attributes &nbsp; files &nbsp; &nbsp; &nbsp;metadata.rb &nbsp;recipes &nbsp; &nbsp;templates
</p>
<p>
	README.md &nbsp; &nbsp; definitions &nbsp;libraries &nbsp;providers &nbsp; &nbsp;resources
</p>
<p>
	------------------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	二. 创建SSL秘钥证书并复制到apache的cookbook对应文件夹&nbsp;(<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>.example.com)
</p>
<p>
	1.证书配置:
</p>
<p>
	1).下载并解压ssl证书生成压缩包:
</p>
<p>
	# cd ~/<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>-repo/cookbooks/apache/files/default
</p>
<p>
	# mkdir certificates
</p>
<p>
	# cd certificates
</p>
<p>
	# wget <a href="http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz" rel="nofollow">http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz</a>
</p>
<p>
	# tar zxvf ssl.ca-0.1.tar.gz
</p>
<p>
	# cd ssl.ca-0.1
</p>
<p>
	
</p>
<p>
	2).利用ssl内脚本生成根证书:
</p>
<p>
	# ./new-root-ca.sh &nbsp;
</p>
<p>
	----------------------------------------------------------------------------------------------
</p>
<p>
	No Root CA key round. Generating one
</p>
<p>
	Generating RSA private key, 1024 bit &nbsp;long modulus
</p>
<p>
	………………………++++++
</p>
<p>
	….++++++
</p>
<p>
	e is 65537 (0×10001)
</p>
<p>
	Enter &nbsp;pass phrase for ca.key:&nbsp;(输入一个密码)
</p>
<p>
	Verifying – Enter pass phrase for ca.key: &nbsp;(再输入一次密码)
</p>
<p>
	……
</p>
<p>
	Self-sign the root CA… (签署根证书)
</p>
<p>
	Enter pass phrase for &nbsp;ca.key:&nbsp;(输入刚刚设置的密码)
</p>
<p>
	……..
</p>
<p>
	……..&nbsp;(下面开始签署)
</p>
<p>
	Country Name (2 letter code) &nbsp;[MY]:CN
</p>
<p>
	State or Province Name (full name) [Perak]:JiangSu
</p>
<p>
	Locality Name &nbsp;(eg, city) [Sitiawan]:NanJing
</p>
<p>
	Organization Name (eg, company) [My Directory &nbsp;Sdn Bhd]:example Co.,Ltd
</p>
<p>
	Organizational Unit Name (eg, section) &nbsp;[Certification Services Division]:example
</p>
<p>
	Common Name (eg, MD Root CA) &nbsp;[]:example
</p>
<p>
	Email Address []:info@example.com
</p>
<p>
	---------------------------------------------------------------------------------------------
</p>
<p>
	这样就生成了ca.key和ca.crt两个文件
</p>
<p>
	
</p>
<p>
	3).生成服务端证书:
</p>
<p>
	# ./new-server-cert.sh server &nbsp;
</p>
<p>
	<span style="color:#E53333;">注:证书名为server</span>
</p>
<p>
	-----------------------------------------------------------------------------------------------
</p>
<p>
	……
</p>
<p>
	……
</p>
<p>
	Country Name (2 letter code) [MY]:CN
</p>
<p>
	State or &nbsp;Province Name (full name) [Perak]:JiangSu
</p>
<p>
	Locality Name (eg, city) &nbsp;[Sitiawan]:NanJing
</p>
<p>
	Organization Name (eg, company) [My Directory Sdn &nbsp;Bhd]:example Co.,Ltd
</p>
<p>
	Organizational Unit Name (eg, section) [Secure Web &nbsp;Server]:example
</p>
<p>
	Common Name (eg, <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a>) &nbsp;[]:www.example.com
</p>
<p>
	Email Address &nbsp;[]:info@example.com
</p>
<p>
	------------------------------------------------------------------------------------------------
</p>
<p>
	这样就生成了server.csr和server.key这两个文件。
</p>
<p>
	
</p>
<p>
	4).签署服务端证书:
</p>
<p>
	# &nbsp;./sign-server-cert.sh server
</p>
<p>
	--------------------------------------------------------------------------------------------
</p>
<p>
	CA signing: server.csr -&gt; &nbsp;server.crt:
</p>
<p>
	Using configuration from ca.config
</p>
<p>
	Enter pass phrase for &nbsp;./ca.key:&nbsp;(输入上面设置的根证书密码)
</p>
<p>
	Check that the request matches the &nbsp;signature
</p>
<p>
	Signature ok
</p>
<p>
	The Subject’s Distinguished Name is as &nbsp;follows
</p>
<p>
	countryName &nbsp; RINTABLE:’CN’
</p>
<p>
	stateOrProvinceName &nbsp; RINTABLE:’JiangSu’
</p>
<p>
	localityName &nbsp; RINTABLE:’NanJing’
</p>
<p>
	organizationName &nbsp; RINTABLE:’example Co.,Ltd’
</p>
<p>
	organizationalUnitName:PRINTABLE:’example’
</p>
<p>
	commonName &nbsp; RINTABLE:’www.example.com’
</p>
<p>
	emailAddress &nbsp;:IA5STRING:’info@example.com’
</p>
<p>
	Certificate is to be certified until Jul 16 &nbsp;12:55:34 2005 GMT (365 days)
</p>
<p>
	Sign the certificate? [y/n]:y
</p>
<p>
	1 out of 1 &nbsp;certificate requests certified, commit? [y/n]y
</p>
<p>
	Write out database with 1 new &nbsp;entries
</p>
<p>
	Data Base Updated
</p>
<p>
	CA verifying: server.crt &lt;-&gt; CA &nbsp;cert
</p>
<p>
	server.crt: OK
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	2.复制证书到cookbook相应位置
</p>
<p>
	# pwd
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	/root/<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>-repo/cookbooks/apache/files/default/certificates/ssl.ca-0.1
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	# cp server.crt server.key ca.crt ..
</p>
<p>
	# cd ..
</p>
<p>
	# ls
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	ca.crt &nbsp;server.crt &nbsp;server.key &nbsp;ssl.ca-0.1 &nbsp;ssl.ca-0.1.tar.gz
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	三. 定义cookbook变量属性&nbsp;(<a href="http://www.showerlee.com/archives/tag/chef-2" title="查看chef中的全部文章" class="tag_link">chef</a>.example.com)
</p>
<p>
	# cd ~/chef-repo/cookbooks/apache/attributes
</p>
<p>
	# vi default.rb
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	default['apache']['dir'] &nbsp; &nbsp; = "/etc/httpd"
</p>
<p>
	default['apache']['sslpath'] &nbsp; &nbsp;= "/etc/httpd/ssl"
</p>
<p>
	default['apache']['servername'] = "node1.example.com"
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	四.编写recipes(可按照实际部署需求修改)&nbsp;(chef.example.com)
</p>
<p>
	# cd ~/chef-repo/cookbooks/apache/recipes
</p>
<p>
	# vi default.rb
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	# Cookbook Name:: apache
</p>
<p>
	# Recipe:: default
</p>
<p>
	#
</p>
<p>
	# Copyright 2013, YOUR_COMPANY_NAME
</p>
<p>
	#
</p>
<p>
	# All rights reserved - Do Not Redistribute
</p>
<p>
	#
</p>
<p>
	
</p>
<p>
	# Install httpd package but don't start it
</p>
<p>
	package "httpd" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;action [:install]
</p>
<p>
	end
</p>
<p>
	
</p>
<p>
	# Install mod_ssl package to enable ssl module in apache
</p>
<p>
	package "mod_ssl" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;action [:install]
</p>
<p>
	end
</p>
<p>
	
</p>
<p>
	# Stop iptables service permanently
</p>
<p>
	service "iptables" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;action [:disable,:stop]
</p>
<p>
	end
</p>
<p>
	
</p>
<p>
	# Stop ip6tables service permanently&nbsp;
</p>
<p>
	service "ip6tables" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;action [:disable,:stop]
</p>
<p>
	end
</p>
<p>
	
</p>
<p>
	# Create /etc/httpd/ssl directory on chef client
</p>
<p>
	directory "#{node['apache']['dir']}/ssl" do<br />
<span style="line-height:1.5;">&nbsp; &nbsp; &nbsp; action :create</span>
</p>
<p>
	<span style="line-height:1.5;">&nbsp; &nbsp; &nbsp; recursive true</span>
</p>
<p>
	<span style="line-height:1.5;">&nbsp; &nbsp; &nbsp; mode 0755</span>
</p>
<p>
	<span style="line-height:1.5;">end</span>
</p>
<p>
	
</p>
<p>
	# Copy ssl certificates from certificates folder to client's /etc/httpd/ssl folder
</p>
<p>
	remote_directory "#{node['apache']['dir']}/ssl" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;source "certificates"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;files_owner "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;files_group "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;files_mode 00644
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;owner "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;group "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;mode 0755
</p>
<p>
	end
</p>
<p>
	
</p>
<p>
	# This will make changes to ssl.conf&nbsp;
</p>
<p>
	template "/etc/httpd/conf.d/ssl.conf" do
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;source "ssl.conf.erb"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;mode 0644
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;owner "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;group "root"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;variables(
</p>
<p>
	:sslcertificate =&gt; "#{node['apache']['sslpath']}/server.crt",
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:sslkey =&gt; "#{node['apache']['sslpath']}/server.key",
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:sslcacertificate =&gt; "#{node['apache']['sslpath']}/ca.crt",
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:servername =&gt; "#{node['apache']['servername']}"
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp;)
</p>
<p>
	end
</p>
<p>
	# start httpd service
</p>
<p>
	service "httpd" do
</p>
<p>
	&nbsp; &nbsp;action [:enable,:start]
</p>
<p>
	end
</p>
<p>
	<span style="line-height:1.5;">--------------------------------------------------------------------------------------</span>
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	五.定义templates&nbsp;(chef.example.com)
</p>
<p>
	
</p>
<p>
	<span style="color:#E53333;">注:这里实际上就是将apache原有的配置文件中需要修改的参数添加chef自有的变量属性,部署到client端,实现apache的自定义配置.</span>
</p>
<p>
	<span style="color:#E53333;">此处仅仅更改了SSL证书的具体路径,如果有其他需要可按此语法格式进行修改.</span>
</p>
<p>
	# cd ~/chef-repo/cookbooks/apache/templates/default
</p>
<p>
	# vi ssl.conf.erb
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	#
</p>
<p>
	# This is the Apache server configuration file providing SSL support.
</p>
<p>
	# It contains the configuration directives to instruct the server how to
</p>
<p>
	# serve pages over an https connection. For detailing information about these
</p>
<p>
	# directives see &lt;URL:<a href="http://httpd.apache.org/docs/2.2/mod/mod_ssl.html&#038;gt" rel="nofollow">http://httpd.apache.org/docs/2.2/mod/mod_ssl.html&#038;gt</a>;
</p>
<p>
	#
</p>
<p>
	# Do NOT simply read the instructions in here without understanding
</p>
<p>
	# what they do. &nbsp;They're here only as hints or reminders. &nbsp;If you are unsure
</p>
<p>
	# consult the online docs. You have been warned.
</p>
<p>
	#
</p>
<p>
	LoadModule ssl_module modules/mod_ssl.so
</p>
<p>
	#
</p>
<p>
	# When we also provide SSL we have to listen to the
</p>
<p>
	# the HTTPS port in addition.
</p>
<p>
	#
</p>
<p>
	Listen 443
</p>
<p>
	##
</p>
<p>
	## &nbsp;SSL Global Context
</p>
<p>
	##
</p>
<p>
	## &nbsp;All SSL configuration in this context applies both to
</p>
<p>
	## &nbsp;the main server and all SSL-enabled virtual hosts.
</p>
<p>
	##
</p>
<p>
	# &nbsp; Pass Phrase Dialog:
</p>
<p>
	# &nbsp; Configure the pass phrase gathering process.
</p>
<p>
	# &nbsp; The filtering dialog program (`builtin' is a internal
</p>
<p>
	# &nbsp; terminal dialog) has to provide the pass phrase on stdout.
</p>
<p>
	SSLPassPhraseDialog &nbsp;builtin
</p>
<p>
	# &nbsp; Inter-Process Session Cache:
</p>
<p>
	# &nbsp; Configure the SSL Session Cache: First the mechanism
</p>
<p>
	# &nbsp; to use and second the expiring timeout (in seconds).
</p>
<p>
	SSLSessionCache &nbsp; &nbsp; &nbsp; &nbsp; shmcb:/var/cache/mod_ssl/scache(512000)
</p>
<p>
	SSLSessionCacheTimeout &nbsp;300
</p>
<p>
	# &nbsp; Semaphore:
</p>
<p>
	# &nbsp; Configure the path to the mutual exclusion semaphore the
</p>
<p>
	# &nbsp; SSL engine uses internally for inter-process synchronization.
</p>
<p>
	SSLMutex default
</p>
<p>
	# &nbsp; Pseudo Random Number Generator (PRNG):
</p>
<p>
	# &nbsp; Configure one or more sources to seed the PRNG of the
</p>
<p>
	# &nbsp; SSL library. The seed data should be of good random quality.
</p>
<p>
	# &nbsp; WARNING! On some platforms /dev/random blocks if not enough entropy
</p>
<p>
	# &nbsp; is available. This means you then cannot use the /dev/random device
</p>
<p>
	# &nbsp; because it would lead to very long connection times (as long as
</p>
<p>
	# &nbsp; it requires to make more entropy available). But usually those
</p>
<p>
	# &nbsp; platforms additionally provide a /dev/urandom device which doesn't
</p>
<p>
	# &nbsp; block. So, if available, use this one instead. Read the mod_ssl User
</p>
<p>
	# &nbsp; Manual for more details.
</p>
<p>
	SSLRandomSeed startup file:/dev/urandom &nbsp;256
</p>
<p>
	SSLRandomSeed connect builtin
</p>
<p>
	#SSLRandomSeed startup file:/dev/random &nbsp;512
</p>
<p>
	#SSLRandomSeed connect file:/dev/random &nbsp;512
</p>
<p>
	#SSLRandomSeed connect file:/dev/urandom 512
</p>
<p>
	#
</p>
<p>
	# Use "SSLCryptoDevice" to enable any supported hardware
</p>
<p>
	# accelerators. Use "openssl engine -v" to list supported
</p>
<p>
	# engine names. &nbsp;NOTE: If you enable an accelerator and the
</p>
<p>
	# server does not start, consult the error logs and ensure
</p>
<p>
	# your accelerator is functioning properly.
</p>
<p>
	#
</p>
<p>
	SSLCryptoDevice builtin
</p>
<p>
	#SSLCryptoDevice ubsec
</p>
<p>
	##
</p>
<p>
	## SSL Virtual Host Context
</p>
<p>
	##
</p>
<p>
	&lt;VirtualHost _default_:443&gt;
</p>
<p>
	# General setup for the virtual host, inherited from global configuration
</p>
<p>
	#DocumentRoot "/var/www/html"
</p>
<p>
	ServerName <span style="color:#E53333;">&lt;%= @servername %&gt;:443</span>
</p>
<p>
	# Use separate log files for the SSL virtual host; note that LogLevel
</p>
<p>
	# is not inherited from httpd.conf.
</p>
<p>
	ErrorLog logs/ssl_error_log
</p>
<p>
	TransferLog logs/ssl_access_log
</p>
<p>
	LogLevel warn
</p>
<p>
	# &nbsp; SSL Engine Switch:
</p>
<p>
	# &nbsp; Enable/Disable SSL for this virtual host.
</p>
<p>
	SSLEngine on
</p>
<p>
	# &nbsp; SSL Protocol support:
</p>
<p>
	# List the enable protocol levels with which clients will be able to
</p>
<p>
	# connect. &nbsp;Disable SSLv2 access by default:
</p>
<p>
	SSLProtocol all -SSLv2
</p>
<p>
	# &nbsp; SSL Cipher Suite:
</p>
<p>
	# List the ciphers that the client is permitted to negotiate.
</p>
<p>
	# See the mod_ssl documentation for a complete list.
</p>
<p>
	SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
</p>
<p>
	# &nbsp; Server Certificate:
</p>
<p>
	# Point SSLCertificateFile at a PEM encoded certificate. &nbsp;If
</p>
<p>
	# the certificate is encrypted, then you will be prompted for a
</p>
<p>
	# pass phrase. &nbsp;Note that a kill -HUP will prompt again. &nbsp;A new
</p>
<p>
	# certificate can be generated using the genkey(1) command.
</p>
<p>
	SSLCertificateFile&nbsp;<span style="color:#E53333;">&lt;%= @sslcertificate %&gt;</span>
</p>
<p>
	# &nbsp; Server Private Key:
</p>
<p>
	# &nbsp; If the key is not combined with the certificate, use this
</p>
<p>
	# &nbsp; directive to point at the key file. &nbsp;Keep in mind that if
</p>
<p>
	# &nbsp; you've both a RSA and a DSA private key you can configure
</p>
<p>
	# &nbsp; both in parallel (to also allow the use of DSA ciphers, etc.)
</p>
<p>
	SSLCertificateKeyFile&nbsp;<span style="color:#E53333;">&lt;%= @sslkey %&gt;</span>
</p>
<p>
	# &nbsp; Server Certificate Chain:
</p>
<p>
	# &nbsp; Point SSLCertificateChainFile at a file containing the
</p>
<p>
	# &nbsp; concatenation of PEM encoded CA certificates which form the
</p>
<p>
	# &nbsp; certificate chain for the server certificate. Alternatively
</p>
<p>
	# &nbsp; the referenced file can be the same as SSLCertificateFile
</p>
<p>
	# &nbsp; when the CA certificates are directly appended to the server
</p>
<p>
	# &nbsp; certificate for convinience.
</p>
<p>
	#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
</p>
<p>
	# &nbsp; Certificate Authority (CA):
</p>
<p>
	# &nbsp; Set the CA certificate verification path where to find CA
</p>
<p>
	# &nbsp; certificates for client authentication or alternatively one
</p>
<p>
	# &nbsp; huge file containing all of them (file must be PEM encoded)
</p>
<p>
	SSLCACertificateFile&nbsp;<span style="color:#E53333;">&lt;%= @sslcacertificate %&gt;</span>
</p>
<p>
	# &nbsp; Client Authentication (Type):
</p>
<p>
	# &nbsp; Client certificate verification type and depth. &nbsp;Types are
</p>
<p>
	# &nbsp; none, optional, require and optional_no_ca. &nbsp;Depth is a
</p>
<p>
	# &nbsp; number which specifies how deeply to verify the certificate
</p>
<p>
	# &nbsp; issuer chain before deciding the certificate is not valid.
</p>
<p>
	#SSLVerifyClient require
</p>
<p>
	#SSLVerifyDepth &nbsp;10
</p>
<p>
	# &nbsp; Access Control:
</p>
<p>
	# &nbsp; With SSLRequire you can do per-directory access control based
</p>
<p>
	# &nbsp; on arbitrary complex boolean expressions containing server
</p>
<p>
	# &nbsp; variable checks and other lookup directives. &nbsp;The syntax is a
</p>
<p>
	# &nbsp; mixture between C and Perl. &nbsp;See the mod_ssl documentation
</p>
<p>
	# &nbsp; for more details.
</p>
<p>
	#&lt;Location /&gt;
</p>
<p>
	#SSLRequire ( &nbsp; &nbsp;%{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
</p>
<p>
	# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
</p>
<p>
	# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
</p>
<p>
	# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and %{TIME_WDAY} &gt;= 1 and %{TIME_WDAY} &lt;= 5 \
</p>
<p>
	# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and %{TIME_HOUR} &gt;= 8 and %{TIME_HOUR} &lt;= 20 &nbsp; &nbsp; &nbsp; ) \
</p>
<p>
	# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
</p>
<p>
	#&lt;/Location&gt;
</p>
<p>
	# &nbsp; SSL Engine Options:
</p>
<p>
	# &nbsp; Set various options for the SSL engine.
</p>
<p>
	# &nbsp; o FakeBasicAuth:
</p>
<p>
	# &nbsp; &nbsp; Translate the client X.509 into a Basic Authorisation. &nbsp;This means that
</p>
<p>
	# &nbsp; &nbsp; the standard Auth/DBMAuth methods can be used for access control. &nbsp;The
</p>
<p>
	# &nbsp; &nbsp; user name is the `one line' version of the client's X.509 certificate.
</p>
<p>
	# &nbsp; &nbsp; Note that no password is obtained from the user. Every entry in the user
</p>
<p>
	# &nbsp; &nbsp; file needs this password: `xxj31ZMTZzkVA'.
</p>
<p>
	# &nbsp; o ExportCertData:
</p>
<p>
	# &nbsp; &nbsp; This exports two additional environment variables: SSL_CLIENT_CERT and
</p>
<p>
	# &nbsp; &nbsp; SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
</p>
<p>
	# &nbsp; &nbsp; server (always existing) and the client (only existing when client
</p>
<p>
	# &nbsp; &nbsp; authentication is used). This can be used to import the certificates
</p>
<p>
	# &nbsp; &nbsp; into CGI scripts.
</p>
<p>
	# &nbsp; o StdEnvVars:
</p>
<p>
	# &nbsp; &nbsp; This exports the standard SSL/TLS related `SSL_*' environment variables.
</p>
<p>
	# &nbsp; &nbsp; Per default this exportation is switched off for performance reasons,
</p>
<p>
	# &nbsp; &nbsp; because the extraction step is an expensive operation and is usually
</p>
<p>
	# &nbsp; &nbsp; useless for serving static content. So one usually enables the
</p>
<p>
	# &nbsp; &nbsp; exportation for CGI and SSI requests only.
</p>
<p>
	# &nbsp; o StrictRequire:
</p>
<p>
	# &nbsp; &nbsp; This denies access when "SSLRequireSSL" or "SSLRequire" applied even
</p>
<p>
	# &nbsp; &nbsp; under a "Satisfy any" situation, i.e. when it applies access is denied
</p>
<p>
	# &nbsp; &nbsp; and no other module can change it.
</p>
<p>
	# &nbsp; o OptRenegotiate:
</p>
<p>
	# &nbsp; &nbsp; This enables optimized SSL connection renegotiation handling when SSL
</p>
<p>
	# &nbsp; &nbsp; directives are used in per-directory context.
</p>
<p>
	#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
</p>
<p>
	&lt;Files ~ "\.(cgi|shtml|phtml|php3?)$"&gt;
</p>
<p>
	&nbsp; &nbsp;SSLOptions +StdEnvVars
</p>
<p>
	&lt;/Files&gt;
</p>
<p>
	&lt;Directory "/var/www/cgi-bin"&gt;
</p>
<p>
	&nbsp; &nbsp;SSLOptions +StdEnvVars
</p>
<p>
	&lt;/Directory&gt;
</p>
<p>
	# &nbsp; SSL Protocol Adjustments:
</p>
<p>
	# &nbsp; The safe and default but still SSL/TLS standard compliant shutdown
</p>
<p>
	# &nbsp; approach is that mod_ssl sends the close notify alert but doesn't wait for
</p>
<p>
	# &nbsp; the close notify alert from client. When you need a different shutdown
</p>
<p>
	# &nbsp; approach you can use one of the following variables:
</p>
<p>
	# &nbsp; o ssl-unclean-shutdown:
</p>
<p>
	# &nbsp; &nbsp; This forces an unclean shutdown when the connection is closed, i.e. no
</p>
<p>
	# &nbsp; &nbsp; SSL close notify alert is send or allowed to received. &nbsp;This violates
</p>
<p>
	# &nbsp; &nbsp; the SSL/TLS standard but is needed for some brain-dead browsers. Use
</p>
<p>
	# &nbsp; &nbsp; this when you receive I/O errors because of the standard approach where
</p>
<p>
	# &nbsp; &nbsp; mod_ssl sends the close notify alert.
</p>
<p>
	# &nbsp; o ssl-accurate-shutdown:
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; &nbsp; This forces an accurate shutdown when the connection is closed, i.e. a</span>
</p>
<p>
	# &nbsp; &nbsp; SSL close notify alert is send and mod_ssl waits for the close notify
</p>
<p>
	# &nbsp; &nbsp; alert of the client. This is 100% SSL/TLS standard compliant, but in
</p>
<p>
	# &nbsp; &nbsp; practice often causes hanging connections with brain-dead browsers. Use
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; &nbsp; this only for browsers where you know that their SSL implementation</span>
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; &nbsp; works correctly.</span>
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; Notice: Most problems of broken clients are also related to the HTTP</span>
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; keep-alive facility, so you usually additionally want to disable</span>
</p>
<p>
	<span style="line-height:1.5;"># &nbsp; keep-alive for those clients, too. Use variable "nokeepalive" for this.</span>
</p>
<p>
	# &nbsp; Similarly, one has to force some clients to use HTTP/1.0 to workaround
</p>
<p>
	# &nbsp; their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
</p>
<p>
	# &nbsp; "force-response-1.0" for this.
</p>
<p>
	SetEnvIf User-Agent ".*MSIE.*" \
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; nokeepalive ssl-unclean-shutdown \
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; downgrade-1.0 force-response-1.0
</p>
<p>
	# &nbsp; Per-Server Logging:
</p>
<p>
	# &nbsp; The home of a custom SSL log file. Use this when you want a
</p>
<p>
	# &nbsp; compact non-error SSL logfile on a virtual host basis.
</p>
<p>
	CustomLog logs/ssl_request_log \
</p>
<p>
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</p>
<p>
	
</p>
<p>
	&lt;/VirtualHost&gt;
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	六.上传cookbook&nbsp;(chef.example.com)
</p>
<p>
	# cd /root/chef-repo/cookbooks
</p>
<p>
	# knife cookbook upload apache
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	Uploading apache &nbsp; &nbsp; &nbsp; &nbsp; [0.1.0]
</p>
<p>
	Uploaded 1 cookbook.
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	七.创建Role&nbsp;(chef.example.com)
</p>
<p>
	<span style="color:#E53333;">注:简单来说Role就是实现一个能在Server端批量下发cookbook并自动开始对所有client的部署,此前的方法部署client端需要登录其SHELL执行chef-client,方能开始部署,少量部署无所谓,但批量的话执行效率会大大降低.</span>
</p>
<p>
	1). 设置editor环境变量
</p>
<p>
	# echo 'export EDITOR=$(which vi)' &gt;&gt; ~/.bashrc
</p>
<p>
	# source ~/.bashrc
</p>
<p>
	
</p>
<p>
	2). 编写Role,将默认替换成如下内容.
</p>
<p>
	# knife role create webserver
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	{
</p>
<p>
	&nbsp;"run_list": [
</p>
<p>
	&nbsp; &nbsp;"recipe[apache]"
</p>
<p>
	&nbsp;],
</p>
<p>
	&nbsp;"chef_type": "role",
</p>
<p>
	&nbsp;"env_run_lists": {
</p>
<p>
	&nbsp;},
</p>
<p>
	&nbsp;"description": "apache webserver",
</p>
<p>
	&nbsp;"override_attributes": {
</p>
<p>
	&nbsp;},
</p>
<p>
	&nbsp;"json_class": "Chef::Role",
</p>
<p>
	&nbsp;"default_attributes": {
</p>
<p>
	&nbsp;},
</p>
<p>
	&nbsp;"name": "webserver"
</p>
<p>
	}
</p>
<p>
	--------------------------------------------------------------------------------------
</p>
<p>
	
</p>
<p>
	八. Bootstrap客户端.
</p>
<p>
	<span style="color:#E53333;">注: bootstrap是一个将CHEF具体的cookbook实例部署到目标客户端的程序,因此他可以在server端实现client本地执行最后部署命令chef-client的功能</span>
</p>
<p>
	1. 首先需要做一个CHEF的server端到client端的SSH秘钥认证,实现server端无需输入SSH密码即可登录client执行部署.
</p>
<p>
	1) .在CHEF的Server端(SSH客户端)创建秘钥对：(chef.example.com)
</p>
<p>
	# su - root
</p>
<p>
	# ssh-keygen -t dsa
</p>
<p>
	一路回车即可
</p>
<p>
	----------------------
</p>
<p>
	Generating public/private dsa key pair.
</p>
<p>
	<span style="line-height:1.5;">Enter file in which to save the key (/root/.ssh/id_dsa):</span>
</p>
<p>
	<span style="line-height:1.5;">Created directory '/root/.ssh'.</span>
</p>
<p>
	<span style="line-height:1.5;">Enter passphrase (empty for no passphrase):</span>
</p>
<p>
	<span style="line-height:1.5;">Enter same passphrase again:</span>
</p>
<p>
	Your identification has been saved in /root/.ssh/id_dsa.
</p>
<p>
	Your public key has been saved in /root/.ssh/id_dsa.pub.
</p>
<p>
	The key fingerprint is:
</p>
<p>
	e9:5e:4a:7f:79:64:c5:ae:f2:06:a7:26:e4:41:5c:0e <a href="mailto:root@chef.example.com">root@chef.example.com</a>
</p>
<p>
	The key's randomart image is:
</p>
<p>
	+--[ DSA 1024]----+
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;E . &nbsp; &nbsp;|
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp; . + &nbsp; . |
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp; .o . &nbsp; o|
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp;S. &nbsp; &nbsp; o |
</p>
<p>
	| &nbsp; &nbsp; &nbsp; . &nbsp;o . + .|
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp;oo.. B . |
</p>
<p>
	| &nbsp; &nbsp; &nbsp; o +o * + &nbsp;|
</p>
<p>
	| &nbsp; &nbsp; &nbsp; &nbsp;o .+ =. &nbsp;|
</p>
<p>
	+-----------------+
</p>
<p>
	----------------------
</p>
<p>
	
</p>
<p>
	2). 查看生成的秘钥对：(chef.example.com)
</p>
<p>
	# ls -lda ~/.ssh
</p>
<p>
	-----------------
</p>
<p>
	drwx------ 2 root root 4096 6月 &nbsp; 6 23:03 .ssh
</p>
<p>
	-----------------
</p>
<p>
	# cd .ssh
</p>
<p>
	# ls -la
</p>
<p>
	------------------
</p>
<p>
	总用量 16
</p>
<p>
	drwx------ &nbsp; 2 root root 4096 6月 &nbsp; 6 23:03 .
</p>
<p>
	dr-xr-x---. 26 root root 4096 6月 &nbsp; 6 23:03 ..
</p>
<p>
	-rw------- &nbsp; 1 root root &nbsp;668 6月 &nbsp; 6 23:03 id_dsa
</p>
<p>
	-rw-r--r-- &nbsp; 1 root root &nbsp;613 6月 &nbsp; 6 23:03 id_dsa.pub
</p>
<p>
	------------------
</p>
<p>
	秘钥生成完毕
</p>
<p>
	
</p>
<p>
	3) .将公钥（锁）分发到SSH服务端(CHEF客户端)：(chef.example.com)
</p>
<p>
	# ssh-copy-id -i .ssh/id_dsa.pub node1.example.com
</p>
<p>
	<span style="color:#E53333;">注：若非root用户，以及自定义SSH端口，则格式为：</span>
</p>
<p>
	# ssh-copy-id -i .ssh/id_rsa.pub "-p 22 user@server"
</p>
<p>
	输入yes,然后密码后回车：
</p>
<p>
	----------------------------
</p>
<p>
	The authenticity of host 'node1.example.com (10.107.91.252)' can't be established.
</p>
<p>
	RSA key fingerprint is fc:9b:2e:38:3b:04:18:67:16:8f:dd:94:a8:bd:08:03.
</p>
<p>
	Are you sure you want to continue connecting (yes/no)? yes
</p>
<p>
	Warning: Permanently added 'node1.example.com' (RSA) to the list of known hosts.
</p>
<p>
	Address node1.example.com maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
</p>
<p>
	<a href="mailto:root@node1.example.com">root@node1.example.com</a>'s password: &nbsp;输入密码
</p>
<p>
	Now try logging into the machine, with "ssh 'node1.example.com'", and check in:</p>
<p>&nbsp;.ssh/authorized_keys</p>
<p>to make sure we haven't added extra keys that you weren't expecting.
</p>
<p>
	-----------------------------
</p>
<p>
	公钥分发完毕
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	4) .SSH服务端(CHEF客户端)查看收到的分发文件：(node1.example.com)
</p>
<p>
	
</p>
<p>
	# ll /root/.ssh
</p>
<p>
	-------------
</p>
<p>
	总用量 4
</p>
<p>
	-rw------- 1 root root 613 6月 &nbsp; 6 23:29 authorized_keys
</p>
<p>
	-------------
</p>
<p>
	成功收到
</p>
<p>
	
</p>
<p>
	2.执行bootstrap部署&nbsp;(chef.example.com)
</p>
<p>
	# knife bootstrap node1.example.com -x root --sudo -r "role[webserver]"
</p>
<p>
	-------------------------------------------------------------------------------------------------------------- &nbsp;
</p>
<p>
	Connecting to node1.example.com
</p>
<p>
	node1.example.com Starting first Chef Client run...
</p>
<p>
	node1.example.com [2014-05-09T06:08:53+08:00] WARN:&nbsp;
</p>
<p>
	node1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *&nbsp;
</p>
<p>
	node1.example.com SSL validation of HTTPS requests is disabled. HTTPS connections are still
</p>
<p>
	node1.example.com encrypted, but chef is not able to detect forged replies or man in the middle
</p>
<p>
	node1.example.com attacks.
</p>
<p>
	node1.example.com&nbsp;
</p>
<p>
	node1.example.com To fix this issue add an entry like this to your configuration file:
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com ```</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; # Verify all HTTPS connections (recommended)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; ssl_verify_mode :verify_peer</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; # OR, Verify only connections to chef-server</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; verify_api_cert true</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com ```</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com To check your SSL configuration, or troubleshoot errors, you can use the</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com `knife ssl check` command like so:</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com ```</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; knife ssl check -c /etc/chef/client.rb</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com ```</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com&nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com Starting Chef Client, version 11.12.4</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com resolving cookbooks for run list: ["apache"]</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com Synchronizing Cookbooks:</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; - apache</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com Compiling Cookbooks...</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com Converging 8 resources</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com Recipe: apache::default</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * package[httpd] action install (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * package[mod_ssl] action install (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * service[iptables] action disable (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * service[iptables] action stop (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * service[ip6tables] action disable (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * service[ip6tables] action stop (up to date)</span>
</p>
<p>
	<span style="line-height:1.5;">node1.example.com &nbsp; * directory[/etc/httpd/ssl] action create (up to date)</span>
</p>
<p>
	node1.example.com &nbsp; * remote_directory[/etc/httpd/ssl] action createRecipe: &lt;Dynamically Defined Resource&gt;
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/sign-user-cert.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/sign-server-cert.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.key] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.csr] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.crt] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/random-bits] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/p12.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-user-cert.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-server-cert.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-root-ca.sh] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.key] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.serial] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.index.attr] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.index] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.certs/01.pem] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.crt] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/VERSION] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/README] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/COPYING] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1.tar.gz] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/server.key] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/server.crt] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * cookbook_file[/etc/httpd/ssl/ca.crt] action create (up to date)
</p>
<p>
	node1.example.com &nbsp;(up to date)
</p>
<p>
	node1.example.com Recipe: apache::default
</p>
<p>
	node1.example.com &nbsp; * template[/etc/httpd/conf.d/ssl.conf] action create (up to date)
</p>
<p>
	node1.example.com &nbsp; * service[httpd] action enable (up to date)
</p>
<p>
	node1.example.com &nbsp; * service[httpd] action start (up to date)
</p>
<p>
	node1.example.com&nbsp;
</p>
<p>
	node1.example.com Running handlers:
</p>
<p>
	node1.example.com Running handlers complete
</p>
<p>
	node1.example.com&nbsp;
</p>
<p>
	node1.example.com Chef Client finished, 0/34 resources updated in 9.1690343 seconds
</p>
<p>
	-------------------------------------------------------------------------------------------------------------- &nbsp;
</p>
<p>
	部署成功....
</p>
<p>
	
</p>
<p>
	九.验证&nbsp;(node1.example.com)
</p>
<p>
	<span style="line-height:1.5;"># cd /etc/httpd/</span>
</p>
<p>
	<span style="line-height:1.5;"># ls</span>
</p>
<p>
	<span style="line-height:1.5;">-------------------------------------------------------------------------------------------------------------- &nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">conf &nbsp;conf.d &nbsp;logs &nbsp;modules &nbsp;run &nbsp;ssl</span>
</p>
<p>
	<span style="line-height:1.5;">-------------------------------------------------------------------------------------------------------------- &nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;"># service httpd status</span>
</p>
<p>
	<span style="line-height:1.5;">-------------------------------------------------------------------------------------------------------------- &nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;">httpd (pid &nbsp;10492) is running...</span>
</p>
<p>
	<span style="line-height:1.5;">-------------------------------------------------------------------------------------------------------------- &nbsp;</span>
</p>
<p>
	<span style="line-height:1.5;"># lsof -i:80</span>
</p>
<p>
	<span style="line-height:1.5;">--------------------------------------------------------------------------------------------------------------</span>
</p>
<p>
	COMMAND &nbsp; PID &nbsp; USER &nbsp; FD &nbsp; TYPE DEVICE SIZE/OFF NODE NAME
</p>
<p>
	<span style="line-height:1.5;">httpd &nbsp; 10492 &nbsp; root &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)</span>
</p>
<p>
	httpd &nbsp; 10494 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	httpd &nbsp; 10495 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	httpd &nbsp; 10496 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	httpd &nbsp; 10497 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	httpd &nbsp; 10498 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	httpd &nbsp; 10499 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)
</p>
<p>
	<span style="line-height:1.5;">httpd &nbsp; 10500 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)</span>
</p>
<p>
	<span style="line-height:1.5;">httpd &nbsp; 10501 apache &nbsp; &nbsp;4u &nbsp;IPv6 &nbsp;48097 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:http (LISTEN)</span>
</p>
<p>
	# lsof -i:443
</p>
<p>
	--------------------------------------------------------------------------------------------------------------
</p>
<p>
	COMMAND &nbsp; PID &nbsp; USER &nbsp; FD &nbsp; TYPE DEVICE SIZE/OFF NODE NAME
</p>
<p>
	httpd &nbsp; 10492 &nbsp; root &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10494 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10495 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10496 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10497 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10498 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10499 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10500 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	httpd &nbsp; 10501 apache &nbsp; &nbsp;6u &nbsp;IPv6 &nbsp;48101 &nbsp; &nbsp; &nbsp;0t0 &nbsp;TCP *:https (LISTEN)
</p>
<p>
	--------------------------------------------------------------------------------------------------------------
</p>
<p>
	如图:
</p>
<p>
	<a href="http://www.showerlee.com/wp-content/uploads/2014/05/5.jpg"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/05/5-1024x749.jpg" alt="5" width="1024" height="749" /></a>
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	大功告成。。。。
</p>
<p></p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/1145">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="CentOS 6.3下CHEF批量部署APACHE" href="http://www.showerlee.com/archives/1145">http://www.showerlee.com/archives/1145</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/1145/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>windows下实现wamp与tomcat环境整合</title>
		<link>http://www.showerlee.com/archives/1077</link>
		<comments>http://www.showerlee.com/archives/1077#comments</comments>
		<pubDate>Thu, 06 Feb 2014 07:23:01 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>
		<category><![CDATA[WEB]]></category>
		<category><![CDATA[wamp]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=1077</guid>
		<description><![CDATA[过年期间一直在研究PHP,好久没给大家更新文档了,刚好今天闲下来时间帮朋友解决一些系统环境方面问题时,关注了下 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	过年期间一直在研究PHP,好久没给大家更新文档了,刚好今天闲下来时间帮朋友解决一些系统环境方面问题时,关注了下如何实现<a href="http://www.showerlee.com/archives/tag/wamp" title="查看wamp中的全部文章" class="tag_link">wamp</a>与tomcat在windows下的测试环境整合,网上查了下杂七杂八的资料,各种凌乱,不过运气还好,用了一下午时间终于搞定,现将整合方法贴出来,供大家分享...
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	windows下环境配置相对较linux下简单,这里我们就开始干活...
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	操作系统: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Windows7_sp1_x64
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	WAMP: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WampServer Version 2.4
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	TOMCAT: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Apache-tomcat-7.0.50
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	jdk: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Jdk1.7.0_17
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	tomcat-connectors: &nbsp;tomcat-connectors-1.2.37-windows-x86_64-httpd-2.4.x
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">注:这个tomcat-connectors是一个压缩包,解压后有一个mod_jk.so的模块,可以理解为是apache的一个扩展模块,作用其实和我们平时使用WAMP或LAMP平台加载PHP扩展模块是一个道理,就是tomcat-connectors作为一个接口,让apache可以识别jsp语言,实现web页面解析,平时我们通常使用apache-tomcat这个通用web服务开启8080端口实现jsp解析,这里等于是apache去调用tomcat8080端口实现apache80端口jsp解析</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">刚好朋友想实现jsp和php同目录混编,利用这种方法即可实现.</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">之前实现apache-tomcat与apache对接的老方法是利用apache的代理功能,将访问80端口的请求统一跳转到tomcat的8080端口上,算是一种解决方案,但能否实现jsp和php同目录混编,有待进一步考证.</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	一.安装WAMP
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	下载地址:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://optimate.dl.sourceforge.net/project/wampserver/WampServer%202/Wampserver%202.4/Wampserver2.4-x64.exe" target="_blank">http://optimate.dl.sourceforge.net/project/wampserver/WampServer%202/Wampserver%202.4/Wampserver2.4-x64.exe</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	这个不用多讲了吧,各种无脑下一步,最后安装完毕,双击桌面的WampServer图标即可.
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	二.安装jdk和apache-tomcat
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	下载地址:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-windows-x64.exe" target="_blank">http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-windows-x64.exe</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://mirror.esocc.com/apache/tomcat/tomcat-7/v7.0.50/bin/apache-tomcat-7.0.50.exe" target="_blank">http://mirror.esocc.com/apache/tomcat/tomcat-7/v7.0.50/bin/apache-tomcat-7.0.50.exe</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	这里建议将apache-tomcat安装到<a href="http://www.showerlee.com/archives/tag/wamp" title="查看wamp中的全部文章" class="tag_link">wamp</a>目录下
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	如图:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://www.showerlee.com/wp-content/uploads/2014/02/2.jpg"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/02/2.jpg" alt="2" width="798" height="553" class="alignnone size-full wp-image-1079" /></a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	三.配置tomcat-connectors
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	1.下载匹配环境的tomcat-connectors,这里我们使用的是匹配apache2.4和win7_x64的版本
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	下载地址:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.37-windows-x86_64-httpd-2.4.x.zip" target="_blank">http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/tomcat-connectors-1.2.37-windows-x86_64-httpd-2.4.x.zip</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	2.下载完毕,将压缩包内的mod_jk.so解压到<a href="http://www.showerlee.com/archives/tag/wamp" title="查看wamp中的全部文章" class="tag_link">wamp</a>目录下apache的module目录中
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	如图:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://www.showerlee.com/wp-content/uploads/2014/02/1.jpg"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/02/1.jpg" alt="1" width="797" height="188" class="alignnone size-full wp-image-1078" /></a><span style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;line-height:21px;background-color:#FFFFFF;"></span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	3.进入Tomcat文件夹下的conf目录,创建workers.properties文件
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	内容如下：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	--------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	workers.tomcat_home="E:\Program Files\wamp\tomcat"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	workers.java_home="C:\Program Files\Java\jdk1.7.0_17"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	worker.list=ajp13
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	worker.ajp13.port=8009
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	worker.ajp13.type=ajp13
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	worker.ajp13.host=localhost
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	worker.ajp13.lbfactor=1
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	--------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">注:workers.tomcat_home和workers.java_home分别为你的tomcat和jdk安装目录</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	4.配置tomcat的conf目录下的server.xml文件,修改tomcat默认根目录到WAMP的apache根目录
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	搜索"&lt;Host"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	将
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;Host name="localhost" &nbsp;appBase="webapps"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unpackWARs="true" autoDeploy="true"&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	------------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	改成
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;Host name="localhost" &nbsp;appBase=<span style="color:#FF0000;">"H:\MyProject"</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unpackWARs="true" autoDeploy="true"&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	------------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">注:这里的"H:\MyProject"为我自定义的apache的DocumentRoot根目录,安装好默认目录在E:\Program Files\wamp\www下,这里请注意</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;"><br />
</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	并在该行下添加如下内容:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	------------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;Context path="" docBase="H:\MyProject"&gt;&lt;/Context&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	------------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	5.配置apache主配置文件,加载mod_jk.so模块
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">注:确保之前将下载的JK包中的mod_jk.so解压到apache的module目录下</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	在E:\Program Files\wamp\bin\apache\Apache2.4.4\conf\http.conf中加入下面内容：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	----------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	LoadModule jk_module modules/mod_jk.so
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	JkWorkersFile "E:/Program Files/wamp/tomcat/conf/workers.properties"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	JkLogFile "E:/Program Files/wamp/bin/apache/Apache2.4.4/logs/mod_jk.log"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	JkMount /*.jsp ajp13
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	JkMount /servlet/* ajp13
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	JkLogLevel info
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	----------------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	6.重启tomcat与apache服务,测试jsp页面是否加载
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	在<span style="color:#FF0000;">H:\MyProject</span>下创建test.jsp文件，内容如下：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	--------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;%@ page contentType="text/html;charset=gb2312" %&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp;&lt;HTML&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; &nbsp;&lt;HEAD&gt;&lt;TITLE&gt;JSP测试页面&lt;/TITLE&gt;&lt;/HEAD&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; &nbsp;&lt;BODY&gt;&lt;%out.println("&lt;h1&gt;Hello World! &lt;/h1&gt;");%&gt;&lt;/BODY&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp;&lt;/HTML&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	---------------------------------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	打开浏览器,访问如下页面
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://localhost/test.jsp" target="_blank">http://localhost/test.jsp</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<a href="http://localhost/test.jsp" target="_blank">http://localhost:8080/test.jsp</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	如图:
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<br />
<a href="http://www.showerlee.com/wp-content/uploads/2014/02/3.jpg"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/02/3.jpg" alt="3" width="679" height="188" class="alignnone size-full wp-image-1080" /></a><span></span><a href="http://www.showerlee.com/wp-content/uploads/2014/02/6.jpg"><img onerror="javascript:this.src='http://www.showerlee.com/wp-content/themes/BYMT/images/images_error.jpg'" src="http://www.showerlee.com/wp-content/uploads/2014/02/6.jpg" alt="6" width="578" height="195" class="alignnone size-large wp-image-1081" /></a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	测试成功,说明apache调用tomcat进行jsp页面解析成功...
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">注:这里需要保证tomcat与apache同时开启</span></p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/1077">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="windows下实现wamp与tomcat环境整合" href="http://www.showerlee.com/archives/1077">http://www.showerlee.com/archives/1077</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/1077/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache中多个HTTPS虚拟主机的实现</title>
		<link>http://www.showerlee.com/archives/825</link>
		<comments>http://www.showerlee.com/archives/825#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:57:01 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>
		<category><![CDATA[HTTPS]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=825</guid>
		<description><![CDATA[要实现一个Apache服务器上提供多个SSL虚拟主机， 可以： * 使用多域名SSL证书，可以实现一个IP，一 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="font-family:SimSun;color:#666666;font-size:14px;">要实现</span><span style="font-family:SimSun;font-weight:bold;color:#666666;font-size:14px;">一个Apache服务器上提供多个SSL虚拟主机</span><span style="font-family:SimSun;color:#666666;font-size:14px;">，</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;font-size:14px;">可以：</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;font-size:14px;">* 使用多域名SSL证书，可以实现一个IP，一个443端口上多个SSL虚拟主机；</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;font-size:14px;">* 一个ip，为所有SSL虚拟主机配置单独的端口。比如，默认的虚拟主机使用443，其他的使用8080或8081等，且每个SSL虚</span><span style="color:#666666;font-family:SimSun;font-size:14px;">拟主机必须独占一个端口；</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;font-size:14px;">* 为Apache服务器配置多个IP，每个SSL虚拟主机独占IP。如果只有一张物理网卡，可以配置为网卡配置子接口；</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;font-size:14px;">* 使用mod_gnutls模块，创建多个SSL虚拟主机&nbsp;</span>
</p>
<p>
	
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-weight:bold;"><br />
</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-weight:bold;font-size:14px;">1. Apache中同一IP多个<a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>虚拟主机的实现</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">在 Apache 文档中提到，不能在单个 IP 上同时有多个按名字识别的虚拟主机("named virtual host")。不完全是这样。</span>
</p>
<p><span><span style="color:#666666;font-family:SimSun;"> </p>
<p>
	
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>协议的过程是：服务器首先与客户机之间进行服务器身份验证并协商安全会话，然后，客户端向服务器发送 HTTP 请求。这样一来，在客户端开始发送HTTP请求之前，服务器就已经把证书发给了客户端（客户端根据本地的根证书去验证证书链，等等）。而最重要的是，为了表明身份，这个证书的"Common Name"填写的应该是域名，否则浏览器会给出警告。</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">既然在这个过程中，客户端就所访问的域名所处的地位是"被告知"的地位，因此，客户端再发出的 Host: 请求头也就显得不那么有意义了。另一方面，如果客户请求的域名与Common Name不符，浏览器也会给出警告。至少，在表面上看是这样。</span>
</p>
<p></span> </span> </p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">不过，对于自行签署的证书，以及一些发证机构而言，其实还可以签署一种普适<a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>证书，这种证书的</span></span><span style="color:#666666;font-family:SimSun;font-size:14px;">Common Name</span><span><span style="color:#666666;font-family:SimSun;font-size:14px;">一栏是 *.domain.tld 这样的形式，即其主机名部分可以是任意字符串，而只有域名部分是确定的。</span><br />
<span style="color:#666666;font-family:SimSun;font-size:14px;">当然，这种证书的安全性有一定的负面影响：由于一个证书可以验证整个域下面的所有服务器，一旦其被破解，则所有加密通讯也就同时失密了（当然，可以每台服务器使用自己的单独的证书），不过这个问题并不是太严重，通常还算是尚可接受的范围。另一个潜在的影响是，某些手机上运行的浏览器不能正确处理这种证书，不过这个问题仅限于希望给手机提供服务的网站。</span><br />
<span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">因此，简而言之，符合这样几个条件的前提下，是可以在同一个IP上部署多个<a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>虚拟主机的：</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">a) 这些虚拟主机是同属于同一域名的子域名&nbsp;</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">b) 拥有普适证书&nbsp;</span></span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;font-size:14px;">c) 正确地配置Apache。</span><br />
<span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span><span style="color:#666666;font-size:14px;font-family:SimSun;">如果</span><span style="font-weight:bold;color:#666666;font-family:SimSun;font-size:14px;">要在一个IP地址上需要部署多个SSL网站</span><span style="color:#666666;font-family:SimSun;font-size:14px;">，</span></span>
</p>
<p>
	<span><span style="color:#FF0000;"><span style="color:#666666;font-family:SimSun;font-size:14px;">（1）</span><span style="color:#666666;font-family:SimSun;font-size:14px;">一种方法</span></span><span style="color:#666666;font-family:SimSun;font-size:14px;">：如果要</span><span style="color:#666666;font-family:SimSun;font-size:14px;">在同一个IP地址的443端口上部署多个网站，必须保证这些网站的域名都能匹配相同的一张SSL证书。</span><span style="color:#666666;font-family:SimSun;font-size:14px;">这是因为</span><span style="color:#666666;font-family:SimSun;font-size:14px;">SSL握手协议</span><span style="color:#666666;font-family:SimSun;font-size:14px;">过程中,是</span><span style="color:#666666;font-family:SimSun;font-size:14px;">通过IP+Port来进行通信，一个IP的一个端口只能返给客户一张SSL证书（即使有多张证书，也只能返回第一张，因为无法分辨用户会需要返回哪张证书），如果这张证书能够满足这些网站的主机名匹配要求（访问b.test.com时，使用a.test.com段的证书，证书中包含a.test.com,于虚拟主机中的主机名之一匹配），就可以使用。</span><br />
<span style="color:#666666;font-family:SimSun;font-size:14px;">一般能匹配多个主机名的证书有通配符证书*.domain.com和多域名证书(www.domain.com,ftp.domain.com 等)，以下我们提供一个典型同一个IP上的多主机名部署配置，www.domain.com对应的根目录在WWW下，ftp.domain.com对应的根目录在FTP下，</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">当然，这种证书的安全性有一定的负面影响：由于一个证书可以验证整个域下面的所有服务器，一旦其被破解，则所有加密通讯也就同时失密了（当然，可以每台服务器使用自己的单独的证书），不过这个问题并不是太严重，通常还算是尚可接受的范围。另一个潜在的影响是，某些手机上运行的浏览器不能正确处理这种证书，不过这个问题仅限于希望给手机提供服务的网站。</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">因此，简而言之，符合这样几个条件的前提下，是可以在同一个IP上部署多个<a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>虚拟主机的：</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">a) 这些虚拟主机是同属于同一域名的子域名&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">b) 拥有普适证书&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">c) 正确地配置Apache。</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;font-size:14px;">如果</span><span style="font-weight:bold;color:#666666;font-family:SimSun;font-size:14px;">要在一个IP地址上需要部署多个SSL网站</span><span style="color:#666666;font-family:SimSun;font-size:14px;">，</span></span>
</p>
<p>
	<span style="color:#FF0000;"><span style="color:#666666;font-family:SimSun;font-size:14px;">（1）</span><span style="color:#666666;font-family:SimSun;font-size:14px;">一种方法</span></span><span style="color:#666666;font-family:SimSun;font-size:14px;">：如果要</span><span style="color:#666666;font-family:SimSun;font-size:14px;">在同一个IP地址的443端口上部署多个网站，必须保证这些网站的域名都能匹配相同的一张SSL证书。</span><span style="color:#666666;font-family:SimSun;font-size:14px;">这是因为</span><span style="color:#666666;font-family:SimSun;font-size:14px;">SSL握手协议</span><span style="color:#666666;font-family:SimSun;font-size:14px;">过程中,是</span><span style="color:#666666;font-family:SimSun;font-size:14px;">通过IP+Port来进行通信，一个IP的一个端口只能返给客户一张SSL证书（即使有多张证书，也只能返回第一张，因为无法分辨用户会需要返回哪张证书），如果这张证书能够满足这些网站的主机名匹配要求（访问b.test.com时，使用a.test.com段的证书，证书中包含a.test.com,于虚拟主机中的主机名之一匹配），就可以使用。</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">一般能匹配多个主机名的证书有通配符证书*.domain.com和多域名证书(www.domain.com,ftp.domain.com 等)，以下我们提供一个典型同一个IP上的多主机名部署配置，www.domain.com对应的根目录在WWW下，ftp.domain.com对应的根目录在FTP下，</span><span style="color:#666666;font-family:SimSun;font-size:14px;"><a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a></span><span style="color:#666666;font-family:SimSun;font-size:14px;">与</span><span style="color:#666666;font-family:SimSun;font-size:14px;"><a href="http://ftp.domain.com" rel="nofollow">http://ftp.domain.com</a></span><span style="color:#666666;font-family:SimSun;font-size:14px;">使用相同的证书：</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">NameVirtualHost 11.22.33.44:443</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost 11.22.33.44:443&gt;</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">DocumentRoot "C:/Apache2.2/htdocs/www"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">ServerName <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateFile "C:/Apache2.2/conf/server.cer"</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateKeyFile "C:/Apache2.2/conf/server.key"</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost 11.22.33.44:443&gt;</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">DocumentRoot "C:/Apache2.2/htdocs/ftp"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">ServerName <a href="http://ftp.domain.com" rel="nofollow">http://ftp.domain.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateFile "C:/Apache2.2/conf/server.cer"</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateKeyFile "C:/Apache2.2/conf/server.key"</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	<span><span style="color:#FF0000;"><span style="color:#666666;font-family:SimSun;"><br />
</span></span></span>
</p>
<p>
	<span><span style="color:#FF0000;"><span style="color:#666666;font-family:SimSun;font-size:14px;">（2）</span><span style="color:#666666;font-family:SimSun;font-size:14px;">另一种办法就是给每个网站分配不同的端口号</span></span><span style="color:#666666;font-family:SimSun;font-size:14px;">；</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost 11.22.33.44:443&gt;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">DocumentRoot "C:/Apache2.2/htdocs/www"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">ServerName <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateFile "C:/Apache2.2/conf/server.cer"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateKeyFile "C:/Apache2.2/conf/server.key"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost 11.22.33.44:</span><span style="color:#666666;font-family:SimSun;font-size:14px;">8443</span><span style="color:#666666;font-family:SimSun;font-size:14px;">&gt;</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">DocumentRoot "C:/Apache2.2/htdocs/ftp"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">ServerName <a href="http://ftp.domain.com" rel="nofollow">http://ftp.domain.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateFile "C:/Apache2.2/conf/server.cer"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">SSLCertificateKeyFile "C:/Apache2.2/conf/server.key"</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;"><br />
</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">基于域名的虚拟主机只能使用同一个证书，或者说，即使有不同的证书，最终使用的都是排在前面的默认的第一个</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-weight:bold;"><br />
</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-weight:bold;font-size:14px;">2. Apache中一张网卡绑定不同IP实现多个<a href="http://www.showerlee.com/archives/tag/https" title="查看HTTPS中的全部文章" class="tag_link">HTTPS</a>虚拟主机</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">一张网卡绑定多个ip，ifconfig eth0:0......</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost</span><span style="font-weight:bold;color:#666666;font-family:SimSun;font-size:14px;">&nbsp;220.181.75.109</span><span style="color:#666666;font-family:SimSun;font-size:14px;">:8443&gt;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;ServerAdmin <a href="mailto:lala@corp.net.com">lala@corp.net.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;DocumentRoot /home/lala/apache/htdocs/test</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;ServerName a.test.com</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCertificateFile /home/lala/apache/conf/ssl.key/server.crt</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCertificateKeyFile /home/lala/apache/conf/ssl.key/server.key</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#Include /home/lala/apache/conf/ssl.conf</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#ErrorLog logs/dummy-a.test.com-error_log</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#CustomLog logs/a.test.com-access_log common</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;"><br />
</span></span>
</p>
<p>
	<span><span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;VirtualHost&nbsp;</span><span style="font-weight:bold;color:#666666;font-family:SimSun;font-size:14px;">220.181.75.65</span><span style="color:#666666;font-family:SimSun;font-size:14px;">:8443&gt;</span></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;ServerAdmin <a href="mailto:lala@corp.net.com">lala@corp.net.com</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;DocumentRoot /home/lala/apache/htdocs/test2</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;ServerName d.test.com</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLEngine on</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCertificateFile /home/lala/apache/conf/ssl.key/server2.crt</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;SSLCertificateKeyFile /home/lala/apache/conf/ssl.key/server2.key</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#Include /home/lala/apache/conf/ssl.conf</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#ErrorLog logs/dummy-a.test.com-error_log</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp; &nbsp; &nbsp;#CustomLog logs/a.test.com-access_log common</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&lt;/VirtualHost&gt;</span>
</p>
<p>
	</p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/825">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="Apache中多个HTTPS虚拟主机的实现" href="http://www.showerlee.com/archives/825">http://www.showerlee.com/archives/825</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/825/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>实现apache下,IP地址无法访问网站.</title>
		<link>http://www.showerlee.com/archives/823</link>
		<comments>http://www.showerlee.com/archives/823#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:53:58 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=823</guid>
		<description><![CDATA[在apache2/conf/extra/httpd-vhosts.conf下首行添加 ------------ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">在apache2/conf/extra/httpd-vhosts.conf下首行添加</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">------------------------------------</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&lt;VirtualHost *:80&gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; DocumentRoot "/usr/local/www/www.abc.com.cn/"</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; ServerAlias 1.1.1.1</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; &lt;Location /&gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; Order Deny,Allow</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; Deny from all</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&nbsp; &nbsp; &lt;/Location&gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">&lt;/VirtualHost&gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-family:SimSun;">-------------------------------------</span></p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/823">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="实现apache下,IP地址无法访问网站." href="http://www.showerlee.com/archives/823">http://www.showerlee.com/archives/823</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/823/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS6.3下使用webbench对网站进行压力测试</title>
		<link>http://www.showerlee.com/archives/819</link>
		<comments>http://www.showerlee.com/archives/819#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:50:54 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>
		<category><![CDATA[Webbench]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=819</guid>
		<description><![CDATA[webbench最多可以模拟3万个并发连接去测试网站的负载能力，个人感觉要比 Apache自带的ab压力测试工 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">webbench最多可以模拟3万个并发连接去测试网站的负载能力，个人感觉要比</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">Apache自带的ab压力测试工具好，安装使用也特别方便。</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">1、适用系统：Linux</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">2、编译安装：</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"># wget <a href="http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz" rel="nofollow">http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz</a></span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"># tar zxvf webbench-1.5.tar.gz</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"># cd webbench-1.5</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"># make &amp;&amp; make install</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">3、使用：</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"># webbench -c 500 -t 30 <a href="http://127.0.0.1/test.jpg" rel="nofollow">http://127.0.0.1/test.jpg</a></span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">参数说明：-c表示并发数，-t表示时间(秒)</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;"><br />
</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">4、测试结果示例：</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;"><a href="http://www.showerlee.com/archives/tag/webbench" title="查看Webbench中的全部文章" class="tag_link">Webbench</a> - Simple Web Benchmark 1.5</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">Benchmarking: GET <a href="http://127.0.0.1/test.jpg" rel="nofollow">http://127.0.0.1/test.jpg</a></span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">500 clients, running 30 sec.</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">Speed=3230 pages/min, 11614212 bytes/sec.</span>
</p>
<p>
	<span style="background-color:#FFFFFF;color:#666666;font-family:SimSun;font-size:14px;">Requests: 1615 susceed, 0 failed.</span></p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/819">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="CentOS6.3下使用webbench对网站进行压力测试" href="http://www.showerlee.com/archives/819">http://www.showerlee.com/archives/819</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/819/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APACHE利用Limit模块限制IP连接数</title>
		<link>http://www.showerlee.com/archives/813</link>
		<comments>http://www.showerlee.com/archives/813#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:44:26 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=813</guid>
		<description><![CDATA[系统版本:centos6.3 APACHE版本:apache2.42(编译安装) 1.配置Limit模块 #w [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">系统版本:centos6.3</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;"><a href="http://www.showerlee.com/archives/tag/apache" title="查看APACHE中的全部文章" class="tag_link">APACHE</a>版本:apache2.42(编译安装)</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">1.配置Limit模块</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#wget <a href="http://dominia.org/djao/limit/mod_limitipconn-0.24.tar.bz2" rel="nofollow">http://dominia.org/djao/limit/mod_limitipconn-0.24.tar.bz2</a></span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">安装:</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#tar jxvf mod_limitipconn-0.24.tar.bz2</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#cd mod_limitipconn-0.24</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#vi Makefile</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">找到APXS这行,改成</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">APXS=/usr/local/apache2/bin/apxs</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#make &amp;&amp; make install</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">全局变量范例:</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; IfModule mod_limitipconn.c &gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; Location / &gt; &nbsp; &nbsp;# 所有虚拟主机的/目录</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">MaxConnPerIP 3 &nbsp; &nbsp; &nbsp;# 每IP只允许3个并发连接</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">NoIPLimit image/* &nbsp; # 对图片不做IP限制</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; /Location &gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; Location /mp3 &gt; &nbsp; # 所有主机的/mp3目录</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">MaxConnPerIP 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 每IP只允许一个连接请求</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">OnlyIPLimit audio/mpeg video &nbsp; &nbsp; # 该限制只对视频和音频格式的文件</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; /Location &gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&lt; /IfModule &gt;</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;"># vi /usr/local/apache2/conf/httpd.conf</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#666666;font-size:14px;font-family:SimSun;">--------------------</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">ExtendedStatus On &nbsp;</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">LoadModule limitipconn_module modules/mod_limitipconn.so</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">&lt;IfModule mod_limitipconn.c&gt;&nbsp;</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">&lt;Location /&gt;</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">MaxConnPerIP 6</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">NoIPLimit image/*&nbsp;</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">&lt;/Location&gt;</span>
</p>
<p>
	<span style="color:#666666;background-color:#FFFFFF;font-family:SimSun;font-size:14px;">&lt;/IfModule&gt;&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;background-color:#FFFFFF;">-------------------</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">2、配置webbench对网站进行压力测试：</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#wget <a href="http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz" rel="nofollow">http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz</a></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#tar zxvf webbench-1.5.tar.gz</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#cd webbench-1.5</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">#make &amp;&amp; make install</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">3、使用：</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">webbench -c 500 -t 30 <a href="http://127.0.0.1/" rel="nofollow">http://127.0.0.1/</a></span>
</p>
<p>
	<span style="color:#666666;font-family:SimSun;font-size:14px;">参数说明：-c表示并发数，-t表示时间(秒)</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">4、测试结果示例：</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">Webbench - Simple Web Benchmark 1.5</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">&nbsp;</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">Benchmarking: GET <a href="http://127.0.0.1/" rel="nofollow">http://127.0.0.1/</a></span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">500 clients, running 30 sec.</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">Speed=3230 pages/min, 11614212 bytes/sec.</span>
</p>
<p>
	<span style="color:#666666;font-size:14px;font-family:SimSun;">Requests: 1615 susceed, 0 failed.</span>
</p>
<p>
	
</p>
<p>
	
</p>
<p>
	</p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/813">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="APACHE利用Limit模块限制IP连接数" href="http://www.showerlee.com/archives/813">http://www.showerlee.com/archives/813</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/813/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>利用apache代理功能实现网站资源异步存储</title>
		<link>http://www.showerlee.com/archives/810</link>
		<comments>http://www.showerlee.com/archives/810#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:42:40 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=810</guid>
		<description><![CDATA[系统环境：centOS 6.3 x64 Apache: &#160; http-2.4.2 代理端，web服务 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	系统环境：centOS 6.3 x64
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Apache: &nbsp; http-2.4.2
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	代理端，web服务器（192.168.7.12）：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# mkdir /usr/local/apache2/htdocs/files.abc.cn/
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	首先将在主配置文件http.conf下Module的注释去掉&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# vi /usr/local/apache2/conf/http.conf
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	找到以下3行，去掉#注释
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	LoadModule proxy_module modules/mod_proxy.so&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	LoadModule proxy_http_module modules/mod_proxy_http.so&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Include conf/extra/httpd-vhosts.conf&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	进入虚拟主机配置：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;VirtualHost *:80&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; DocumentRoot "/usr/local/apache2/htdocs/files.abc.cn/"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; ServerAlias files.abc.cn
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; proxypass / &nbsp; &nbsp;<a href="http://192.168.7.11/" rel="nofollow">http://192.168.7.11/</a>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;/VirtualHost&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	被代理端，文件服务器（192.168.7.11）：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# vi /usr/local/apache2/conf/http.conf
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	找到下行，去掉#注释
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Include conf/extra/httpd-vhosts.conf
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	进入虚拟主机配置：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# mkdir /usr/local/apache2/htdocs/files.abc.cn/
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;VirtualHost *:80&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; DocumentRoot "/usr/local/apache2/htdocs/files.abc.cn/"
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp; &nbsp; ServerAlias 192.168.7.11
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&lt;/VirtualHost&gt;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	-----------------
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	配置完毕
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	&nbsp;
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	这样客户端浏览器访问域名http://files.abc.cn
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	通过http代理，即可访问到192.168.7.11上的资源
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	从而实现网站资源异步存储访问，缓解主服务器访问压力。</p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/810">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="利用apache代理功能实现网站资源异步存储" href="http://www.showerlee.com/archives/810">http://www.showerlee.com/archives/810</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/810/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache下prefork,worker,event三种模式的区别</title>
		<link>http://www.showerlee.com/archives/807</link>
		<comments>http://www.showerlee.com/archives/807#comments</comments>
		<pubDate>Sat, 31 Aug 2013 13:40:34 +0000</pubDate>
		<dc:creator>showerlee</dc:creator>
				<category><![CDATA[APACHE]]></category>

		<guid isPermaLink="false">http://www.showerlee.com/?p=807</guid>
		<description><![CDATA[Apache 2.X &#160;支持插入式并行处理模块，称为多路处理模块（MPM）。在编译apache时必须 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Apache 2.X &nbsp;支持插入式并行处理模块，称为多路处理模块（MPM）。在编译apache时必须选择也只能选择一个MPM，对类UNIX系统，有几个不同的MPM可供选择，它们会影响到apache的速度和可伸缩性。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Prefork MPM : 这个多路处理模块(MPM)实现了一个非线程型的、预派生的web服务器，它的工作方式类似于Apache 1.3。它适合于没有线程安全库，需要避免线程兼容性问题的系统。它是要求将每个请求相互独立的情况下最好的MPM，这样若一个请求出现问题就不会影响到其他请求。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	这个MPM具有很强的自我调节能力，只需要很少的配置指令调整。最重要的是将MaxClients设置为一个足够大的数值以处理潜在的请求高峰，同时又不能太大，以致需要使用的内存超出物理内存的大小。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Worker MPM : 此多路处理模块(MPM)使网络服务器支持混合的多线程多进程。由于使用线程来处理请求，所以可以处理海量请求，而系统资源的开销小于基于进程的MPM。但是，它也使用了多进程，每个进程又有多个线程，以获得基于进程的MPM的稳定性。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	每个进程可以拥有的线程数量是固定的。服务器会根据负载情况增加或减少进程数量。一个单独的控制进程(父进程)负责子进程的建立。每个子进程可以建立ThreadsPerChild数量的服务线程和一个监听线程，该监听线程监听接入请求并将其传递给服务线程处理和应答。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	不管是Worker模式或是Prefork 模式，Apache总是试图保持一些备用的(spare)或者是空闲的子进程（空闲的服务线程池）用于迎接即将到来的请求。这样客户端就不需要在得到服务前等候子进程的产生。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	Event MPM：以上两种稳定的MPM方式在非常繁忙的服务器应用下都有些不足。尽管HTTP的Keepalive方式能减少TCP连接数量和网络负载，但是 Keepalive需要和服务进程或者线程绑定，这就导致一个繁忙的服务器会耗光所有的线程。 Event MPM是解决这个问题的一种新模型，它把服务进程从连接中分离出来。在服务器处理速度很快，同时具有非常高的点击率时，可用的线程数量就是关键的资源限 制，此时Event MPM方式是最有效的。一个以Worker MPM方式工作的繁忙服务器能够承受每秒好几万次的访问量（例如在大型新闻服务站点的高峰时），而Event MPM可以用来处理更高负载。值得注意的是，Event MPM不能在安全HTTP（HTTPS）访问下工作。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	对于Event 模式，apache给出了以下警告：
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	This MPM is experimental, so it may or may not work as expected .
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	这种MPM目前处于试验状态，他可能不能按照预期的那样工作。
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">简单来讲：</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">1. prefork 中没有线程的概念，是多进程模型，一个进程处理一个连接；稳定；响应快。其缺点是在连接数比较大时就非常消耗内存。</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">2. worker 是多进程多线程模型，一个进程有多个线程，每个线程处理一个连接。与prefork相比，worker模式更节省系统的内存资源。不过，需要注意worker模式下的Apache与php等程序模块的兼容性。</span>
</p>
<p style="color:#555555;font-family:宋体, 'Arial Narrow', arial, serif;font-size:14px;background-color:#FFFFFF;">
	<span style="color:#FF0000;">3. event 是worker模式的变种，它把服务进程从连接中分离出来,在开启KeepAlive场合下相对worker模式能够承受的了更高的并发负载。event模式不能很好的支持https的访问（HTTP认证相关的问题）。</span>
</p>
<p>
	</p>
<div>声明: 本文采用 <a rel="external" href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" title="署名-非商业性使用-相同方式共享 3.0 Unported">CC BY-NC-SA 3.0</a> 协议进行授权</div><div>转载请注明来源：<a rel="external" title="DevOps技术分享" href="http://www.showerlee.com/archives/807">DevOps技术分享</a></div><div>本文链接地址：<a rel="external" title="Apache下prefork,worker,event三种模式的区别" href="http://www.showerlee.com/archives/807">http://www.showerlee.com/archives/807</a></div>]]></content:encoded>
			<wfw:commentRss>http://www.showerlee.com/archives/807/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
