步驟:
前往 /etc/apache2/conf-available/security.conf ,找到ServerSignature,跟ServerTokens。
改成如下:
1 2 |
ServerSignature Off ServerTokens Prod |
參考:
How to improve Apache server security by limiting the information it reveals
AWS、PHP、LINUX、APACHE、MYSQL、CAKEPHP、JAVASCRIPT…….
步驟:
前往 /etc/apache2/conf-available/security.conf ,找到ServerSignature,跟ServerTokens。
改成如下:
1 2 |
ServerSignature Off ServerTokens Prod |
參考:
How to improve Apache server security by limiting the information it reveals
步驟如下:
1.開啟 apache headers
sudo a2enmod headers
2.
設定 /etc/apache2/conf-available/security.conf ,加上 header 設定
1 2 3 4 5 6 7 8 |
語法基本如下: Strict-Transport-Security: max-age=<expire-time> Strict-Transport-Security: max-age=<expire-time>; includeSubDomains Strict-Transport-Security: max-age=<expire-time>; preload 可直接複製下面貼到security.conf: Header always set Strict-Transport-Security "max-age=31536000;includeSubdomains; preload" |
3.重開apache
sudo service apache2 reload
參考文章:
[apache] apache 設定 HSTS ( HTTP Strict Transport Security )
避免網站MIME-sniffing 漏洞,在.htaccess 加入以下。
Header set X-Content-Type-Options nosniff
在網站的.htaccess加入以下:
Header set X-XSS-Protection “1; mode=block”
避免網站被XSS攻擊。
參考文章:
WordPress 如果以人輸入你的資料夾路徑,可能會看到資料。
要避免資料夾資料被看,可以在Wordpress網站根目錄的.htaccess加入以下指令:
Options -Indexes
進入Server前往下面Apache 路徑:
/etc/apache2/conf-enabled/security.conf
找到:
#Header set X-Frame-Options: “SAMEORIGIN”
將上面這行取消註解。
接著輸入以下指令:
a2enmod headers
suod service apache2 restart
這樣就可以了。
參考文章:
https://tecadmin.net/configure-x-frame-options-apache/
如何在Apache server下新增X-Frame-Options與Content-Security-Policy至Response Header中
安裝步驟如下,跟以前用gitclone 的方式不太一樣,都是指令列:
1 2 3 4 |
sudo snap install core; sudo snap refresh core sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot --apache |
當你的憑證快到期時,可以輸入任何下方一個指令:
sudo certbot –apache
sudo certbot renew –dry-run
如果你想查詢憑證何時到期,可以輸入以下指令:
sudo certbot certificates
建議可以看官方文件:
https://certbot.eff.org/lets-encrypt/ubuntufocal-apache
安裝步驟如下:
sudo apt-get update
sudo apt-get upgrade
一、安裝Apache
1 2 3 4 5 6 |
sudo apt-get install apache2 之後輸入網址會出現it works sudo a2enmod rewrite #若有需要,自行開啟mod_rewrite sudo a2enmod proxy_http #若有需要,自行開啟proxy_http sudo a2enmod proxy_balancer #若有需要,自行開啟proxy_balancer |
二、安裝php 7.4
1 2 3 4 |
sudo apt-get install php7.4 sudo apt-get install php7.4-mysql sudo apt-get install php-curl sudo service apache2 restart |
三、安裝Mysql
1 2 3 4 5 6 7 |
sudo apt-get install mysql-server 安裝完可以登入mysql看看 sudo mysql -u root -p 登入後,看一下資料庫: show databases; |
四、安裝Phpmyadmin
1 2 |
sudo apt-get install phpmyadmin php-mbstring (預設安裝目錄為/usr/share/phpmyadmin) |
phpmyadmin預設路徑是/usr/share/phpmyadmin,所以可以做個軟連結,讓我們可以直接在網址後面打/phpmyadmin:
cd /var/www
ln -s /usr/share/phpmyadmin
在網址後面打/phpmyadmin即可登入使用
Ubuntu 20.04安裝Phpmyadmin,會有無法透過phpmyadmin來登入root的問題,可以參考下面文章解決:
1 2 3 4 5 6 7 8 9 10 |
sudo mysql -u root -p #先登入mysql SELECT user,plugin,host FROM mysql.user WHERE user = 'root'; #看一下,會看到auth_socket屬性 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your pass'; #改成你要登入phpmyadmin root 的密碼 FLUSH PRIVILEGES; |
完成,現在已經可以用phpmyadmin登入了
參考文章:
https://devanswers.co/phpmyadmin-access-denied-for-user-root-localhost/