tag:blogger.com,1999:blog-59465307047421309702024-03-06T16:20:07.273+08:00Jax 的工作紀錄除了在整理學習上的經驗,同時也能幫助其他需要的人Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-5946530704742130970.post-85072958064986502822015-01-31T21:02:00.001+08:002015-01-31T21:36:21.047+08:00[轉載] PHP 配置open_basedir,让各虚拟站点独立运行轉載自:<a href="http://www.cnblogs.com/flashlm/archive/2009/11/11/php_open_basedir_seprate_site.html" target="_blank">PHP 配置open_basedir,让各虚拟站点独立运行 - canbeing - 博客园</a><br />
<br />
open_basedir 可将用户访问文件的活动范围限制在指定的区域,通常是其家目录的路径,也可用符号"."来代表当前目录。open_basedir 也可以同时设置多个目录, 在 Windows 中用分号(;)分隔目录,在任何其它系统中用冒号(:)分隔目录。当其作用于 Apache 模块时,父目录中的 open_basedir 路径自动被继承。<br />
<br />
以下以 Linux 系统下的配置为例:<br />
<br />
<strong>方法一:在 php.ini 里配置</strong><br />
<code>open_basedir = .:/tmp/</code><br />
<br />
<strong>方法二:在 Apache 配置的 VirtualHost 里设置</strong><br />
<code>php_admin_value open_basedir .:/tmp/</code><br />
<br />
<strong>方法三:在 Apache 配置的 Direcotry .htaccess 里设置</strong><br />
<code>php_admin_value open_basedir .:/tmp/</code><br />
<br />
<br />
<strong>关于三个配置方法的解释:</strong><br />
<ol><li>方法二的优先级高于方法一,也就是说方法二会覆盖方法一<br/>方法三的优先级高于方法二,也就是说方法三会覆盖方法二</li>
<li>配置目录里加了 <code>/tmp/</code> 是因为php默认的临时文件(如上传的文件、session 等)会放在该目录,所以一般需要添加该目录,否则部分功能将无法使用</li>
<li>配置目录里加了 <code>.</code> 是指运行php文件的当前目录,这样做可以避免每个站点一个一个设置</li>
<li>如果站点还使用了站点目录外的文件,需要单独在对应 VirtualHost 设置该目录</li>
</ol>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-22702506736778364592013-06-04T21:49:00.001+08:002013-06-10T22:22:47.654+08:00[轉載] HTTP 狀態碼轉載自:<a target="_blank" href="http://support.google.com/webmasters/bin/answer.py?hl=zh-Hant&answer=40132">HTTP 狀態碼 - 網站管理員工具說明</a><br />
<p>當向您的伺服器傳送一個要求,要求顯示您網站的網頁 (例如,在使用者在瀏覽器中存取您的網頁,或 Googlebot 檢索該網頁時),則您的伺服器會傳回 HTTP 狀態碼,以回應該要求。</p><p>此狀態碼會提供有關該要求的狀態的資訊。此狀態碼會向 Googlebot 提供有關您的網站和所要求的網頁的資訊。</p><p>以下為一些常見的狀態碼:</p><ul><li><strong>200</strong> - 伺服器成功傳回網頁</li>
<li><strong>404</strong> - 找不到所要求的網頁</li>
<li><strong>503</strong> - 伺服器暫時無法使用</li>
</ul><p>以下是 HTTP 狀態碼的完整清單。您還可以瀏覽<a target="_blank" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">有關 HTTP 狀態碼的 W3C 網頁,以取得更多資訊</a>。</p><br />
<p><strong>1xx (Provisional response)</strong><br />
指出暫時回應並需要要求者採取措施以繼續的狀態碼。</p><ul><li><strong>100 (Continue)</strong><br />
要求者應當繼續此要求。伺服器傳回此代碼,指出已收到某個要求的第一部分,正等候其餘部分。 </li>
<li><strong>101 (Switching protocols)</strong><br />
要求者已請求伺服器切換通訊協定,伺服器正在確認即將進行切換。</li>
</ul><br />
<p><strong>2xx (Successful)</strong><br />
指出伺服器已成功處理該要求的狀態碼。</p><ul><li><strong>200 (Successful)</strong><br />
伺服器已成功處理該要求。一般而言,這代表伺服器已提供所要求的網頁。如果您在 robots.txt 檔案中看到此狀態,即表示 Googlebot 已成功擷取該網頁。</li>
<li><strong>201 (Created)</strong><br />
該要求已成功完成,伺服器已建立新的資源。</li>
<li><strong>202 (Accepted)</strong><br />
伺服器已接受該要求,但尚未處理。</li>
<li><strong>203 (Non-authoritative information)</strong><br />
伺服器成功處理該要求,但正在傳回可能來自另一來源的資訊。</li>
<li><strong>204 (No Content)</strong><br />
伺服器已成功處理該要求,但沒有傳回任何內容。</li>
<li><strong>205 (Reset Content)</strong><br />
伺服器已成功處理該要求,但沒有傳回任何內容。與 204 回應不同,此回應需要要求者重設文件視圖 (例如,清除表單,以輸入新的資料)。</li>
<li><strong>206 (Partial Content)</strong><br />
伺服器已成功處理部分 GET 要求。</li>
</ul><br />
<p><strong>3xx (Redirected)</strong><br />
您需要採取進一步的動作才能完成該要求。通常這些狀態碼會用來重新導向。Google 建議每個要求不要使用超過五次重新導向。您可以使用「網站管理員工具」來查看 Googlebot 在檢索重新導向的網頁時是否存在問題。在 [健康狀態] 下的「檢索錯誤」網頁會列出 Googlebot 因重新導向錯誤而無法檢索的網址。<strong></strong></p><ul><li><strong>300 (Multiple Choices)</strong><br />
根據該要求,伺服器可採取數種動作。伺服器可能會根據要求者 (user-agent) 選擇一個動作,或者可能列出清單供要求者選擇一個動作。</li>
<li><strong>301 (Moved Permanently)</strong><br />
要求的網頁已永久移到新位置。當伺服器傳回此回應 (作為對 GET 或 HEAD 要求的回應) 時,會自動將要求者導向至新位置。您應該使用此代碼,讓 Googlebot 知道某個網頁或網站已永久移至新位置。</li>
<li><strong>302 (Moved Temporarily)</strong><br />
伺服器目前正對來自不同位置的網頁回應該要求,但是要求者應該繼續使用原位置發出以後的要求。此代碼類似於回應 GET 或 HEAD 要求的 301 代碼,會自動將要求者導向至另一個位置,但是因為 Googlebot 會繼續檢索原位置並為其建立索引,所以您不應該使用此代碼來告知 Googlebot 某個網頁或網站已移除。</li>
<li><strong>303 (See Other Location)</strong><br />
當要求者應該對另一個位置發出單獨的 GET 要求以擷取回應時,伺服器會傳回此代碼。對於 HEAD 之外的所有要求,伺服器會自動導向至其他位置。</li>
<li><strong>304 (Not Modified)</strong><br />
要求的網頁自上次要求以後未經任何修改。當伺服器傳回此回應時,並不會傳回該網頁的內容。<br />
如果網頁自要求者上次要求以後,未經任何修改,則您應該設定伺服器傳回此回應 (稱為 If-Modified-Since HTTP 標頭)。這樣可以節省您的頻寬和負載,因為您的伺服器可以告知 Googlebot 網頁自上次檢索後,未經任何修改.</li>
<li><strong>305 (Use Proxy)</strong><br />
要求者只能使用 Proxy 存取要求的網頁。當伺服器傳回此回應時,還會指出要求者應該使用的 Proxy。</li>
<li><strong>307 (Temporary Redirect)</strong><br />
伺服器目前正對來自不同位置的網頁回應該要求,但是要求者應該繼續使用原位置發出以後的要求。此代碼類似於回應 GET 或 HEAD 要求的 301 代碼,會自動將要求者導向至另一個位置,但是因為 Googlebot 會繼續檢索原位置並為其建立索引,所以您不應該使用此代碼來告知 Googlebot 某個網頁或網站已移除。</li>
</ul><br />
<p><strong>4xx (Request Error)</strong><br />
這些狀態碼指出要求中可能存在使伺服器無法進行處理的錯誤。</p><ul><li><strong>400 (Bad Request)</strong><br />
伺服器無法解讀該要求的語法。</li>
<li><strong>401 (Not Authorized)</strong><br />
該要求需要驗證。登入後,伺服器可能會對網頁傳回此回應。</li>
<li><strong>403 (Forbidden)</strong><br />
伺服器拒絕要求。如果您看到 Googlebot 在嘗試檢索您網站的有效網頁時收到這個狀態碼 (您可以在 Google 網站管理員工具 [健康狀態] 標籤下的「檢索錯誤」網頁中看到這狀態碼),則可能是因為您的伺服器或主機封鎖了 Googlebot 的存取權。</li>
<li><strong>404 (Not found)</strong><br />
伺服器找不到要求的網頁。例如,如果該要求是針對伺服器上不存在的網頁,則伺服器通常會傳回此代碼。<br />
如果您的網站上沒有 robots.txt 檔案,並在 Google 網站管理員工具的「封鎖的網址」網頁看到這個狀態,則這個狀態是正確的。不過,如果您有 robots.txt 檔案,並看到此狀態,則您的 robots.txt 檔案可能未正確命名或位於錯誤的位置。(應該位於網域的最高層級並且命名為 robots.txt)。<br />
如果您在 Googlebot 嘗試檢索的網址中看到這個狀態,則 Googlebot 所追蹤的很可能是來自其他網頁的無效連結 (可能是舊連結或拼字錯誤的連結)。</li>
<li><strong>405 (Method Not Allowed)</strong><br />
不允許要求中指定的方法。</li>
<li><strong>406 (Not Acceptable)</strong><br />
無法以所要求的內容特性回應要求的網頁。</li>
<li><strong>407 (Proxy Authentication Required)</strong><br />
此狀態碼類似於 401(Not Authorized),但指定要求者必須使用 Proxy 進行驗證。當伺服器傳回此回應時,還會指出要求者應該使用的 Proxy。 </li>
<li><strong>408 (Request Timeout)</strong><br />
等候回應時,發生伺服器逾時。</li>
<li><strong>409 (Conflict)</strong><br />
完成要求時,伺服器遇到衝突。伺服器必須包括有關在回應中的衝突的資訊。伺服器可能會在 PUT 要求與較早的某個要求相衝突時傳回此狀態碼作為回應,並會提供這兩個要求之間的差異清單。</li>
<li><strong>410 (Gone)</strong><br />
要求的資源已永久移除後,伺服器會回傳此回應。此代碼類似於 404 (Not Found) 代碼,但在資源曾經存在但現已不復存在的情況下,有時會取代 404 而使用。如果資源已永久遷移,則應使用 301 指定資源的新位置。</li>
<li><strong>411 (Length Required)</strong><br />
伺服器不接受不含有效內容長度不標頭欄位的要求。</li>
<li><strong>412 (Precondition Failed)</strong><br />
伺服器未滿足要求者所要求的其中一個前提。</li>
<li><strong>413 (Request Entity Too Large)</strong><br />
伺服器無法處理要求,因為要求過於龐大,伺服器無法處理。</li>
<li><strong>414 (Requested URI Is Too Long)</strong><br />
要求的 URI (通常是網址) 過長,伺服器無法處理。</li>
<li><strong>415 (Unsupported Media Type)</strong><br />
該要求的格式不受要求的網頁支援。</li>
<li><strong>416 (Requested Range Not Satisfiable)</strong><br />
如果該要求是針對該網頁上無法使用的範則,則伺服器便會傳回此狀態碼。</li>
<li><strong>417 (Expectation Failed)</strong><br />
伺服器無法滿足預期要求標頭欄位的要求。</li>
</ul><br />
<p><strong>5xx (Server Error)</strong><br />
這些狀態碼指出伺服器在嘗試處理要求時發生內部錯誤。這些錯誤可能是伺服器本身的錯誤,而不是要求的錯誤。</p><ul><li><strong>500 (Internal Server Error)</strong><br />
伺服器遇到錯誤,無法完成要求。</li>
<li><strong>501 (Not Implemented)</strong><br />
伺服器不具備完成要求所需的功能。例如,當伺服器無法識別要求方式時,就會傳回此代碼。</li>
<li><strong>502 (Bad Gateway)</strong><br />
伺服器用作閘道或 Proxy,接收到來自上游伺服器的無效回應。</li>
<li><strong>503 (Service unavailable)</strong><br />
伺服器目前暫時無法使用 (因為超載或維護之故而關閉)。一般而言,這是暫時性狀態。</li>
<li><strong>504 (Gateway Timeout)</strong><br />
伺服器用作閘道或 Proxy,而且未接收到來自上游伺服器的及時要求。</li>
<li><strong>505 (HTTP Version Not Supported)</strong><br />
伺服器不支援要求中所用的 HTTP 通訊協定版本。</li>
</ul>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-49095090587741562782013-05-30T22:21:00.000+08:002013-07-18T12:32:50.903+08:00[PHP] 從網頁執行 SVN 更新想說寫一個透過網頁就可以執行 SVN 更新的程式,結果並不是我想得那樣簡單,有一些眉角需要注意的說。<br />
<br />
先以 Apache 的使用者帳號執行 SVN checkout,這樣 Apache 才有 SVN 的連結權力,才可以透過網頁執行 SVN update<br />
<br />
<pre class="sh" name="code">su -s /bin/bash www-data
cd /var/www
svn checkout http://www.xxx.com/svn/my_site
</pre><br />
<br />
<ol><li>在用 PHP 執行 shell 指令前要加上 <strong>export LANG=C.UTF-8</strong> 的環境宣告,不然 SVN update 時遇到中文會出現 error,Ubuntu 的 Apache 預設是 LANG=C</li>
<li>接著要為 SVN 補上 <strong>--accept theirs-full</strong> 的參數,這是當衝突發生時,都以 SVN Server 的檔案版本為主</li>
<li>最後再加上 <strong>2>&1</strong>,讓 PHP 可以取得包含錯誤的所有訊息</li>
</ol><pre class="php" name="code"><?php
putenv('LANG=C.UTF-8');
$result = shell_exec('svn update --accept theirs-full /var/www/my_site 2>&1');
echo nl2br($result);
</pre>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-14676851737232896722012-09-05T13:32:00.003+08:002013-06-10T22:25:48.686+08:00Apache 消失的 ServerLimit 參數在某些版本的 Apache 中如果單純加大 MaxClients 的設定值,就會得到以下的錯誤訊息: <br />
<blockquote>WARNING: MaxClients of 300 exceeds ServerLimit value of 256 servers,<br />
lowering MaxClients to 256. To increase, please see the ServerLimit<br />
directive.<br />
</blockquote><br />
這時必須再增加 ServerLimit 這個設定,而這個設定在設定檔中並沒有提示,所以需要額外加入。<br />
<pre class="xml" name="code"><IfModule mpm_prefork_module>
ServerLimit 500 # 額外加入
StartServers 10
MinSpareServers 10
MaxSpareServers 20
MaxClients 300
MaxRequestsPerChild 0
</IfModule>
</pre><br />
停止並啟動(單純 restart 無法套用設定)<br />
service apache2 stop<br />
service apache2 start<br />
<br />
參考來源:<br />
<a target="_blank" href="http://blog.gilbert.tw/2009/08/apache-serverlimit-directive_12.html">Gilbert.tw > Apache 之謎樣 ServerLimit 指令 (directive)</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-89624465096605849712012-09-05T13:01:00.004+08:002023-02-25T21:38:11.120+08:00[Ubuntu] 用 logrotate 定期切割 Apache log 檔Ubuntu 預設已經為 Apache 建立了 log 分割管理,但在建立虛擬主機(Virtual Host),但又很龜毛的將 log 獨立到個別的子目錄下的話,預設的 logrotate 是沒有辦法處理到的,所以請記得為這龜毛的動作加上額外設定。<br />
<br />
編輯屬於 Apache 的設定檔,在檔案最後面加上額外的設定。<br />
<b>vim /etc/logrotate.d/apache2</b><br />
<pre class="cfg" name="code">/var/log/apache2/blog/*.log {
daily
missingok
rotate 52
dateext
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/apache2 reload > /dev/null
endscript
}
</pre><br />
參數說明:<br />
<b>daily</b> 每天整理,其他還有 weekly, monthly, yearly<br />
<b>missingok</b> 允許 log 檔不存在<br />
<b>nomissingok</b> 不允許 log 檔不存在,會丟出錯誤 (預設)<br />
<b>rotate 7</b> 保留 7 次的分割<br />
<b>size 1M</b> 大小超過 1M 就執行分割,單位可以是 1024, 100k, 4M, 1G<br />
<b>dateext</b> 用日期來建立分割檔名,而非流水號<br />
<b>dateformat -%Y%m%d</b> 日期格式<br />
<b>compress</b> 壓縮分割,預設用 gzip (預設)<br />
<b>nocompress</b> 不壓縮分割<br />
<b>delaycompress</b> 延後壓縮直到下一次 rotate<br />
<b>notifempty</b> 如果 log 是空的就不執行<br />
<b>copytruncate</b> 以[複製清空]的方式分割 log,這樣可以用不到 postrotate 設定<br />
<b>mail xxx@address</b> 將分割內容用 mail 寄出<br />
<b>prerotate/endscript</b> 分割前要執行的指令<br />
<b>postrotate/endscript</b> 分割後要執行的指令 <br />
<br />
<br />
測試設定檔是否正確<br />
<b>logrotate -f /etc/logrotate.conf</b> <br />
<br />
<br />
參考來源:<br />
<a target="_blank" href="http://ihower.tw/blog/archives/3565/">使用 logrotate 定期整理 Rails Log 檔案</a><br />
<a target="_blank" href="http://blog.jsdan.com/3616">[ubuntu] 使用 logrotate 定期切割壓縮 apache2 的 log 檔</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-13295502360347923762012-05-05T01:53:00.000+08:002013-06-10T22:34:10.512+08:00[轉載] 让PHP更快的提供文件下载作者:<a target="_blank" href="http://www.laruence.com/">Laruence</a><br />
本文地址:<a target="_blank" href="http://www.laruence.com/2012/05/02/2613.html">http://www.laruence.com/2012/05/02/2613.html</a><br />
<br />
一般来说, 我们可以通过直接让URL指向一个位于Document Root下面的文件, 来引导用户下载文件.<br />
<br />
但是, 这样做, 就没办法做一些统计, 权限检查, 等等的工作. 于是, 很多时候, 我们采用让PHP来做转发, 为用户提供文件下载.<br />
<br />
<pre class="php" name="code"><?php
$file = "/tmp/dummy.tar.gz";
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="'
. basename($file) . '"');
header("Content-Length: ". filesize($file));
readfile($file);
</pre><br />
但是这个有一个问题, 就是如果文件是中文名的话, 有的用户可能下载后的文件名是乱码.<br />
<br />
于是, 我们做一下修改(参考: :<br />
<br />
<pre class="php" name="code"><?php
$file = "/tmp/中文名.tar.gz";
$filename = basename($file);
header("Content-type: application/octet-stream");
//处理中文文件名
$ua = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="'
. $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
header("Content-Disposition: attachment; filename*=\"utf8''"
. $filename . '"');
} else {
header('Content-Disposition: attachment; filename="'
. $filename . '"');
}
header('Content-Disposition: attachment; filename="'
. $filename . '"');
header("Content-Length: ". filesize($file));
readfile($file);
</pre><br />
恩, 现在看起来好多了, 不过还有一个问题, 那就是readfile, 虽然PHP的readfile尝试实现的尽量高效, 不占用PHP本身的内存, 但是实际上它还是需要采用MMAP(如果支持), 或者是一个固定的buffer去循环读取文件, 直接输出.<br />
<br />
输出的时候, 如果是Apache + PHP mod, 那么还需要发送到Apache的输出缓冲区. 最后才发送给用户. 而对于Nginx + fpm如果他们分开部署的话, 那还会带来额外的网络IO.<br />
<br />
那么, 能不能不经过PHP这层, 直接让Webserver直接把文件发送给用户呢?<br />
<br />
今天, 我看到了一个有意思的文章: <a target="_blank" href="http://www.jasny.net/articles/how-i-php-x-sendfile/">How I PHP: X-SendFile</a>.<br />
<br />
我们可以使用Apache的module <a target="_blank" href="https://tn123.org/mod_xsendfile/">mod_xsendfile</a>, 让Apache直接发送这个文件给用户:<br />
<br />
<pre class="php" name="code"><?php
$file = "/tmp/中文名.tar.gz";
$filename = basename($file);
header("Content-type: application/octet-stream");
//处理中文文件名
$ua = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="'
. $encoded_filename . '"');
} else if (preg_match("/Firefox/", $ua)) {
header("Content-Disposition: attachment; filename*=\"utf8''"
. $filename . '"');
} else {
header('Content-Disposition: attachment; filename="'
. $filename . '"');
}
header('Content-Disposition: attachment; filename="'
. basename($file) . '"');
//让Xsendfile发送文件
header("X-Sendfile: $file");
</pre><br />
X-Sendfile头将被Apache处理, 并且把响应的文件直接发送给Client.<br />
<br />
Lighttpd和Nginx也有类似的模块, 大家有兴趣的可以去找找看<br />
<br />
<hr />mod-xsendfile 在 Ubuntu 的安裝方法:<br />
<strong>sudo apt-get install libapache2-mod-xsendfile</strong>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-31691041480423325242012-05-03T14:49:00.003+08:002023-02-25T21:39:35.301+08:00[Ubuntu 11] HTTP Live Streaming 安裝與測試<strong>安裝 Apache</strong><br />
<pre class="sh" name="code">apt-get install apache2
</pre><br />
在 <strong>/etc/apache2/mods-available/mime.conf</strong> 加入以下內容: <br />
<pre class="cfg" name="code"># HLS file type
AddType application/x-mpegURL .m3u8
AddType video/MP2T .ts
</pre><br />
<br />
Ubuntu 11.04 預設的 FFmpeg 是沒有啟用 h.264 的支援,所以要自己編譯。<br />
<br />
<strong>安裝編譯時所需要的套件</strong><br />
<pre class="sh" name="code">apt-get update
apt-get install build-essential checkinstall subversion git libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev libx264-dev librtmp-dev
</pre><br />
<br />
<strong>編譯 FFmpeg</strong><br />
<pre class="sh" name="code">cd /opt
git clone git://git.videolan.org/ffmpeg
cd ffmpeg
./configure --prefix=/usr --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-ffplay --enable-shared --enable-gpl --enable-postproc --enable-version3 --enable-nonfree --enable-avfilter --enable-pthreads --enable-vdpau --enable-librtmp
make -j$(grep processor /proc/cpuinfo |wc -l)
checkinstall --pkgname=ffmpeg --pkgversion="5.0.1" --backup=no --deldoc=yes --default
</pre><br />
<br />
segmenter 是用來切割 FFmpeg 轉好的 ts 檔<br />
<strong>編譯 segmenter</strong><br />
<pre class="sh" name="code">cd /opt
svn co http://httpsegmenter.googlecode.com/svn/trunk
cd trunk
sed 's/\/local//g' Makefile.txt > Makefile
make -j$(grep processor /proc/cpuinfo |wc -l)
checkinstall --pkgname=segmenter --pkgversion="2" --backup=no --deldoc=yes --default
</pre><br />
<br />
<br />
<strong>測試影片轉檔</strong> <br />
<pre class="sh" name="code">cd /var/www
ffmpeg -i gt4.avi -f mpegts -vcodec libx264 -acodec libmp3lame gt4_pre.ts
ffmpeg -i gt4.avi -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 720x480 -vcodec libx264 -b 800k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 800k -bufsize 800k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 720:480 -g 30 -async 2 gt4_pre.ts
</pre><br />
<br />
<strong>測試 RTMP 串接轉檔</strong> <br />
<pre class="sh" name="code">ffmpeg -i rtmp://flashstream.adobe.com/ondemand/flash/cs5/prod/production-performance_400x224 -f mpegts -vcodec libx264 -acodec libmp3lame rtmp_pre.ts
</pre><br />
<br />
<strong>測試影片切割</strong> <br />
<pre class="sh" name="code">segmenter -i gt4_pre.ts -d 10 -o gt4_pre -x stream.m3u8 -p http://192.168.0.10/
</pre><br />
<br />
<strong>利用 pipe 從轉檔到切割</strong> <br />
<pre class="sh" name="code">ffmpeg -i gt4.avi -f mpegts -vcodec libx264 -acodec libmp3lame - |segmenter -i - -d 10 -o gt4_pre -x stream.m3u8 -p http://192.168.0.10/
</pre><br />
<br />
<strong>m3u8 檔案格式</strong> <br />
<pre class="cfg" name="code">#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:11,
http://192.168.0.10/gt4_pre-1.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-2.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-3.ts
#EXTINF:11,
http://192.168.0.10/gt4_pre-4.ts
#EXTINF:5,
http://192.168.0.10/gt4_pre-5.ts
#EXT-X-ENDLIST
</pre><br />
<br />
<strong>以 HTML5 播放影片</strong><br />
<pre class="xml" name="code"><html>
<head><title>Video Test</title></head>
<body>
<center>
<video tabindex="0" width="720" height="480"><source src="/stream.m3u8"></video>
</center>
</body>
</html>
</pre><br />
<br />
參考文件:<br />
<a href="http://buildall.wordpress.com/2011/05/09/how-to-compile-and-install-ffmpeg-in-ubuntu-11-04/">How to compile and install ffmpeg in Ubuntu 11.04</a><br />
<a href="http://ubuntuforums.org/showpost.php?p=9868359&postcount=1289">Install FFmpeg and x264 on Ubuntu Lucid Lynx 10.04 LTS</a><br />
<a href="http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/">iPhone HTTP Streaming with FFMpeg and an Open Source Segmenter</a><br />
<a href="http://tools.ietf.org/html/draft-pantos-http-live-streaming-08">HTTP Live Streaming draft-pantos-http-live-streaming-08</a><br />
<a href="http://southking.iteye.com/blog/1477533">http live streaming(m3u8 streaming)(m3u8)</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com2tag:blogger.com,1999:blog-5946530704742130970.post-61697428906592415472012-03-14T14:48:00.003+08:002013-06-10T22:38:24.354+08:00[Ubuntu 11] 安裝 Redmine 與 SVN<strong>安裝 LAMP & Redmine</strong><br />
<pre class="sh" name="code"># 安裝 LAMP
apt-get install apache2 php5 mysql-server php5-mysql libapache2-mod-php5 libapache2-mod-auth-mysql
# 安裝 svn, dav_svn
apt-get install subversion libapache2-svn
# 安裝 redmine
apt-get install redmine redmine-mysql libapache2-mod-fcgid libapache2-mod-passenger
# 可以使用下面的方式重新設定 redmine DB 連結
#dpkg-reconfigure redmine
# 啟用 Apache 套件 php5, headers, expires
a2enmod php5 dav_svn auth_mysql cgid fcgid passenger rewrite ssl setenvif
# 安裝 git, phpmyadmin
apt-get install mercurial git-core phpmyadmin
# 連結 phpmyadmin 設定檔
cd /etc/apache2/conf.d/
ln -s ../../phpmyadmin/apache.conf phpmyadmin.conf
service apache2 restart
</pre><br />
<br />
<strong>安裝 Redmine 套件</strong><br />
<pre class="sh" name="code">gem install pandoc-ruby rdiscount rpeg-markdown bluefeather
cd /usr/share/redmine/vendor/plugins
# 安裝 Code Review 套件
hg clone https://bitbucket.org/haru_iida/redmine_code_review
rake db:migrate_plugins RAILS_ENV=production
# 安裝 Markdown Extra formatter 套件
git clone git://github.com/juno/redmine_markdown_extra_formatter.git
# 安裝 reStructuredText formatting 套件
git clone git://github.com/alphabetum/redmine_restructuredtext_formatter.git
cd redmine_restructuredtext_formatter
git checkout pandoc-ruby
</pre><br />
<br />
<strong>建立SVN庫</strong><br />
<pre class="sh" name="code">mkdir -p /home/repoadmin/repos
svnadmin create /home/repoadmin/repos/team1
svnadmin create /home/repoadmin/repos/team2
chown -R www-data:www-data /home/repoadmin/repos
</pre><br />
<br />
<strong>建立SVN認證時需要的DB使用者(redmine_svn_auth)</strong><br />
<pre class="sql" name="code">CREATE USER 'redmine_svn_auth'@'localhost' IDENTIFIED BY 'redmine_svn_auth';
GRANT SELECT(id, login, hashed_password, status ,type) ON redmine_default.users TO 'redmine_svn_auth'@'localhost';
</pre><br />
<br />
<strong>設定 Apache2 Site</strong> <br />
<pre class="sh" name="code">cd /etc/apache2/sites-available/
cp default redmine_svn
vim redmine_svn
</pre><br />
<pre class="xml" name="code"><VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /usr/share/redmine/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /usr/share/redmine/public>
Options ExecCGI FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} dispatch.fcgi$
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</Directory>
<Location /svn>
DAV svn
SVNParentPath /home/repoadmin/repos
SVNPathAuthz off
AuthBasicAuthoritative Off
AuthUserFile /dev/null
AuthType Basic
AuthName "Subversion Repository"
# auth_mysql help in http://localhost/doc/libapache2-mod-auth-mysql/DIRECTIVES.gz
Auth_MYSQL On
Auth_MySQL_Host localhost
Auth_MYSQL_DB redmine_default
Auth_MYSQL_Username redmine_svn_auth
Auth_MYSQL_Password redmine_svn_auth
Auth_MYSQL_Password_Table users
Auth_MYSQL_Username_Field login
Auth_MYSQL_Password_Field hashed_password
Auth_MySQL_Password_Clause " AND status=1 AND type='User' "
Auth_MYSQL_Empty_Passwords Off
Auth_MYSQL_Encryption_Types SHA1Sum
# Options: Crypt_DES, Crypt_MD5, Crypt, PHP_MD5, SHA1Sum, MySQL, Apache
Require valid-user
</Location>
LogLevel warn
CustomLog /var/log/apache2/redmine_access.log combined
ErrorLog /var/log/apache2/redmine_error.log
</VirtualHost>
</pre><br />
<br />
<strong>重新啟動 Apache</strong> <br />
<pre class="sh" name="code">a2dissite default
a2ensite redmine_svn
service apache2 restart
</pre><br />
<br />
<strong>測試網址</strong> <br />
<ul><li>Redmine: <a target="_blank" href="http://localhost/">http://localhost/</a></li>
<li>SVN: <a target="_blank" href="http://localhost/svn/team1/">http://localhost/svn/team1/</a></li>
</ul><br />
<br />
參考來源:<br />
<a target="_blank" href="http://blog.longwin.com.tw/2011/03/redmine-debian-ubuntu-linux-2011/">將 Redmine 安裝於 Debian、Ubuntu Linux</a><br />
<a target="_blank" href="http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_Ubuntu">Ubuntu 10.04 using Passenger</a><br />
<a target="_blank" href="http://www.pigo.idv.tw/archives/851">svn 使用和 redmine 相同帳號進行認證</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com4tag:blogger.com,1999:blog-5946530704742130970.post-28869189601373658192011-08-18T16:42:00.007+08:002013-06-10T22:52:50.445+08:00[轉載] apache2ctl 指令轉載自:<a target="_blank" href="http://tw.myblog.yahoo.com/ok-free/article?mid=5985&next=5984&l=f&fid=14">Ubuntu系統網絡應用服務器Apache配置基礎</a><br />
<br />
apache2ctl 是 Apache2 服務器的前端程序。他可以幫助管理員控制 Apache2 後台 daemon 的功能。 <br />
<br />
<dl><dt>apache2ctl -v</dt>
<dd>顯示 apache 的版本。</dd>
<dt>apache2ctl -V</dt>
<dd>顯示 apache 的版本和編譯參數。</dd>
<dt>apache2ctl -h</dt>
<dd>輸出命令列選項的簡要說明。</dd>
<dt>apache2ctl -l</dt>
<dd>輸出一個靜態編譯在服務器中的模塊的列表。
它不會列出使用 LoadModule 指令動態加載的模塊。</dd>
<dt>apache2ctl -L</dt>
<dd>輸出一個指令的列表,并包含了各指令的有效參數和使用區域。</dd>
<dt>apache2ctl -t</dt>
<dd>僅對配置文件執行語法檢查。</dd>
<dt>apache2ctl -t -D DUMP_VHOSTS<br />
apache2ctl -S</dt>
<dd>顯示虛擬主機配置的詳細信息。</dd>
<dt>apache2ctl -t -D DUMP_MODULES<br />
apache2ctl -M</dt>
<dd>顯示動態模組加載的詳細信息。 </dd>
<dt>apache2ctl start</dt>
<dd>啟動 apache2 daemon。</dd>
<dt>apache2ctl stop</dt>
<dd>停止 apache2 daemon。</dd>
<dt>apache2ctl restart</dt>
<dd>重新啟動 apache2 daemon。</dd>
<dt>apache2ctl status</dt>
<dd>顯示一個簡要的狀態報告。</dd>
<dt>apache2ctl graceful</dt>
<dd>優雅地重新啟動 apache2 daemon。
如果 daemon 尚未啟動,則啟動它。它和標準重新啟動的不同之處在於:不會中斷當前已經打開的連接,也不會立即關閉日誌。這意味著,如果在日誌滾動腳本使用它,則在處理日誌之前必須加入一個實實在在的延遲,以確保老的日誌文件在被處理前已經關閉。在重新啟動 daemon 之前,此命令會使用 configtest 自動檢查配置文件,以確保 apache 不會死掉。</dd>
<dt>apache2ctl graceful-stop</dt>
<dd>優雅地停止 apache2 daemon。
它和標準停止的不同之處在於:不會中斷當前已經打開的連接,也不會立即關閉日誌。</dd>
<dt>apache2ctl configtest</dt>
<dd>執行一次配置文件語法檢查。
它解析配置文件,並報告 Syntax Ok 或者是特定的語法錯誤詳細信息。</dd> </dl>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-41321001966529460582011-08-18T15:10:00.004+08:002011-08-18T16:00:42.422+08:00[Ubuntu] Apache 未設定 ServerName 造成的警告Ubuntu 下的 Apache 有時候在啟動時會出現以下的警告訊息:<br />
<strong style="background-color: white; color: red;">Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName</strong><br />
<br />
由於沒有任何 ServerName 的設定造成的警告,只要在 <strong>/etc/apache2/apache2.conf </strong> 中加入 <strong>ServerName localhost</strong> 的預設值就不會出現這個錯誤了。<br />
<br />
這個問題我之前也遇到過,但不常發生,久了就忘記該把設定寫在哪裡了,因為可以設定的地方有三四個,為了遵守統一的規則才不會亂。<br />
<br />
當要建立多個虛擬主機時,只要在 <strong><VirtualHost *:80></strong> 中才去覆寫 <strong>ServerName my_host_name</strong> 就不會衝突了。<br />
<br />
Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-48511870655953473942010-12-30T06:22:00.002+08:002014-11-30T17:47:14.444+08:00美化 Apache autoindex因為原始的 auto Index 的頁面實在太醜了<br />
也許五年前看起來還很新潮,但現在已經過時了<br />
所以我自己做的一個 Apache 美化套件<br />
<br />
檔案下載:<a target="_blank" href="https://sites.google.com/site/weskerjax/code-demo/fancy.zip?attredirects=0">fancy.zip</a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcR4SIFN7kLTQcBsuommBSoKN2iOHw-ZO2j8rAWSc1BlksukJFY15zq0EBRTSOpQkcJWCk-2g9qLIwWtlCn8FiF8Bn8zdnEW4PgdYFpbPGW1xxbNtTEHzPqtUXz7YIGHsJtsIUr7r4TSFQ/s1600/screenshot.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcR4SIFN7kLTQcBsuommBSoKN2iOHw-ZO2j8rAWSc1BlksukJFY15zq0EBRTSOpQkcJWCk-2g9qLIwWtlCn8FiF8Bn8zdnEW4PgdYFpbPGW1xxbNtTEHzPqtUXz7YIGHsJtsIUr7r4TSFQ/s400/screenshot.png" /></a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-32196071490008019332010-12-30T06:03:00.001+08:002013-06-10T23:14:57.884+08:00Apache Expires模組(mod_expires) 設定參數<pre class="xml" name="code"># @version $Id: .htaccess 130 2010-09-29 10:03:56Z jax.hu $
#Options -FollowSymLinks -Indexes #TODO 開發時關閉
# 關閉 Apache Rewrite 模組
<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>
# 啟用 Apache mod_expires 模組,來管理 browser 端的 cache 時間
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
# ExpiresDefault "<base> [plus] {<num> <type>}*"
# base:[ access | modification ]
# type:[ years | months | weeks | days | hours | minutes | seconds ]
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault "access plus 1 years"
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|swf|txt|xml|js|css)$">
ExpiresDefault "access plus 7 days"
</FilesMatch>
</IfModule>
# 關閉 Apache 對檔案的實體標籤
FileETag none
</pre><br />
參考來源:<br />
<a target="_blank" href="http://httpd.apache.org/docs/2.0/mod/mod_expires.html">mod_expires - Apache HTTP Server:</a><br />
<a target="_blank" href="http://man.lupaworld.com/content/manage/Apache2.2_chinese_manual/mod/mod_expires.html">mod_expires - Apache 2.2 中文版参考手册:</a><br />
<a target="_blank" href="http://plog.longwin.com.tw/my_note-unix/2008/09/18/apache2-enable-mod_expires-2008">Apache2 載入 Expires 的模組(mod_expires) 與 設定</a><br />
<a target="_blank" href="http://www.ezdiy.org/forum/viewtopic.php?id=281">ezDIY.org / 使用mod_expires模組來加速網頁瀏覽</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-90647542055463731652010-12-30T05:54:00.001+08:002013-06-10T23:15:22.904+08:00Apache 壓縮模組(mod_deflate) 設定參數<pre class="xml" name="code"># @version $Id: .htaccess 130 2010-09-29 10:03:56Z jax.hu $
RewriteEngine on
RewriteRule ^.*$ index.php
php_flag magic_quotes_gpc off
php_flag register_globals on
php_flag output_buffering on
# 啟用 Apache 壓縮模組
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/js
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE application/postscript
AddOutputFilter DEFLATE html htm xml css js svg
# properly handle requests coming from behind proxies
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>
</pre><br />
參考來源:<br />
<a target="_blank" href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate - Apache HTTP Server:</a><br />
<a target="_blank" href="http://man.lupaworld.com/content/manage/Apache2.2_chinese_manual/mod/mod_deflate.html">mod_deflate - Apache 2.2 中文版参考手册</a><br />
<a target="_blank" href="http://twntwn.info/blog/ajer001/archives/1889">[Apache] 壓縮你的網頁 – mod_deflate/mod_gzip、ob_gzhandler、zlib | 阿駕零零壹 © 學習筆記:</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-35644184987187590672010-12-08T11:42:00.002+08:002023-02-26T14:16:28.796+08:00[Ubuntu] setup SVN base Apache note# 安裝 Apache & SVN<br />
<b>apt-get install apache2 apache2.2-common apache2-utils apache2-doc libapache2-svn subversion</b><br />
<br />
# 建立 Repositorys 的目錄<br />
<b>mkdir /var/lib/svn</b><br />
<br />
# 建立三個 Repository<br />
<b>svnadmin create /var/lib/svn/repo1<br />
svnadmin create /var/lib/svn/repo2<br />
svnadmin create /var/lib/svn/repo3</b><br />
<br />
# 變更 Repositorys 的權限給 Apache<br />
<b>chown -R www-data:www-data /var/lib/svn</b><br />
<br />
# 啟用 Apache 中的 dav_svn<br />
<b>a2enmod dav_svn</b><br />
<br />
# 設定 SVN 使用者帳號<br />
<b>htpasswd -c /etc/apache2/dav_svn.passwd user1<br />
htpasswd /etc/apache2/dav_svn.passwd user2<br />
htpasswd /etc/apache2/dav_svn.passwd user3</b><br />
<br />
# 編輯 SVN 配置檔<br />
<b>vim /etc/apache2/mods-available/dav_svn.conf</b><br />
<pre class="xml" name="code"><Location /svn>
DAV svn
SVNParentPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
</pre><br />
# 編輯 SVN 資源權限<br />
<b>vim /etc/apache2/dav_svn.authz</b><br />
<pre class="cfg" name="code"># 設定使用者群組
[groups]
group1 = user1,user2
group2 = user1,user3
# 設定全域皆可讀取
[/]
* = r
# 指定 repo1 只有 group1 可以寫入
[repo1:/]
@group1 = rw
# 指定 repo1 中 blog 這個目錄只有 uesr2 可以寫入
[repo1:/blog/]
uesr2 = rw
# 指定 repo2 只有 group2 可以寫入
[repo2:/]
@group2 = rw
# 指定 repo3 只有 user1 可以寫入
[repo3:/]
user1 = rw
</pre><br />
# 重新啟動 Apache<br />
<b>/etc/init.d/apache2 restart</b><br />
<br />
<br />
參考來源:<br />
<a target="_blank" href="http://blog.xuite.net/gbisland/linux/14229857">Ubuntu - 安裝 SVN (Subversion Server)</a><br />
<a target="_blank" href="http://xok.la/2009/06/subversion_group_users_grant.html">Subversion用户,权限管理</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-70373909374647679742010-08-23T14:37:00.009+08:002013-06-10T23:24:14.668+08:00[轉載] Apache之AllowOverride參數詳解轉載自: <a target="_blank" href="http://www.systn.com/data/articles/246_tw.html">Apache之AllowOverride參數詳解</a><br />
日期:2008-06-20 作者:喜騰小二 來源:PHPChina<br />
<br />
通常利用Apache的rewrite模組對 URL 進行重寫的時候, rewrite規則會寫在 .htaccess 檔案裡。但要使 apache 能夠正常的讀取.htaccess 檔案的內容,就必須對.htaccess 所在目錄進行配置。從安全性考慮,根目錄的AllowOverride內容一般都配置成不允許任何Override ,即<br />
<pre class="xml" name="code"><Directory /myblogroot/>
AllowOverride None
</Directory>
</pre><br />
在 AllowOverride 設定為 None 時, .htaccess 檔案將被完全略過。當此指令設定為 All 時,所有俱有 “.htaccess” 作用域的指令都允許出現在 .htaccess 檔案中。<br />
<br />
而對於 URL rewrite 來說,至少需要把目錄設定為<br />
<pre class="xml" name="code"><Directory /myblogroot/>
AllowOverride FileInfo
</Directory>
</pre><br />
<strong>AllowOverride的參數</strong>:<br />
<dl><dt>AuthConfig</dt>
<dd style="color: rgb(102, 102, 102);">允許使用與認證授權相關的指令(AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, 等)。 </dd>
<dt>FileInfo</dt>
<dd style="color: rgb(102, 102, 102);">允許使用控制文檔類型的指令(DefaultType, ErrorDocument, ForceType, LanguagePriority, SetHandler, SetInputFilter, SetOutputFilter, mod_mime中的 Add* 和 Remove* 指令等等)、控制文檔元資料的指令(Header, RequestHeader, SetEnvIf, SetEnvIfNoCase, BrowserMatch, CookieExpires, CookieDomain, CookieStyle, CookieTracking, CookieName)、mod_rewrite中的指令(RewriteEngine, RewriteOptions, RewriteBase, RewriteCond, RewriteRule)和mod_actions中的Action指令。 </dd>
<dt>Indexes</dt>
<dd style="color: rgb(102, 102, 102);">允許使用控制目錄索引的指令(AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName, 等)。 </dd>
<dt>Limit</dt>
<dd style="color: rgb(102, 102, 102);">允許使用控制主機訪問的指令(Allow, Deny, Order)。 </dd>
<dt>Options[=Option,...]</dt>
<dd style="color: rgb(102, 102, 102);">允許使用控制指定目錄功能的指令(Options和XBitHack)。可以在等號後麵附加一個逗號分隔的(無空格的)Options選項清單,用來控制允許Options指令使用哪些選項。</dd></dl>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-70581740902172666832010-08-23T13:52:00.005+08:002023-02-26T14:17:13.123+08:00利用 Apache .htaccess 修改 PHP 系統設定<pre class="cfg" name="code">RewriteEngine on
RewriteRule ^.*$ index.php #將所有請求轉至 index.php
#除特定檔案的請求以外的轉至 index.php
#RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
php_flag register_globals off #將傳入參數註冊為全域變數
php_flag magic_quotes_gpc off #對特殊字元加上的反斜線
php_flag display_error off #在網頁上顯示錯誤訊息
php_flag output_buffering on #開啟輸出緩衝
php_flag log_error on #紀錄錯誤訊息
php_flag allow_url_fopen off #fopen 可開啟遠端網頁
php_flag expose_php off #顯示PHP 版本資訊
php_flag safe_mode on #安全模式
php_value include_path "/path/to/lib" #自訂函數庫的位址
</pre><br />
<br />
參考網址:<br />
<a target="_blank" href="http://ssorc.tw/rewrite.php/read-583.html">php_flag + php_value + Apache 在不更改 php.ini 的情況下更改預設值</a><br />
<a target="_blank" href="http://www.systn.com/data/articles/246_tw.html">Apache之AllowOverride參數詳解</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com2tag:blogger.com,1999:blog-5946530704742130970.post-54728118763539296252010-07-16T18:42:00.007+08:002013-06-10T23:25:22.711+08:00[Ubuntu] PHP 連接 Oracle 語系設定PHP 的環境變數必須在 Apache 中設定<br />
<br />
開啟:<br />
vim /etc/apache2/envvars<br />
<br />
在最後面加入:<br />
export NLS_LANG="AMERICAN_AMERICA.UTF8"<br />
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"<br />
<br />
參考來源:<br />
<a target="_blank" href="http://tony.strongniche.com.tw/linux/contents.php?sn=534">如何新增apache使用的環境變數</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com2tag:blogger.com,1999:blog-5946530704742130970.post-19790773005670571312008-12-21T20:20:00.015+08:002023-02-26T14:25:30.567+08:00apache 301 Redirect 永久重新導向最近因為 Cookie 重複的問題花了不少時間<br />
當 wacanai.com 及 www.wacanai.com 同時在一台主機上<br />
用遊覽器瀏覽 www.wacanai.com 的網站時<br />
會因為之前在 wacanai.com 所存的 Cookie 變數<br />
當變數名稱重複時瀏覽器只會送出 wacanai.com 的變數<br />
雖然這兩個 domain 在 DNS 上都是正確<br />
但為了避免這樣的問題發生<br />
一台主機最好不要同時擁有這兩種 domain<br />
<br />
所以我利用 apache 中的 Rewrite 模組功能<br />
作永久性的重新導向<br />
在瀏覽時都導去 www.wacanai.com 這個網址<br />
<br />
首先先確定 Rewrite 模組已經載入了<br />
<strong>$ sudo a2enmod rewrite</strong><br />
<br />
Apache 還有一個重要的目錄設定就是:<br />
<pre class="xml" name="code"><Directory /myblogroot/>
AllowOverride FileInfo
Options FollowSymlinks
</Directory>
</pre><br />
如果沒有將這個設定加上<br />
Rewrite 在啟用時會出現 http 403 的錯誤<br />
<br />
可以利用 .htaccess 作以下轉址設定<br />
<pre class="cfg" name="code">RewriteEngine On
RewriteCond %{HTTP_HOST} ^wacanai\.com
RewriteRule (.*) http://www.wacanai.com/$1 [R=301,L]
</pre><br />
<br />
參考網址:<br />
<a target="_blank" href="http://www.seoimage.com/301-redirects-and-canonical-urls.html">301 Redirects & Canonical Redirects for Apache</a><br />
<a target="_blank" href="http://www.systn.com/data/articles/246_tw.html">Apache之AllowOverride參數詳解</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0tag:blogger.com,1999:blog-5946530704742130970.post-64666767740687962912007-10-25T22:41:00.003+08:002013-06-11T20:50:30.901+08:00為了 Web Server 忙一天! [Linux]今天又是做了很沒有效率的事,因為 Web Server 一直不能正常 Work,花了很多時間在找問題,原本是安裝系統選單中的 LAMP 套件,做了一些設定後,只有 Apache 運作是正常的,PHP 則是找不到相關 Lib,又是上網找了一堆資料,還到處求助同學,就因為效能的考量必須用到 Linux。<br />
<br />
想說套裝的 Ubuntu Linux 應該安裝好就能 Work,但卻不是我想的那麼快樂,雖然是有學到東西,但花的時間實在太多了,真想利用自己的時間慢慢做,不過所花的時間是值得的,在效能上的確比 Windows 快,而且所耗費的資源也很低,今天的問題就是預設的程序中少安裝了幾個套件。<br />
<br />
<span style="color: rgb(0, 0, 204);">sudo apt-get install apache2 </span><br />
<span style="color: rgb(0, 0, 204);">sudo apt-get install php5</span><br />
<span style="color: rgb(0, 0, 204);">sudo apt-get install mysql-server</span><br />
<span style="color: rgb(255, 0, 0);">sudo apt-get install php5-mysql </span><br />
<span style="color: rgb(255, 0, 0);">sudo apt-get install libapache2-mod-php5 </span><br />
<span style="color: rgb(255, 0, 0);">sudo apt-get install libapache2-mod-auth-mysql</span><br />
<span style="color: rgb(255, 0, 0);">sudo a2enmod php5</span><br />
<br />
藍色的指令是 LAMP 預設安裝的,紅色的指令是我自己後來裝上去的,安裝完後就可以正常 Work,真是給他卡到陰,出現了莫名其妙的怪問題,我還一直以為是我設定錯誤。<br />
<br />
相關教學:<a target="_blank" href="http://wiki.ubuntu.org.cn/index.php?title=LAMP%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE&variant=zh-tw">LAMP伺服器的配置</a>Jax Huhttp://www.blogger.com/profile/01953021685585893658noreply@blogger.com0