给Ubuntu添加新的虚拟主机

时间:2022-08-29 11:01:31

1 创建站点文件

/etc/apache2/sites-available/xxxx.com.conf

2 内容如下:

<VirtualHost *:80>
ServerAdmin webmaster@rekihvac.reihekai.com
ServerName xxxx.com
ServerAlias www.xxxx.com
DocumentRoot /var/www/html/xxxx.com/public_html/
ErrorLog /var/www/html/xxxx.com/logs/error.log
CustomLog /var/www/html/xxxx.com/logs/access.log combined
</VirtualHost>

3 创建目录


sudo mkdir -p /var/www/html/xxxx.com/public_html
sudo mkdir /var/www/html/xxxx.com/logs


4 激活站点


sudo a2ensite xxxx.com