已安装apache2的Ubuntu 11.04和所有相关软件包。我已经尝试了大多数博客,并把google和其他论坛当作我最好的朋友,但是我无法解决此问题。
我需要在本地系统上设置一个命名的虚拟主机以进行开发。
我在其中创建目录“ vivek”,/var/www
并复制了默认的index.html并编辑了一些元素。
我添加的文件vivek.com
中/etc/apache2/sites-available
,如下所示:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.vivek.com
DocumentRoot /var/www/vivek
# Other directives here
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/vivek/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<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
</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>
即我添加了以下几行
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.vivek.com
DocumentRoot /var/www/vivek
# Other directives here
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/vivek/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
到“ sites-available”文件夹中已经存在的默认文件(编辑默认文件之前先备份它)
在/ etc / hosts中存在的hosts文件中添加了此内容
127.0.0.1 localhost
127.0.1.1 vivek-PC
127.0.0.1 www.vivek.com
执行以下操作,没有错误:
root@vivek-PC:~# a2ensite vivek.com
Enabling site vivek.com.
Run '/etc/init.d/apache2 reload' to activate new configuration!
root@vivek-PC:~# /etc/init.d/apache2 reload
* Reloading web server config apache2
当我输入时www.vivek.com
,它给了我默认的index.html,/var/www
但没有在编辑的/ var / www / vivek文件夹中提供默认的index.html 。
后来,我从中编辑了index.html,/var/www
但仍得到了相同的index.html(编辑之前为默认值)。所有index.htmls都已被编辑,但是Apache似乎有一些隐藏的内容,当我请求时它会不断出现www.vivek.com
具有讽刺意味的是,在我重新启动后-Apache正常运行,但是我的站点- www.vivek.com
无法显示(即使index.html被隐藏了,上帝也知道了!)。现在我的浏览器显示“无法连接”
请帮忙。自一周以来,我一直在尝试进行设置,但未成功。