ny3259 发表于 2018-11-24 14:05:25

Apache虚拟主机指南

  基于名字的(通过域名来区分)的虚拟主机
  基于端口的虚拟主机
  基于IP的虚拟主机
  基于端口的虚拟主机
  1、建立虚拟主机使用的目录、设置好权限
  2、修改/etc/apache2/ports.conf,增加需要监听的端口
  ports.conf:
  NameVirtualHost *:80
  Listen 80
  Listen 8080
  3、到/etc/apache2/sites-enabled目录下,拷贝一份000-default命名为mysite,使用文本编辑器打开mysite,修改端口、DocumentRoot和Directory。最好也修改一下日志文件,方便查看。详见下边的例子,红色为需要修改的地方。
  mysite:
  
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/mysite
  
  Options FollowSymLinks
  AllowOverride None
  
  
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  
  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
  
  ErrorLog /var/log/apache2/error_mysite.log
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn
  CustomLog /var/log/apache2/access_mysite.log combined
  Alias /doc/ "/usr/share/doc/"
  
  Options Indexes MultiViews FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  Allow from 127.0.0.0/255.0.0.0 ::1/128
  
  
  4、重启apache服务
  sudo /etc/init.d/apache2 restart

页: [1]
查看完整版本: Apache虚拟主机指南