<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>百里挑一</title> 
<link>http://www.admin99.net/index.php</link> 
<description>linux命令 &#124; seo优化技术 &#124; linux系统管理员指南 --我的学习园地</description> 
<language>zh-cn</language> 
<copyright>Powered by Bo-blog 2.0.2 sp2</copyright>
<item>
<link>http://www.admin99.net/read.php?446</link>
<title>apache和nginx的redirect实现域名跳转</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Sat, 01 Aug 2009 02:29:36 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?446</guid> 
<description>
<![CDATA[ 
	apache中，在虚拟主机的配置中加入<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">RedirectMatch ^/(.*)$ http://www.newdomain.com/$1</div></div><br/>或者用 <br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">RedirectMatch permanent ^/(.*)$ http://www.newdomain.com/$1</div></div><br/>实现301永久跳转<br/>nginx中，在server{}中加入<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">if ($host = 'old_domain.com' ) {<br/> &nbsp; &nbsp;rewrite &nbsp;^/(.*)$ &nbsp;http://newdomain.com/$1 &nbsp;permanent;<br/> }</div></div><br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a> , <a href="http://www.admin99.net/tag.php?tag=nginx" rel="tag">nginx</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?444</link>
<title>URL RewriteRule在httpd.conf和.htaccess中的不同点</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Fri, 03 Jul 2009 07:41:53 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?444</guid> 
<description>
<![CDATA[ 
	相信熟悉Web Server的人一定熟悉Apahce。相信熟悉Apahce的人一定知道URL Rewrite。Apache的mod_rewrite模块，可以帮助人们构造出各种各样美化后的URL。在Apache中使用URL Rewrite，可以有多种方式：一种是直接在httpd.conf中添加相应rewriterule(重写规则)，另一种是在网站根目录下的.htaccess中添加rewriterule(重写规则)。但是，需要注意的是，在这两个文件中添加到URL重写规则略有不同。而这些不同，对于不熟悉的人来说，很可能会困扰许久。<br/><br/>在Httpd.conf中：<br/>（1）Request URI的开头必须以斜线开始；<br/>（2）在寻找Cache文件的时候，必须在开头加上斜线；<br/>（3）在使用-f或者!-f的时候，必须在开头加上斜线。<br/><br/>在.htaccess中，情况完全相反：<br/>（1）Request URI的开头不能有斜线；<br/>（2）在寻找Cache文件的时候，不能在开头加上斜线；<br/>（3）在使用-f或者!-f的时候，不能在开头加上斜线。<br/><br/>简单而言，就是在httpd.conf中，重写前后的URL在使用绝对路径时需要添加斜线“/”，表示从网站根目录开始；而在.htaccess中，则不需要。以下两个简单的例子：<br/><br/>httpd.conf<br/>RewriteRule ^/$ /cache/index.html [QSA]<br/>RewriteRule ^/([^.]+)$ /cache/$1.html [QSA]<br/>RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f<br/>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]<br/><br/>.htaccess<br/>RewriteRule ^$ cache/index.html [QSA]<br/>RewriteRule ^([^.]+)$ cache/$1.html [QSA]<br/>RewriteCond %{REQUEST_FILENAME} !-f<br/>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]<br/><br/>或许还有更多的不同，大家也可以自己关注研究一下。<br/><br/>本文可以自由转载，转载时请保留全文并注明出处：<br/>转载自仲子说 [ http://www.wangzhongyuan.com/ ]<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?441</link>
<title>apache设置mod_expires</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Wed, 13 May 2009 03:41:57 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?441</guid> 
<description>
<![CDATA[ 
	首先要确认apache已经加载了mod_expires<br/>在配置文件中，或者 .htaccess(要支持.htaccess)中加入<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">&lt;IfModule mod_expires.c&gt;<br/>ExpiresActive On<br/>ExpiresDefault &quot;access plus 1 hours&quot;<br/>ExpiresByType image/gif &quot;access plus 1 month&quot;<br/>ExpiresByType image/jpg &quot;access plus 1 month&quot;<br/>ExpiresByType image/jpeg &quot;access plus 1 month&quot;<br/>ExpiresByType image/png &quot;access plus 1 month&quot;<br/>&lt;/IfModule&gt;</div></div><br/>ExpiresActive On 表示开启expires模块<br/>设置图片类 如 gif jpg jpeg png 过期时间为一个月。一般情况下网站上的图片很少修改的，设置的过期时间再长一些也关系不大<br/>设置其它内容过期时间为1小时，比如css js html等<br/>详见 <a href="http://httpd.apache.org/docs/2.2/mod/mod_expires.html" target="_blank">Apache Module mod_expires</a><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?438</link>
<title>64位系统下安装apache遇到的一个错误</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Mon, 11 May 2009 08:39:59 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?438</guid> 
<description>
<![CDATA[ 
	在 64位linux 系统下载装 apache , 在 make 的时候出现如下错误<br/>/usr/lib/libexpat.so: could not read symbols: File in wrong format<br/>解决办法<br/>在64位的系统上编译时需要链接64位的库文件，而/usr/lib/libexpat.so是32位的ELF格式，所以格式不对。在configure的时候添加LDFLAGS="-L/usr/lib64 -L/lib64" 选项即可 <br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?430</link>
<title>apache startssl 不输入密码</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Thu, 30 Apr 2009 07:50:43 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?430</guid> 
<description>
<![CDATA[ 
	去掉/usr/local/bin/apachectl startssl启动的pass phrase，用空pass phrase启动apache<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cp server.key server.key.org<br/>openssl rsa -in server.key.org -out server.key</div></div><br/>确认server.key 文件为root可读<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">chmod 400 server.key</div></div><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?429</link>
<title>Apache2+openssl实现https验证</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Thu, 30 Apr 2009 07:49:03 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?429</guid> 
<description>
<![CDATA[ 
	安装openssl最新版<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /usr/src<br/>wget http://www.openssl.org/source/openssl-0.9.8k.tar.gz<br/>tar xzvf openssl-0.9.8k.tar.gz<br/>cd openssl-0.9.8k<br/>./configure;make;make install</div></div><br/>把openssl放进内核目录下，使其在任何目录下都能运行。<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /usr/local/bin<br/>ln -s /usr/local/ssl/bin/openssl openssl</div></div><br/>安装apache2<br/>编译的时候加上参数 --enable-ssl --with-ssl=/usr/local/ssl/bin<br/>其它略过<br/><br/>在/usr/local/apache/conf下建立一个ssl.key目录<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd /usr/local/apache/conf<br/>mkdir ssl.key</div></div><br/>然后在该目录下生成证书：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">cd ssl.key/</div></div><br/>生成服务器私钥：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">openssl genrsa -des3 -out server.key 1024</div></div><br/>Generating RSA private key, 1024 bit long modulus<br/>.......................++++++<br/>.................................................++++++<br/>e is 65537 (0x10001)<br/>Enter pass phrase for server.key:<br/>Verifying - Enter pass phrase for server.key:<br/>生成服务器证书请求，并按要求填些相关证书信息：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">openssl req -new -key server.key -out server.csr</div></div><br/>Enter pass phrase for server.key:<br/>You are about to be asked to enter information that will be incorporated<br/>into your certificate request.<br/>What you are about to enter is what is called a Distinguished Name or a DN.<br/>There are quite a few fields but you can leave some blank<br/>For some fields there will be a default value,<br/>If you enter '.', the field will be left blank.<br/>-----<br/>Country Name (2 letter code) [AU]:CN<br/>State or Province Name (full name) [Some-State]:ShangHai<br/>Locality Name (eg, city) []:ShangHai<br/>Organization Name (eg, company) [Internet Widgits Pty Ltd]:6wei<br/>Organizational Unit Name (eg, section) []:6wei<br/>Common Name (eg, YOUR name) []:6wei<br/>Email Address []:service@6wei.cc<br/> <br/>Please enter the following 'extra' attributes<br/>to be sent with your certificate request<br/>A challenge password []:<br/>An optional company name []:<br/>签证：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">openssl x509 -req -days 700 -in server.csr -signkey server.key -out server.cert</div></div><br/>Signature ok<br/>subject=/C=AU/ST=Some-State/L=tyl/O=tz/OU=tz/CN=tyl/emailAddress=tangyl@ruyi.com<br/>Getting Private key<br/>Enter pass phrase for server.key:<br/>为了安全，然后我们把这些文件的权限都设为400<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">chmod 400 server.key<br/>chmod 400 server.cert</div></div><br/><br/>最后对/usr/local/apache/conf/ssl.conf 进行修改：<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">vi /usr/local/apache/conf/ssl.conf</div></div><br/>修改的地方如下几处：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt &nbsp;#108行<br/>SSLCertificateFile /usr/local/apache/conf/ssl.key/server.cert<br/>#SSLCertificateFile /usr/local/apache/conf/ssl.crt/server-dsa.crt<br/><br/>SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key &nbsp; #116行<br/>#SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server-dsa.key</div></div><br/><br/>这样我们就基本配好了ssl现在我们来让apache启动ssl<br/><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">/usr/local/apache/bin/apachectl startssl</div></div><br/><br/>然后要求输入证书密码，正确输入后ssl就连同apache一起启动<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?428</link>
<title>限制虚拟主机中php程序访问根目录以为的目录</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Tue, 28 Apr 2009 13:58:30 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?428</guid> 
<description>
<![CDATA[ 
	默认情况下，任何一个虚拟主机中的php程序，都可以读取到服务器上的所有目录<br/>比如你在其中一个虚拟主机中上传一个phpspy，就可以看到服务器的所有目录<br/>要限制虚拟主机中php只能访问该虚拟主机根目录之内的文件<br/>在apache中虚拟主机的配置文件里加入一句<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">php_admin_value open_basedir "/data/htdocs/admin99.net:/tmp"</div></div><br/>/tmp前面是冒号:，如果还需要访问更多目录，用冒号: 继续隔开<br/>重启apache然后再访问phpspy，就会发现，phpspy已经不能访问设定的目录意外的文件<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=%E5%AE%89%E5%85%A8%E7%9B%B8%E5%85%B3" rel="tag">安全相关</a> , <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a> , <a href="http://www.admin99.net/tag.php?tag=php" rel="tag">php</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?414</link>
<title>为apache启用页面压缩mod_deflate</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Sat, 27 Dec 2008 14:19:25 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?414</guid> 
<description>
<![CDATA[ 
	到apache的源文件目录<br/>cd /usr/src/httpd-2.0.63/modules/filters<br/>编译并安装<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">/usr/local/apache/bin/apxs -i -c -a mod_deflate.c</div></div><br/>如果能正确执行，则会把mod_deflate.so拷贝到/usr/local/apache/modules下，并在配置文件中加入一行 LoadModule deflate_module &nbsp;modules/mod_deflate.so<br/>在配置文件中加入两行配置<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"> AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php<br/> AddOutputFilter DEFLATE css js</div></div><br/>重启apache<br/>/usr/local/apache/bin/apachectl restart<br/>测试<br/>到 http://gzip.zzbaike.com/ 测试一下看看<br/><br/>如果重启的时候出现错误<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">Cannot load /usr/local/apache/modules/mod_deflate.so into server: /usr/local/apache/modules/mod_deflate.so: undefined symbol: inflateEnd</div></div><br/>需要在 LoadModule deflate_module &nbsp;modules/mod_deflate.so 的前面加载zlib.so<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">LoadFile /usr/lib/libz.so<br/>LoadModule deflate_module &nbsp; &nbsp; modules/mod_deflate.so</div></div><br/><br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?408</link>
<title>使用rotatelogs轮询apache的日志</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Tue, 16 Dec 2008 06:26:43 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?408</guid> 
<description>
<![CDATA[ 
	rotatelogs是一个配合Apache管道日志功能使用的简单程序。举例：<br/><br/>CustomLog "&#124;bin/rotatelogs /var/logs/logfile 86400" common<br/>此配置会建立文件"/var/logs/logfile.nnnn"，其中的nnnn是名义上的日志启动时的系统时间(此时间总是滚动时间的倍数，可以用于cron脚本的同步)。在滚动时间到达时(在此例中是24小时以后)，会产生一个新的日志。<br/>CustomLog "&#124;bin/rotatelogs /var/logs/logfile 5M" common<br/>此配置会在日志文件大小增长到5兆字节时滚动该日志。<br/>ErrorLog "&#124;bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"<br/>此配置会在错误日志大小增长到5兆字节时滚动该日志，日志文件名后缀会按照如下格式创建：errorlog.YYYY-mm-dd-HH_MM_SS <br/><br/>语法<br/>rotatelogs [ -l ] logfile [ rotationtime [ offset ]] &#124; [ filesizeM ]<br/><br/>选项<br/>-l<br/> &nbsp; &nbsp;使用本地时间代替GMT时间作为时间基准。注意：在一个改变GMT偏移量(比如夏令时)的环境中使用-l会导致不可预料的结果。<br/>logfile<br/> &nbsp; &nbsp;它加上基准名就是日志文件名。如果logfile中包含"%"，则它会被视为用于strftime()的格式字符串；否则它会被自动加上以秒为单位的".nnnnnnnnnn"后缀。这两种格式都表示新的日志开始使用的时间。<br/>rotationtime<br/> &nbsp; &nbsp;日志文件滚动的以秒为单位的间隔时间。<br/>offset<br/> &nbsp; &nbsp;相对于UTC的时差的分钟数。如果省略，则假定为"0"并使用UTC时间。比如，要指定UTC时差为"-5小时"的地区的当地时间，则此参数应为"-300"。中国处于东八区，则此参数应该为 “480”。<br/>filesizeM<br/> &nbsp; &nbsp;指定以filesizeM文件大小滚动，而不是按照时间或时差滚动。<br/><br/>下列日志文件格式字符串可以为所有的strftime()实现所支持，见各种扩展库对应的strftime()的手册。<br/>%A&nbsp;&nbsp;星期名全称(本地的)<br/>%a&nbsp;&nbsp;3个字符的星期名(本地的)<br/>%B&nbsp;&nbsp;月份名的全称(本地的)<br/>%b&nbsp;&nbsp;3个字符的月份名(本地的)<br/>%c&nbsp;&nbsp;日期和时间(本地的)<br/>%d&nbsp;&nbsp;2位数的一个月中的日期数<br/>%H&nbsp;&nbsp;2位数的小时数(24小时制)<br/>%I&nbsp;&nbsp;2位数的小时数(12小时制)<br/>%j&nbsp;&nbsp;3位数的一年中的日期数<br/>%M&nbsp;&nbsp;2位数的分钟数<br/>%m&nbsp;&nbsp;2位数的月份数<br/>%p&nbsp;&nbsp;am/pm12小时制的上下午(本地的)<br/>%S&nbsp;&nbsp;2位数的秒数<br/>%U&nbsp;&nbsp;2位数的一年中的星期数(星期天为一周的第一天)<br/>%W&nbsp;&nbsp;2位数的一年中的星期数(星期一为一周的第一天)<br/>%w&nbsp;&nbsp;1位数的星期几(星期天为一周的第一天)<br/>%X&nbsp;&nbsp;时间(本地的)<br/>%x&nbsp;&nbsp;日期(本地的)<br/>%Y&nbsp;&nbsp;4位数的年份<br/>%y&nbsp;&nbsp;2位数的年份<br/>%Z&nbsp;&nbsp;时区名<br/>%%&nbsp;&nbsp;符号"%"本身<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item><item>
<link>http://www.admin99.net/read.php?394</link>
<title>开启 Apache Server Status</title> 
<author>real &lt;real@admin99.net&gt;</author>
<category>Apache</category>
<pubDate>Sat, 08 Nov 2008 14:46:19 +0000</pubDate> 
<guid>http://www.admin99.net/read.php?394</guid> 
<description>
<![CDATA[ 
	Apache 1.3.2及以后的版本中就自带一个查看Apache状态的功能模块server-status<br/>一般默认状态下，apache安装的时候已经将mod_status模块安装了，只是模式情况下没有启用<br/>在httpd.conf中，找到<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">&lt;Location /server-status&gt;<br/> &nbsp; &nbsp;SetHandler server-status<br/> &nbsp; &nbsp;Order deny,allow<br/> &nbsp; &nbsp;Deny from all<br/> &nbsp; &nbsp;Allow from .example.com<br/>&lt;/Location&gt;</div></div><br/>将其中的 .example.com 改为自己的域名，比如www.admin99.net<br/>将前面的注释去掉，重启apache，即可通过 http://www.admin99.net/server-status来访问。<br/>可以通过http://www.admin99.net/server-status?refresh=5来自动刷新当前的状态信息，5秒刷新一次<br/>另外，如果想要看当前的详细请求信息的话，可以将<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">ExtendedStatus On</div></div><br/>的注释也去掉，不过这样会比较明显的加重服务器的负担，不推荐。<br/>Tags - <a href="http://www.admin99.net/tag.php?tag=apache" rel="tag">apache</a>
  ]]> 
</description>
</item>
</channel>
</rss>