这很简单,因为您已经安装了 apache,您将能够看到一个名为:的文件/etc/apache2/sites-enabled/000-default
,它指向您www
在var
. 这个想法是 apache 将它作为主配置文件,因此您可以根据需要定义任意数量的.conf
文件,您可能想要这样的东西:
/etc/apache2/sites-enabled/
├── 000-default -> ../sites-available/default
└── subsystems
└── appA.conf
└── appB.conf
└── appMyWebSite.conf
所以它更容易处理,因为您将所有内容分割成几个 conf 文件,只要您需要就可以。
现在,那些必须有什么?这取决于您需要什么,但这几乎是您需要的:
<Directory "/var/www/mywebsite.com/">
Options Indexes Includes FollowSymLinks MultiViews +ExecCGI
AddHandler cgi-script cgi pl
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.cgi index.html
</Directory>
<VirtualHost *:80>
ServerName mywebsite.com
ServerAdmin youremail@provider.com
SetEnv VAR_IF_YOU_NEED_ONE VALUE
RewriteEngine on
DocumentRoot "/var/www/mywebsite.com/"
LogLevel warn
ServerSignature Off
#And whatever you need take a look to apache documentation
</VirtualHost>
因此,您可以将您的域名指向相同的服务器 ip 地址,apache 将根据这些域的名称来处理它(即所有域的相同 ip)
希望这可以帮助。