﻿<?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>P.Linux Laboratory &#187; LAMP</title>
	<atom:link href="http://www.penglixun.com/tag/lamp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.penglixun.com</link>
	<description>MySQL DBA &#38; Linux SA</description>
	<lastBuildDate>Sun, 22 Jan 2012 16:34:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>LAMP架构下的安全注意要点</title>
		<link>http://www.penglixun.com/tech/system/lamp_security.html</link>
		<comments>http://www.penglixun.com/tech/system/lamp_security.html#comments</comments>
		<pubDate>Sat, 09 Jan 2010 16:24:45 +0000</pubDate>
		<dc:creator>P.Linux</dc:creator>
				<category><![CDATA[操作系统]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://www.penglixun.com/?p=880</guid>
		<description><![CDATA[本文内容遵从CC版权协议, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明网址: http://www.penglixun.com/tech/system/lamp_security.html 我对安全方面也不是了解很多，最近遇到... ]]></description>
			<content:encoded><![CDATA[<p><span style="color: #888888;">本文内容遵从<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" target="_blank">CC版权协议</a>, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明</br>网址: http://www.penglixun.com/tech/system/lamp_security.html </p>
<p></span>我对安全方面也不是了解很多，最近遇到了安全方面的问题，查了一些资料，亲自试了试，选出一些比较重要的记录一下。</p>
<p>安全方面即将加入阿里云的<a title="刘博洋" href="http://twitter.com/Natural__Light">@Natural__Light</a>大牛给我演示过不少入侵的方法，算“资深”了，从在中学开始入侵学校网络，咱们大学里的那些破网站，<a title="刘博洋" href="http://twitter.com/Natural__Light">@Natural__Light</a>大牛玩一样进后台。</p>
<ol>
<li>如果要考虑安全问题，就必须有一个假设：<span style="color: #ff0000;">一切用户输入的内容都是不安全的，一切参数的传递都是不安全的</span>。入侵者可能利用每一个我们假设是安全的地方。</li>
<li>Linux方面
<ul>
<li>限制用户账号，开发和运维分开。</li>
<li><acronym title="Secure Shell">SSH</acronym>登陆必须限制主机来源，切忌允许全部<acronym title="Internet Protocol">IP</acronym>登陆，最好port也要修改。</li>
<li>使用iptables限制端口出入和<acronym title="Internet Protocol">IP</acronym>，内部系统只能允许内部<acronym title="Internet Protocol">IP</acronym>。</li>
<li>注意为不同的用户甚至不同的功能区分不同的账号和用户组。</li>
<li>为关键文件和目录一定要设置好权限，千万不能777，配合用户和分组保证只有需要的人有需要的权限，尤其是/etc下的。<span id="more-880"></span></li>
</ul>
</li>
<li>Apache方面
<ul>
<li>使用专门的账号和用户组来启动Apache。</li>
<li>不同功能和站点的配置文件最好拆分为不同的文件。</li>
<li>设置ServerSignature Off和ServerTokens ProductOnly，防止服务器广播敏感信息和<acronym title="HyperText Transfer Protocol">HTTP</acronym>头透露关键信息。</li>
<li>禁止浏览目录。</li>
<li>只监听指定的<acronym title="Internet Protocol">IP</acronym>和端口。</li>
<li>必要时可以修改代码伪装服务器版本信息。</li>
<li>为每个目录建立.htaccss文件保护。</li>
<li>只允许特定常用的User-Agent访问。</li>
<li>利用iptables或Nginx做反向代理，过滤DDOS攻击。</li>
</ul>
</li>
<li>MySQL方面
<ul>
<li>必须设置MySQL目录的权限，限制访问。</li>
<li>必须使用一个独立的用户和用户组，没有Shell，也不能运行其他程序。</li>
<li>必须删除无用户名账户，必须修改root账户密码，并且要限制主机来源。</li>
<li>必须删除test库，这个库任何人都可以建表，危险。</li>
<li>为每个功能单独建账号，使用不同的密码，限制主机来源，只给需要的权限。</li>
<li>细化权限粒度，不要给任何账户不必要的权限。</li>
</ul>
</li>
<li><acronym title="Pre-Hypertext Processing">PHP</acronym>方面
<ul>
<li>一定要分析任何用户输入或者传递的参数，过滤其中的危险字符。</li>
<li>使用系统自带的过滤函数一定要了解其机制，避免对方利用单/多字符集的方法绕过。</li>
<li>在前端限制特殊字符被输入，接到输入后还需要再次进行过滤。</li>
<li>系统的错误信息必须被屏蔽或者关闭，错误可以跳转。</li>
<li>禁止采用root账户连接数据库。</li>
<li>用专门的账户运行<acronym title="Pre-Hypertext Processing">PHP</acronym>。</li>
</ul>
</li>
</ol>
<p>总的来说最重要的就是：<span style="color: #ff0000;">以最低粒度控制权限，过滤任何用户可以修改的进入系统的内容</span>。</p><h2  class="related_post_title">类似的文章</h2><ul class="related_post"><li>2009年10月13日 -- <a href="http://www.penglixun.com/life/diary/recommend_one_powerful_person.html" title="推荐一位牛人">推荐一位牛人</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.penglixun.com/tech/system/lamp_security.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>推荐一位牛人</title>
		<link>http://www.penglixun.com/life/diary/recommend_one_powerful_person.html</link>
		<comments>http://www.penglixun.com/life/diary/recommend_one_powerful_person.html#comments</comments>
		<pubDate>Tue, 13 Oct 2009 14:39:29 +0000</pubDate>
		<dc:creator>P.Linux</dc:creator>
				<category><![CDATA[随笔日记]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[牛人]]></category>
		<category><![CDATA[金步国]]></category>

		<guid isPermaLink="false">http://www.penglixun.com/PLX/Blog/?p=404</guid>
		<description><![CDATA[本文内容遵从CC版权协议, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明网址: http://www.penglixun.com/life/diary/recommend_one_powerful_person.html http://lamp.linux.gov.cn/jinbuguo_floril... ]]></description>
			<content:encoded><![CDATA[<p><span style="color: #888888;">本文内容遵从<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.zh" target="_blank">CC版权协议</a>, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明</br>网址: http://www.penglixun.com/life/diary/recommend_one_powerful_person.html </p>
<p></span><a href="http://lamp.linux.gov.cn/jinbuguo_florilegium.html">http://lamp.linux.gov.cn/jinbuguo_florilegium.html</a>——金步国</p>
<p>曾经苦苦寻找GCC编译参数的详解，未果，翻到Google结果的N页之后终于发现了一篇完整的<a href="http://lamp.linux.gov.cn/Linux/optimize_guide.html">介绍GCC参数优化的文章</a>，习惯性的去掉目录打开<a href="http://lamp.linux.gov.cn/">http://lamp.linux.gov.cn/</a>，宝贝啊。</p>
<p>此人可以“可以从源代码开始，全手动编译一个实用的服务器系统，无需借助任何包管理器，可以全手动处理依赖关系。”，如果读了他的文章，就不会觉得这是吹嘘了~</p>
<p>决定把此人的文档都看一遍，很多稀有资源！</p><h2  class="related_post_title">类似的文章</h2><ul class="related_post"><li>2010年01月10日 -- <a href="http://www.penglixun.com/tech/system/lamp_security.html" title="LAMP架构下的安全注意要点">LAMP架构下的安全注意要点</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.penglixun.com/life/diary/recommend_one_powerful_person.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

