Tag: Apache
在 Ubuntu 開啟及關閉虛擬主機, 會用 a2ensite 及 a2dissite 指令, 這個方法在管理多個 Virtual Host 時方便很多, 以下是在 RHEL 7 及 Centos 7 下, 設定類似 Ubuntu 管理 Virtual Host 的方法。 Ubuntu 在 /etc/httpd 目錄下建立兩個目錄, …
在預設的情況下, HTTP 的 Header 會包含了 Web Server 及 PHP 的版本, 基於安全理由, 可以用以下方法隱藏 Apache, Nginx 及 PHP 的版本資訊。 Apache 開啟 Apache 的 httpd.conf, CentOS 預設位置是 /etc/httpd/conf/httpd.conf: # vi /etc/httpd/conf/httpd.conf 找到 …
Apache 配置 PHP 一般會預設用 mod_php 的方法安裝, 安裝 Nginx 便會使用 PHP-FPM。但如果在 Apache 不想使用預設的 prefork 作為 MPM (通常基於效能因素), 想使用 worker 或 event, 便需要使用 PHP-FPM 的方法安裝 PHP。 本文會示範在 CentOS 7 安裝 Apache …
現在很多入門的 VPS 只有 1GB Ram, 如果在 1GB RAM 的 VPS 安裝 Apache, PHP 及 MySQL / MariaDB, 為僻免出現 out of memory 的情況, 可以使用以下方法進行優化。 Apache 建議對 Apache MPM worker 進行設定: …
要開啟或關閉 PHP 的錯誤訊息有幾種方法, 分別是在 php.ini 內設定, httpd.conf 及 .htaccess 設定, 或者在 PHP 程式內設定, 以下是各種方法的設定方法。 1. php.ini 在 php.ini 一般預設路徑在 /etc/php.ini, 在 php.ini 內找到 display_errors, 設定為 On 是開啟錯誤信息, Off 是關閉輸出: …
想要透過 Apache 實現上載限制, 可以通過限制 HTTP 請求的大小來實現, 並根據需要對個別目錄、檔案或位置進行限制。 例如要設定 /var/www/html/uploads 目錄的上載限制為 5MB, 可以在 httpd.conf 或 .htaccess 加入以下設定, 以下是 httpd.conf 的預設位置: RHEL / CentOS: # vi /etc/httpd/conf/httpd.conf Debian / Ubuntu: # …
Let’s Encrypt 推出免費 SSL 憑證,讓想使用 SSL 的網站節省不少成本,而且使用 Let’s Encrypt 提供的客戶端申請及 renew 憑證,比起在網上購買更加方便。雖然 Let’s Encrypt 的憑證每次只可以申請 3 個月,但可以使用 crontab 自動 renew 憑證,使用上也是很方便。以下介紹在 RHEL 及 CentOS 7 安裝 Let’s Encrypt 客戶端 …
當 Apache 其中一個 Virtual Host 佔用資源過多時,會拖慢整台伺服器所有網站的速度,這時可以安裝 mod_cband 模組,限制個別虛擬主機可以佔用的連線數量及頻寬,以下會示範在 CentOS 7 安裝 mod_cband 模組: 要安裝 mod_cband,需要先安裝 httpd-devel: # yum install httpd-devel 然後可以下載 mod_cband 及編譯安裝: # cd /usr/local/src # wget https://github.com/maiha/mod_cband/archive/master.zip …
今天編譯安裝 Apache, Apache 的預設安裝目錄是 /usr/local/apache2, 但我將它安裝到 /usr/local/apache, 但在編譯時出現以下錯誤: 原因可能是之前編譯 Apache 時, 有一些紀錄是安裝到 /usr/local/apache2 所致, 解決方法是有兩個: 1. 執行 make clean 指令, 再重新編譯。 2. 將原始碼的目錄刪除, 再重新解壓 Apache 的源始碼, 再進行編譯安裝即可。
用 Ubuntu 安裝好 Apache 後,啟動 Apache 時會出現以下報錯: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message …