預設document root在 /var/www,所以在此目錄下建一個新目錄:
sudo mkdir /var/www/example.com/
2.Grant Permissions
sudo chown -R $USER:$USER /var/www/example.com/
($USER設呈現在登入的user name)
sudo chmod -R 755 /var/www/example.com/
3.建立新的Virtual Host Files
sudo vi /etc/apache2/sites-available/example.com.conf
檔案內容如下:
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
4.Enable the New Virtual Host Files
sudo a2ensite example.com.conf
5.Apache重新載入設定:
sudo service apache2 reload
or
sudo service apache2 restart
沒有留言:
張貼留言