啟用 userdir 模組:
sudo a2enmod userdir
修改 userdir.conf
sudo nano /etc/apache2/mods-enabled/userdir.conf
更改成這樣:(藍色部分)
<IfModule mod_userdir.c> UserDir public_html UserDir disabled root <Directory /home/*/public_html> AllowOverride All Options MultiViews Indexes SymLinksIfOwnerMatch <Limit GET POST OPTIONS> Require all granted </Limit> <LimitExcept GET POST OPTIONS> Require all denied </LimitExcept> </Directory> </IfModule>
修改 php 設定:
sudo nano /etc/apache2/mods-available/php5.conf
從 <IfModule mod_userdir.c> 到下一個 </IfModule> 的幾行要註解掉,所以會看起來像這樣:
#<IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_value engine Off # </Directory> #</IfModule>
重啟 apache:
sudo service apache2 restart
建立 user 的網頁根目錄 public_html:
mkdir /home/$USER/public_html
source: Enable userdir Apache module on Ubuntu Linux and other Debian based distributions