2018年2月24日 星期六

XAMPP 更新...

修正httpd.conf下列內容:

  1.  取消目錄瀏覽
  2. 將logs定時roration

取消目錄瀏覽,找到:
<Directory "D:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>

刪除其中的 Options 改成
<Directory "D:/xampp/htdocs">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

將logs做rotation
ErrorLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/error-%Y%m%d.log 86400"
CustomLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/access-%Y%m%d.log 86400" combined

將 / 重導至 HTTPS
<If "%{HTTP_HOST} != 'www.sclai.tk'">
    Redirect "/" "https://www.sclai.tk/"
</If>

<If "%{HTTPS} != 'on'">
    Redirect "/" "https://www.sclai.tk/"
</If>

修正httpd-ssl.conf下列內容:

  1. 將logs定時rotation
  2. #ErrorLog "D:/xampp729/apache/logs/error.log"
    ErrorLog "|D:/xampp729/apache/bin/rotatelogs.exe D:/xampp729/apache/logs/error-%Y%m%d.log 86400"

    #TransferLog "D:/xampp729/apache/logs/access.log"
    TransferLog "|D:/xampp729/apache/bin/rotatelogs.exe D:/xampp729/apache/logs/access-%Y%m%d.log 86400"

    #CustomLog "D:/xampp729/apache/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    CustomLog "|D:/xampp729/apache/bin/rotatelogs.exe D:/xampp729/apache/logs/ssl_request-%Y%m%d.log 86400" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

  3. 調整ServerName及ServerAdmin
  4. #ServerName www.example.com:443
    #ServerAdmin admin@example.com
    ServerName www.myname.com:443
    ServerAdmin nobody@gmail.com

  5. 配合sslforfree調整憑證檔案(全部憑證置放於conf/sslforfree/目錄下)
  6. #SSLCertificateFile "conf/ssl.crt/server.crt" SSLCertificateFile "conf/sslforfree/certificate.crt"

    #SSLCertificateKeyFile "conf/ssl.key/server.key" SSLCertificateKeyFile "conf/sslforfree/private.key" SSLCACertificateFile "conf/sslforfree/ca_bundle.crt"

修正php.ini的下列內容:

  1.  設定 PHP 的時區
  2. 開啟imap extension

設定PHP的時區
找到
[Date] ;date.timezone =

改成
[Date] date.timezone = "Asia/Taipei"

或者在 php 中加入:
date_default_timezone_set("Asia/Taipei");

就可以確保時區的正確性。

開啟imap extension
找到
;extension=imap

改成
extension=imap

2018年2月18日 星期日

Hard Links, Junctions, and Symbolic Links

在NTFS上有Hard link,Junction和Symbolic link三種,簡單來說:

  1. Hard Link就是檔案本身,僅適用在本機磁碟
  2. Junction是hard link的一種,專用於目錄
  3. Symbolic link本身就是一個檔案,指向鎖鏈結的檔案或目錄
詳細內容可參考:

可使用 mklink 來建立三種鏈結。

C:\>mklink /?
建立符號連結。

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      建立目錄符號連結。預設是檔案符號連結。
        /H      建立永久連結而不是符號連結。
        /J      建立目錄連接。
        Link    指定新符號連結名稱。
        Target  指定新連結參照的路徑 (相對或絕對)。

2018年2月17日 星期六

Apache logs rotation

XAMPP中apache的(\xampp\apache\logs]) access log和error log會隨時間增長,
可利用 (\xampp\apache\bin\) rotatelogs.exe 來 rotate log:

修改 (\xampp\apache\conf\) httpd.conf,運用 rotatelogs.exe 每 86400 秒產生一個檔案:
#ErrorLog "logs/error.log"
ErrorLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/error-%Y%m%d.log 86400"

#CustomLog "logs/access.log" combined
CustomLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/access-%Y%m%d.log 86400" combined

如啟用SSL,須同步修改 http-ssl.conf:
#ErrorLog "D:/xampp/apache/logs/error.log"
ErrorLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/error-%Y%m%d.log 86400"

#TransferLog "D:/xampp/apache/logs/access.log"
TransferLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/access-%Y%m%d.log 86400"

#CustomLog "D:/xampp/apache/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
CustomLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/ssl_request-%Y%m%d.log 86400" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"