php.ini 增強安全性
-
disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
-
allow_url_fopen=Off
-
allow_url_include=Off
-
expose_php=Off
http header (X-Powered-By) 不帶php info -
load less modules
php -m 可看 module 列表
rename 副檔名 ini 成 disable
mv /etc/php.d/sqlite3.ini /etc/php.d/sqlite3.disable
-
display_errors=Off
lod error 但不讓 end user 看到 -
file_uploads=Off
關閉上傳檔案,如果必要,限制檔案大小
file_uploads=On
upload_max_filesize=1M
-
sql.safe_mode=On
-
magic_quotes_gpc=Off
-
避免執行過久,耗用資源,避免阻斷攻擊 DoS
max_execution_time = 30
max_input_time = 30
memory_limit = 40M
-
cgi.force_redirect=On
-
open_basedir="/var/www/html/"
限制 open_basedir,只開放必要的folder
apache 增強安全性
-
避免 root 身份執行 apache server
chown -R apache:apache /var/www/html/
/var/www/html/ 下的檔案權限 0444
/var/www/html/ 下的目錄權限 0445 -
Jails
應用虛擬化技術,Freebsd Jail, XEN, KVM or openVZ. 將伺服器跑在一個虛擬環境中 -
伺服器依照用途分類
- static asset
- php (cgi), 動態內容產生
- mysql,資料庫
- memcache,快取層,架在資料庫前面
- proxy and reverse proxy server,擋在所有機器前面,做 load balance。
-
http://httpd.apache.org/docs/current/misc/security_tips.html
apache 的 security tips