- /etc/hosts :將裡面的host name對應到新更動的IP即可
- /etc/apache2/sites-enabled/000-default.conf:不用更動這個存放virtual host的設定檔
2020年4月15日 星期三
Apache2用virtual host的網頁不正常
網頁伺服器用apache2,機器搬家後發現原來上面透過virtual host架的網頁無法正常顯示,而是跳出apache的歡迎頁面。搞半天才發現不是apache2的設定錯誤,而是host name設定錯誤。所以對於下面兩個檔案:
2020年4月14日 星期二
AH00558: apache2: Could not reliably determine the server's fully qualified domain name
在啟動Apache2的網頁伺服器時,雖可正常啟動,但卻出現下面的警告訊息
最簡單的解決方法在 /etc/apache2/apache2.conf 裡面加入機器正確的名稱
- AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
最簡單的解決方法在 /etc/apache2/apache2.conf 裡面加入機器正確的名稱
2016年12月8日 星期四
啟動Apache2的rewrite模組
Apache的rewrite模組可讓網址看起來比較簡潔(參考《【FreeBSD】在 Apache 利用 mod_rewrite 做到網址轉換》)。以下是安裝在Debian下面的Apache2打開rewrite模組的指令:
_EOF_
- a2enmod rewrite
- service apache2 restart
_EOF_
2016年12月7日 星期三
讓Apache2支援php
架設網頁伺服器,讓使用者可以在自己家目錄的public_html裡面的php程式正確顯示在網頁上,依序執行:
- sudo apt-get install apache2 php5 libapache2-mod-php5
- 修改 /etc/apache2/mods-enabled/php5.conf,下面的設定要加上#,改成這樣
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule> - sudo a2enmod php5
- sudo a2enmod userdir
- service apache2 restart
2016年8月24日 星期三
設定htaccess直接下載檔案
在自己的網頁下,希望某些檔案可以直接下載而不是由瀏覽器開啟,可以藉由修改htaccess來完成。例如說,figure.tiff 這個圖檔放在/home/username/public_html/xxx/ 下面,那麼就只要在這個xxx資料夾下新增一個 .htaccess 檔案,其內容如下:
<FilesMatch "\.(tiff|tif)$">
Allow from all
Header set Content-Disposition attachment
</FilesMatch>
<FilesMatch "\.(tiff|tif)$">
Allow from all
Header set Content-Disposition attachment
</FilesMatch>
訂閱:
文章 (Atom)