您好我的问题是当我尝试访问我的本地人的网址时,我没有得到正确的指示。这是我的设置:
/var/www/example.com
包含所有代码
/etc/apache2/sites-avaliable/example.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName example.com
ServerAlias www.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory "/var/www/html">
AllowOverride All
</Directory>
最后我的/ etc / hosts
# This file is automatically generated by WSL based on the Windows hosts
file:
# %WINDIR%\System32\drivers\etc\hosts. Modifications to this file will be
overwritten.
127.0.0.1 localhost
127.0.0.1 example.com
当我ping example.com时,我得到了
PING example.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=128 time=0.392 ms
但是当我转到http://example.com时,它只是普通的域名网站。我清除了Chrome和我的缓存
sudo service nscd restart
任何帮助将不胜感激,谢谢。
答案 0 :(得分:0)
我在Windows上运行它。所以在教程DigitalOcean中,第6步对我不起作用(第六步 - 设置本地主机文件(可选))。我要做的就是打开“开始”菜单,搜索“记事本”,右键单击“打开管理员”,打开文件,转到C:\ Windows \ System32 \ drivers \ etc \托管并在此处添加example.com。一旦我这样做,我就会被重定向到我的localhost。谢谢@PrathameshPalav的帮助!