2021年10月29日 星期五

Ubuntu 一些小事項

 1.防火牆可以加開DNS

To open ports 53 & 43 on the UFW firewall run the commands below:

$ sudo ufw allow 53/tcp
$ sudo ufw allow 43/tcp
$ sudo ufw reload

Command Line 測試localhost 

        lynx "http://localhost"


Start Apache Web Server

        sudo systemctl start apache2

Check status 

        sudo systemctl status apache2


檢查埠號是否有開啟

        nc -zvw3 192.168.1.10 80

檢查網路狀態

        sudo netstat -nlp


解決啟動 Apache 網站伺服器時找不到 ServerName 的問題

hostname www.yourdomain.com

https://blog.miniasp.com/post/2012/06/23/apache2-Could-not-reliably-determine-the-server-fully-qualified-domain-name-using-for-ServerName


Apache 不紀錄某些log

SetEnvIf Remote_Addr "::1" dontlog

#不紀錄來自127.0.0.1的連線
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
CustomLog logs/access_log common env=!dontlog

#不紀錄存取robot.txt的連線
SetEnvIf Request_URI "^/robots\.txt$" dontlog
CustomLog logs/access_log common env=!dontlog