
我的 php 程式碼無法在 mod_userdir (~/user) 目錄下運作,但在 /var/www/ 下運作正常,我該如何處理這個問題?當我在 ~/user 下開啟 php 檔案時,我的瀏覽器提示下載
答案1
請查看/etc/apache2/mods-enabled/php5.conf,它有這樣的註解:
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
更改檔案後,使用 重新啟動 Apache service apache2 restart
。
答案2
確保mod_userdir
Apache 擴充功能已啟用。透過以下命令啟用:
a2enmod userdir
sudo
如果需要,請加上前綴。
然後重新載入/重新啟動 Apache ( service apache2 restart
)。