Ubuntu apache2服务器上的多个站点
我试图在同一ip上为多个站点提供服务。这些是/etc/apache2/sites下可用的配置 默认配置:Ubuntu apache2服务器上的多个站点,ubuntu,apache2,Ubuntu,Apache2,我试图在同一ip上为多个站点提供服务。这些是/etc/apache2/sites下可用的配置 默认配置: NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride No
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName site1.ws
ServerAlias *.site.ws
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site1.ws/htdocs"
# Custom log file locations
LogLevel warn
ErrorLog /var/www/vhosts/site1.ws/log/error.log
CustomLog /var/www/vhosts/site1.ws/log/access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site1/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName me.site2.com
ServerAlias me.site2.com
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site2.com/htdocs/"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site2.com/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
NameVirtualHost*:80
服务器管理员webmaster@localhost
DocumentRoot/var/www/
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
#该指令允许我们拥有apache2的默认起始页
#在/apache2 default/中,但仍有/转到正确的位置
重定向匹配^/$/apache2默认值/
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项EXECGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog/var/log/apache2/error.log
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog/var/log/apache2/access.log组合
服务器签名
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
第一个站点:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName site1.ws
ServerAlias *.site.ws
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site1.ws/htdocs"
# Custom log file locations
LogLevel warn
ErrorLog /var/www/vhosts/site1.ws/log/error.log
CustomLog /var/www/vhosts/site1.ws/log/access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site1/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName me.site2.com
ServerAlias me.site2.com
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site2.com/htdocs/"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site2.com/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
服务器管理员techm3@gmail.com
服务器名site1.ws
ServerAlias*.site.ws
#索引文件和文档根目录(公共文件所在的位置)
DirectoryIndex.html
DocumentRoot“/var/www/vhosts/site1.ws/htdocs”
#自定义日志文件位置
日志级别警告
ErrorLog/var/www/vhosts/site1.ws/log/error.log
CustomLog/var/www/vhosts/site1.ws/log/access.log
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
第二站点:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName site1.ws
ServerAlias *.site.ws
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site1.ws/htdocs"
# Custom log file locations
LogLevel warn
ErrorLog /var/www/vhosts/site1.ws/log/error.log
CustomLog /var/www/vhosts/site1.ws/log/access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site1/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
<VirtualHost *:80>
ServerAdmin techm3@gmail.com
ServerName me.site2.com
ServerAlias me.site2.com
# Index file and document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot "/var/www/vhosts/site2.com/htdocs/"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/vhosts/site2.com/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/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
</Directory>
服务器管理员techm3@gmail.com
ServerName me.site2.com
ServerAlias me.site2.com
#索引文件和文档根目录(公共文件所在的位置)
DirectoryIndex.html
DocumentRoot“/var/www/vhosts/site2.com/htdocs/”
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
每当我尝试加载site2时,它都会提供site1的内容。我做错了什么
注意:我正在将Godaddy的域和子域重定向到端口80上的服务器ip。在/etc/hosts文件中注册你的两个站点在/etc/hosts文件中注册你的两个站点拍摄时,我遇到了同样的问题,我不记得是如何修复的。您是否有另一个
VirtualHost
或ServerName
位置?@minitech在/etc/apache2/httpd.conf中我有ServerName localhost在您的/etc/apache2/站点中只有site1和site2 vhost可用
文件?你用来加载site2的URL是什么?site1和site2配置文件都在/etc/apache2/sites available
中,并且都是使用a2ensite
启用的,而且这两个DocumentRoot
都是不同的。哎呀,我也有同样的问题,我记不起是怎么解决的。您是否有另一个VirtualHost
或ServerName
位置?@minitech在/etc/apache2/httpd.conf中我有ServerName localhost在您的/etc/apache2/站点中只有site1和site2 vhost可用
文件?您用于加载site2的URL是什么?site1和site2配置文件都位于/etc/apache2/sites available
中,并且都是使用a2ensite
启用的,并且这两个DocumentRoot
都不同。